Unverified Commit 645b90f6 authored by Dan Jones's avatar Dan Jones
Browse files

refactor: move common steps from auth into common

+ correct the feature description for getAuthorizationHeader
parent c4d324c2
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
......
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) => {
......
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment