Repository: codeceptjs/CodeceptJS (JavaScript)

Issue:
REST: Method "amBearerAuthenticated" doesn't work, no Authorization header is sent
#### What are you trying to achieve?
I'm able to replace the code
```js
const response = await I.sendGetRequest("http://localhost:3030/year?default=1", {Authorization: "Bearer xyz"});
```

by 
```js
I.amBearerAuthenticated("xyz");
const response = await I.sendGetRequest("http://localhost:3030/year?default=1");
```

3.3.0 should support it: https://codecept.io/api/#rest
#### What do you get instead?

Headers are sent as empty (I should get `"headers":{"Authorization":"Bearer xyz"}`)

```bash
Api --
    [1]  Starting recording promises
    Timeouts: 
 › [Session] Starting singleton browser session
  test something
    I am bearer authenticated "xyz"
    I send get request "http://localhost:3030/year?default=1"
    › [Request] {"baseURL":"http://localhost:3030/year?default=1","headers":{}}
    › [Response] Response error. Status code: 401
    › [Response] {"name":"NotAuthenticated","message":"Not authenticated","code":401,"className":"not-authenticated","errors":{}}
  ✔ OK in 24ms
```

> Provide test source code if related

```js
Feature('Api');

Scenario('test something', async ({ I }) => {
    I.amBearerAuthenticated("xyz");
    const response = await I.sendGetRequest("http://localhost:3030/year?default=1");
});
```

### Details

* CodeceptJS version: 3.3.0
* NodeJS Version: v14.18.3
* Operating System: Ubuntu 21.10
* Configuration file:

```js
exports.config = {
    tests: './*_test.js',
    output: './output',
    helpers: {
        Playwright: {
            url: 'https://playwright.dev',
            timeout: 10000,
            show: false,
            browser: 'chromium'
        },
        REST: {
        }
    },
    include: {
        I: './steps_file.js'
    },
    bootstrap: null,
    mocha: {},
    name: 'playwright'
}
```



Discussion:
I think it can be solved by inserting of
```js
// request.headers is empty by default, add a custom header this.headers to it
request.headers = {...request.headers, ...this.headers}
```
at the begin of the method
https://github.com/codeceptjs/CodeceptJS/blob/b9bfce36b5046a8afcd52ec0749561227c5185fe/lib/helper/REST.js#L114



Patch:
diff --git a/lib/helper/REST.js b/lib/helper/REST.js
index c9cbcae1b..90212d2ce 100644
--- a/lib/helper/REST.js
+++ b/lib/helper/REST.js
@@ -112,6 +112,9 @@ class REST extends Helper {
    * @returns {Promise<*>} response
    */
   async _executeRequest(request) {
+    // Add custom headers. They can be set by amBearerAuthenticated() or haveRequestHeaders()
+    request.headers = { ...request.headers, ...this.headers };
+
     const _debugRequest = { ...request };
     this.axios.defaults.timeout = request.timeout || this.options.timeout;
 


Test patch:
diff --git a/test/rest/REST_test.js b/test/rest/REST_test.js
index f9de8678c..d0971d7ba 100644
--- a/test/rest/REST_test.js
+++ b/test/rest/REST_test.js
@@ -178,6 +178,44 @@ describe('REST', () => {
       response.config.headers.should.have.property('Content-Type');
       response.config.headers['Content-Type'].should.eql('application/json');
     });
+
+    it('should set headers for all requests', async () => {
+      I.haveRequestHeaders({ 'XY1-Test': 'xy1test' });
+      // 1st request
+      {
+        const response = await I.sendGetRequest('/user');
+
+        response.config.headers.should.have.property('XY1-Test');
+        response.config.headers['XY1-Test'].should.eql('xy1test');
+
+        response.config.headers.should.have.property('X-Test');
+        response.config.headers['X-Test'].should.eql('test');
+      }
+      // 2nd request
+      {
+        const response = await I.sendPostRequest('/user', { name: 'john' }, { 'XY2-Test': 'xy2test' });
+
+        response.config.headers.should.have.property('XY1-Test');
+        response.config.headers['XY1-Test'].should.eql('xy1test');
+
+        response.config.headers.should.have.property('XY2-Test');
+        response.config.headers['XY2-Test'].should.include('xy2test');
+
+        response.config.headers.should.have.property('X-Test');
+        response.config.headers['X-Test'].should.eql('test');
+      }
+    });
+
+    it('should set Bearer authorization', async () => {
+      I.amBearerAuthenticated('token');
+      const response = await I.sendGetRequest('/user');
+
+      response.config.headers.should.have.property('Authorization');
+      response.config.headers.Authorization.should.eql('Bearer token');
+
+      response.config.headers.should.have.property('X-Test');
+      response.config.headers['X-Test'].should.eql('test');
+    });
   });
 
   describe('_url autocompletion', () => {