@apideck/portman
Version:
Port OpenAPI Spec to Postman Collection, with contract & variation tests included
172 lines • 7.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var _1 = require(".");
var getPostmanMappedOperation_1 = require("../../../__tests__/testUtils/getPostmanMappedOperation");
describe('overwriteRequestSecurity', function () {
it('should overwrite the request apiKey definition', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var overwriteValues, pmOperation;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
overwriteValues = {
apiKey: {
key: 'x-apideck-app-id',
value: 'foo-bar-baz'
}
};
return [4, (0, getPostmanMappedOperation_1.getPostmanMappedOperation)()];
case 1:
pmOperation = _a.sent();
(0, _1.overwriteRequestSecurity)(overwriteValues, pmOperation);
expect(pmOperation.item.getAuth()).toMatchSnapshot();
return [2];
}
});
}); });
it('should overwrite the request basic auth', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var overwriteValues, pmOperation;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
overwriteValues = {
basic: {
username: 'foo',
password: 'bar'
}
};
return [4, (0, getPostmanMappedOperation_1.getPostmanMappedOperation)()];
case 1:
pmOperation = _a.sent();
(0, _1.overwriteRequestSecurity)(overwriteValues, pmOperation);
expect(pmOperation.item.getAuth()).toMatchSnapshot();
return [2];
}
});
}); });
it('should overwrite the request bearer token auth', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var overwriteValues, pmOperation;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
overwriteValues = {
bearer: {
token: 'foo'
}
};
return [4, (0, getPostmanMappedOperation_1.getPostmanMappedOperation)()];
case 1:
pmOperation = _a.sent();
(0, _1.overwriteRequestSecurity)(overwriteValues, pmOperation);
expect(pmOperation.item.getAuth()).toMatchSnapshot();
return [2];
}
});
}); });
it('should overwrite the request Oauth2 auth', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var overwriteValues, pmOperation;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
overwriteValues = {
oauth2: [
{
key: 'scope',
value: '{{PC_SCOPE}}',
type: 'string'
},
{
key: 'password',
value: '{{PC_PASSWORD}}',
type: 'string'
},
{
key: 'username',
value: '{{PC_USERNAME}}',
type: 'string'
},
{
key: 'clientSecret',
value: '{{PC_CLIENT_SECRET}}',
type: 'string'
},
{
key: 'clientId',
value: '{{PC_CLIENT_ID}}',
type: 'string'
},
{
key: 'accessTokenUrl',
value: '{{PC_ACCESS_TOKEN__URL}}',
type: 'string'
},
{
key: 'tokenName',
value: '{{PC_TOKEN_NAME}}',
type: 'string'
},
{
key: 'grant_type',
value: 'password_credentials',
type: 'string'
},
{
key: 'refreshRequestParams',
value: [],
type: 'any'
},
{
key: 'tokenRequestParams',
value: [],
type: 'any'
},
{
key: 'authRequestParams',
value: [],
type: 'any'
},
{
key: 'challengeAlgorithm',
value: 'S256',
type: 'string'
},
{
key: 'addTokenTo',
value: 'header',
type: 'string'
},
{
key: 'client_authentication',
value: 'body',
type: 'string'
}
]
};
return [4, (0, getPostmanMappedOperation_1.getPostmanMappedOperation)()];
case 1:
pmOperation = _a.sent();
(0, _1.overwriteRequestSecurity)(overwriteValues, pmOperation);
expect(pmOperation.item.getAuth()).toMatchSnapshot();
return [2];
}
});
}); });
it('should remove the request bearer token auth', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var overwriteValues, pmOperation;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
overwriteValues = {
remove: true
};
return [4, (0, getPostmanMappedOperation_1.getPostmanMappedOperation)()];
case 1:
pmOperation = _a.sent();
(0, _1.overwriteRequestSecurity)(overwriteValues, pmOperation);
expect(pmOperation.item.getAuth()).toMatchSnapshot();
return [2];
}
});
}); });
});
//# sourceMappingURL=overwriteRequestSecurity.test.js.map