Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit b1a58ac

Browse files
author
Chris Wiechmann
committed
Integration tests and a small bug fixed
1 parent 7a033f8 commit b1a58ac

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

apibuilder4elastic/custom_flow_nodes/api-builder-plugin-axway-api-management/src/actions.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ async function lookupTopology(params, options) {
129129
var topology;
130130
if(requestHeaders.authorization) {
131131
logger.debug(`Trying to get API-Gateway topology based on Authorization header.`);
132-
topology = await _getTopology(headers = {'Authorization': `${requestHeaders.authorization}`}, options);
132+
topology = await _getTopology(headers = {'Authorization': `${requestHeaders.authorization}`}, logger);
133133
} else {
134134
logger.trace(`Trying to get API-Gateway topology based on VIDUSR cookie.`);
135-
topology = await _getTopology(headers = {'Cookie': requestHeaders.cookie, 'csrf-token': requestHeaders['csrf-token']}, options);
135+
topology = await _getTopology(headers = {'Cookie': requestHeaders.cookie, 'csrf-token': requestHeaders['csrf-token']}, logger);
136136
}
137137
if(topology.services) {
138138
topology.services = topology.services.filter(function(service) {
@@ -453,7 +453,7 @@ async function _getCurrentGWUser(requestHeaders) {
453453
return loginName;
454454
}
455455

456-
async function _getTopology(requestHeaders, options) {
456+
async function _getTopology(requestHeaders, logger) {
457457
var options = {
458458
path: '/api/topology',
459459
headers: requestHeaders,
@@ -464,8 +464,8 @@ async function _getTopology(requestHeaders, options) {
464464
return response.body.result;
465465
})
466466
.catch(err => {
467-
options.logger.error(`Error getting API-Gateway topology from Admin-Node-Manager. Request sent to: '${pluginConfig.apigateway.url}'. Response-Code: ${err.statusCode}`);
468-
options.logger.error(`This error will cause the application to fail in a future release.`);
467+
logger.error(`Error getting API-Gateway topology from Admin-Node-Manager. Request sent to: '${pluginConfig.apigateway.url}'. Response-Code: ${err.statusCode}`);
468+
logger.error(`This error will cause the application to fail in a future release.`);
469469
return {};
470470
// During a grace period it not cause the entire application to fail - Just EMT will not include all services.
471471
//throw new Error(`Error getting API-Gateway topology from Admin-Node-Manager. Request sent to: '${pluginConfig.apigateway.url}'. Response-Code: ${err.statusCode}`);

apibuilder4elastic/test/trafficMonitorAPI/asAdmin/payload/test_payload.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('Payload', function () {
1616
// Simulate all responses in this test-file to be an admin, which will not lead to any result restriction
1717
nock('https://mocked-api-gateway:8090').get('/api/rbac/currentuser').reply(200, { "result": "david" });
1818
nock('https://mocked-api-gateway:8090').get('/api/rbac/permissions/currentuser').replyWithFile(200, './test/mockedReplies/apigateway/adminUserDavid.json');
19+
nock('https://mocked-api-gateway:8090').get('/api/topology').reply(200, { result: {} });
1920
});
2021

2122
afterEach(() => {
@@ -55,7 +56,7 @@ describe('Payload', function () {
5556
after(() => stopApiBuilder(server));
5657

5758
describe('Payload tests', () => {
58-
it('[Payload-0001] Should return sent payload for leg 0', () => {
59+
it.only('[Payload-0001] Should return sent payload for leg 0', () => {
5960
const testPayload = fs.readFileSync(`${payloadFolder}/2020-07-03/08.55/0455ff5e82267be8182a553d-0-sent`);
6061
return requestAsync({
6162
method: 'GET', //

apibuilder4elastic/test/trafficMonitorAPI/restricted/http/test_payload_disabled_authz.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ describe('Payload restricted', function () {
5050
it('[Disabled-AuthZ-Payload-0001] Should return payload as the authz is disabled', () => {
5151
nock('https://mocked-api-gateway:8090').get('/api/rbac/currentuser').reply(200, { "result": "chris" });
5252
nock('https://mocked-api-gateway:8090').get('/api/rbac/permissions/currentuser').replyWithFile(200, './test/mockedReplies/apigateway/operatorChris.json');
53+
nock('https://mocked-api-gateway:8090').get('/api/topology').reply(200, { result: {} });
54+
5355
return requestAsync({
5456
method: 'GET',
5557
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/0455ff5e82267be8182a553d/1/received`,

apibuilder4elastic/test/trafficMonitorAPI/restricted/http/test_payload_extHttp1.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ describe('Payload restricted using Ext HTTP-Service', function () {
5454
it('[Ext-AuthZ-Payload-0001] Should return payload as the authz is disabled', () => {
5555
nock('https://mocked-api-gateway:8090').get('/api/rbac/currentuser').reply(200, { "result": "chris" });
5656
nock('https://mocked-api-gateway:8090').get('/api/rbac/permissions/currentuser').replyWithFile(200, './test/mockedReplies/apigateway/operatorChris.json');
57+
nock('https://mocked-api-gateway:8090').get('/api/topology').reply(200, { result: {} });
5758

5859
nock('https://mocked-server:8443')
5960
.defaultReplyHeaders({'Content-Type': 'application/json; charset=utf-8'})

apibuilder4elastic/test/trafficMonitorAPI/restricted/http/test_payload_restricted.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ describe('Payload restricted', function () {
5151
nock('https://mocked-api-gateway:8090').get('/api/rbac/permissions/currentuser').replyWithFile(200, './test/mockedReplies/apigateway/operatorChris.json');
5252
nock('https://mocked-api-gateway:8075').get(`/api/portal/v1.3/users?field=loginName&op=eq&value=chris&field=enabled&op=eq&value=enabled`).replyWithFile(200, './test/mockedReplies/apimanager/apiManagerUserChris.json');
5353
nock('https://mocked-api-gateway:8075').get(`/api/portal/v1.3/organizations/2bfaa1c2-49ab-4059-832d-CHRIS`).replyWithFile(200, './test/mockedReplies/apimanager/organizationChris.json');
54+
nock('https://mocked-api-gateway:8090').get('/api/topology').reply(200, { result: {} });
55+
56+
5457
return requestAsync({
5558
method: 'GET',
5659
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/0455ff5e82267be8182a553d/1/received`,
@@ -71,6 +74,8 @@ describe('Payload restricted', function () {
7174
nock('https://mocked-api-gateway:8090').get('/api/rbac/permissions/currentuser').replyWithFile(200, './test/mockedReplies/apigateway/operatorMax.json');
7275
nock('https://mocked-api-gateway:8075').get(`/api/portal/v1.3/users?field=loginName&op=eq&value=max&field=enabled&op=eq&value=enabled`).replyWithFile(200, './test/mockedReplies/apimanager/apiManagerUserMax.json');
7376
nock('https://mocked-api-gateway:8075').get(`/api/portal/v1.3/organizations/2bfaa1c2-49ab-4059-832d-MAX`).replyWithFile(200, './test/mockedReplies/apimanager/organizationMax.json');
77+
nock('https://mocked-api-gateway:8090').get('/api/topology').reply(200, { result: {} });
78+
7479
return requestAsync({
7580
method: 'GET',
7681
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/0455ff5e82267be8182a553d/1/received`,
@@ -91,6 +96,8 @@ describe('Payload restricted', function () {
9196
nock('https://mocked-api-gateway:8090').get('/api/rbac/permissions/currentuser').replyWithFile(200, './test/mockedReplies/apigateway/operatorRene.json');
9297
nock('https://mocked-api-gateway:8075').get(`/api/portal/v1.3/users?field=loginName&op=eq&value=rene&field=enabled&op=eq&value=enabled`).replyWithFile(200, './test/mockedReplies/apimanager/apiManagerUserRene.json');
9398
nock('https://mocked-api-gateway:8075').get(`/api/portal/v1.3/organizations/2bfaa1c2-49ab-4059-832d-MAX`).replyWithFile(200, './test/mockedReplies/apimanager/organizationMax.json');
99+
nock('https://mocked-api-gateway:8090').get('/api/topology').reply(200, { result: {} });
100+
94101
return requestAsync({
95102
method: 'GET',
96103
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/0455ff5e82267be8182a553d/0/sent`,

0 commit comments

Comments
 (0)