diff --git a/features/adapter_get-authorization-header.feature b/features/adapter_get-authorization-header.feature index 59de9a4a56c34647e2a307644d988bc3262a761e..554acdf0378c917328ca72921843c39315a1f580 100644 --- a/features/adapter_get-authorization-header.feature +++ b/features/adapter_get-authorization-header.feature @@ -1,5 +1,5 @@ -Feature: Does the adapter authenticate? - When an adapter instance is created it authenticates and receives a token +Feature: Can the adapter create an authorization header? + The adapter getAuthorizationHeader method works as expected Scenario: getAuthorizationHeader returns a bearer token Given valid config diff --git a/test/cucumber/adapter/auth.steps.js b/test/cucumber/adapter/auth.steps.js index 110d21ce7e617fa2c3f1fd8c8b29079508efac73..386c5f5a5ebfc09684e240f7e54a53266da199d5 100644 --- a/test/cucumber/adapter/auth.steps.js +++ b/test/cucumber/adapter/auth.steps.js @@ -1,25 +1,8 @@ const assert = require('assert'); -const { Given, When, Then } = require('@cucumber/cucumber'); +const { When, Then } = require('@cucumber/cucumber'); const { fixtures } = require('../../fixtures/server'); -const mockValidConfig = fixtures.get('config-valid'); -const mockInvalidConfig = fixtures.get('config-invalid'); - -const mockSchema = require('../../mock/swagger.json'); -const { Adapter } = require('../../../dist/adapter'); - - -Given('valid config', function() { - this.config = mockValidConfig -}); - -When('the adapter instance is created', function() { - //let mockProtocol = new GenericProtocol(this.schema); - let mockAdapter = new Adapter(this.protocol, this.config); - this.adapter = mockAdapter; -}); - When('the auth method is called', async function() { await this.adapter.auth(); }); @@ -28,11 +11,6 @@ Then('the adapter credentials are populated', function() { assert.equal(this.adapter.credentials.token, fixtures.get('response-valid-token').token); }); -Given('invalid config', function() { - this.schema = mockSchema; - this.config = mockInvalidConfig; -}); - Then('the adapter auth fails', function() { this.adapter.auth() .catch((error) => { diff --git a/test/cucumber/adapter/common.steps.js b/test/cucumber/adapter/common.steps.js index 5236e909eded68590dfb0a5018eb414321670e48..3979c109129570ebbebf964d82b37d9529999b96 100644 --- a/test/cucumber/adapter/common.steps.js +++ b/test/cucumber/adapter/common.steps.js @@ -1,5 +1,26 @@ const assert = require('assert'); -const { When, Then } = require('@cucumber/cucumber'); +const { Given, When, Then } = require('@cucumber/cucumber'); + +const { fixtures } = require('../../fixtures/server'); + +const mockValidConfig = fixtures.get('config-valid'); +const mockInvalidConfig = fixtures.get('config-invalid'); +const mockSchema = require('../../mock/swagger.json'); +const { Adapter } = require('../../../dist/adapter'); + +Given('valid config', function() { + this.config = mockValidConfig +}); + +Given('invalid config', function() { + this.schema = mockSchema; + this.config = mockInvalidConfig; +}); + +When('the adapter instance is created', function() { + let mockAdapter = new Adapter(this.protocol, this.config); + this.adapter = mockAdapter; +}); Then('a successful response is returned with status {int}', function(expectedStatus) { this.call