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

Commit 7a033f8

Browse files
author
Chris Wiechmann
committed
Integration tests fixed
1 parent 5c06328 commit 7a033f8

File tree

9 files changed

+84
-47
lines changed

9 files changed

+84
-47
lines changed

apibuilder4elastic/flows/trafficMonitorApi-payload.json

Lines changed: 71 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -157,51 +157,6 @@
157157
},
158158
"metaMethod": "Execute"
159159
},
160-
"javascript.2": {
161-
"type": "nodehandler://@axway/api-builder-plugin-fn-javascript/javascript",
162-
"name": "Create query",
163-
"method": "Execute",
164-
"parameters": [
165-
{
166-
"name": "data",
167-
"type": "jsonpath",
168-
"value": "$",
169-
"metaName": "data",
170-
"metaDescription": "The value to apply as the `data` argument to the JavaScript code. For objects and arrays, `data` is passed by reference."
171-
},
172-
{
173-
"name": "code",
174-
"type": "string",
175-
"value": "\"let elasticQuery = {\\n \\\"bool\\\": {\\n \\\"must\\\": [\\n {\\\"term\\\": {\\\"correlationId\\\": data.params.correlationID}},\\n {\\\"term\\\": {\\\"processInfo.serviceId\\\": data.params.serviceID}}\\n ]\\n }\\n };\\n return elasticQuery;\"",
176-
"metaName": "code",
177-
"metaDescription": "A JavaScript function body. Supports `await` and returning promises."
178-
},
179-
{
180-
"name": "unsafe",
181-
"type": "boolean",
182-
"value": "true",
183-
"metaName": "Unsafe mode",
184-
"metaDescription": "USE WITH CAUTION. When enabled, JavaScript is not executed in a sandboxed environment and all globals are available."
185-
}
186-
],
187-
"outputs": {
188-
"next": {
189-
"context": "$.elasticsearch.query",
190-
"routes": [
191-
"authorization.1"
192-
],
193-
"metaName": "Next"
194-
},
195-
"error": {
196-
"context": "$.error",
197-
"routes": [
198-
"http.3"
199-
],
200-
"metaName": "Error"
201-
}
202-
},
203-
"metaMethod": "Execute"
204-
},
205160
"http.2": {
206161
"type": "nodehandler://axway-flow/http",
207162
"name": "Set HTTP Response",
@@ -428,7 +383,7 @@
428383
"outputs": {
429384
"next": {
430385
"routes": [
431-
"javascript.2"
386+
"axway-api-management.2"
432387
],
433388
"context": "$.user",
434389
"metaName": "Next"
@@ -508,7 +463,9 @@
508463
{
509464
"name": "restrictionField",
510465
"type": "jsonpath",
511-
"value": "$.authzConfig.detailedRestrictionField"
466+
"value": "$.authzConfig.detailedRestrictionField",
467+
"metaName": "Restriction field",
468+
"metaDescription": "The field on which the restriction should be applied. For instance a custom property."
512469
}
513470
],
514471
"outputs": {
@@ -760,6 +717,73 @@
760717
}
761718
},
762719
"metaMethod": "Switch on Authorization"
720+
},
721+
"axway-api-management.2": {
722+
"type": "nodehandler://api-builder-plugin-axway-api-management/axway-api-management",
723+
"name": "Lookup topology",
724+
"method": "lookupTopology",
725+
"parameters": [
726+
{
727+
"name": "requestHeaders",
728+
"type": "jsonpath",
729+
"value": "$.request.headers"
730+
}
731+
],
732+
"outputs": {
733+
"next": {
734+
"routes": [
735+
"traffic-monitor-api-utils.1"
736+
],
737+
"context": "$.gatewayTopology"
738+
},
739+
"error": {
740+
"routes": [
741+
"http.3"
742+
],
743+
"context": "$.error"
744+
}
745+
}
746+
},
747+
"traffic-monitor-api-utils.1": {
748+
"type": "nodehandler://api-builder-plugin-traffic-monitor-api-utils/traffic-monitor-api-utils",
749+
"name": "Create Payload query",
750+
"method": "createCircuitPathQuery",
751+
"parameters": [
752+
{
753+
"name": "gatewayTopology",
754+
"type": "jsonpath",
755+
"value": "$.gatewayTopology"
756+
},
757+
{
758+
"name": "authzConfig",
759+
"type": "jsonpath",
760+
"value": "$.authzConfig"
761+
},
762+
{
763+
"name": "params",
764+
"type": "jsonpath",
765+
"value": "$.params"
766+
},
767+
{
768+
"name": "user",
769+
"type": "jsonpath",
770+
"value": "$.user"
771+
}
772+
],
773+
"outputs": {
774+
"next": {
775+
"routes": [
776+
"authorization.1"
777+
],
778+
"context": "$.elasticsearch.query"
779+
},
780+
"error": {
781+
"routes": [
782+
"http.3"
783+
],
784+
"context": "$.error"
785+
}
786+
}
763787
}
764788
}
765789
}

apibuilder4elastic/test/trafficMonitorAPI/asAdmin/http/test_anm_api_with_http_basic.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('Traffic Monitor API', function () {
1616
//
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(() => {

apibuilder4elastic/test/trafficMonitorAPI/asAdmin/http/test_circuitpath.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('Traffic Monitor API', 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(() => {

apibuilder4elastic/test/trafficMonitorAPI/asAdmin/http/test_getinfo_endpoint.js

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

2021
afterEach(() => {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ describe('Traffic Monitor API', function () {
4848
nock('https://mocked-api-gateway:8090').get('/api/rbac/permissions/currentuser').replyWithFile(200, './test/mockedReplies/apigateway/operatorChris.json');
4949
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');
5050
nock('https://mocked-api-gateway:8075').get(`/api/portal/v1.3/organizations/2bfaa1c2-49ab-4059-832d-CHRIS`).replyWithFile(200, './test/mockedReplies/apimanager/organizationChris.json');
51+
nock('https://mocked-api-gateway:8090').get('/api/topology').reply(200, { result: {} });
52+
5153
return requestAsync({
5254
method: 'GET',
5355
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/c8705e5ecc00adca32be7472/*/circuitpath`,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe('Traffic Monitor API Circuitpath - Ext-HTTP-AuthZ', function () {
4949
it('[restricted-circuitpath-extHttpAuthZ-0001] Should return http 200 and (API Broker/HTTP Petstore) Policy with 2 filters as the transaction belongs to users organization', () => {
5050
nock('https://mocked-api-gateway:8090').get('/api/rbac/currentuser').reply(200, { "result": "chris" });
5151
nock('https://mocked-api-gateway:8090').get('/api/rbac/permissions/currentuser').replyWithFile(200, './test/mockedReplies/apigateway/operatorChris.json');
52+
nock('https://mocked-api-gateway:8090').get('/api/topology').reply(200, { result: {} });
5253
// Disabled API-Manager Mocks, as this AuthZ should not need the API-Manager
5354
//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');
5455
//nock('https://mocked-api-gateway:8075').get(`/api/portal/v1.3/organizations/2bfaa1c2-49ab-4059-832d-CHRIS`).replyWithFile(200, './test/mockedReplies/apimanager/organizationChris.json');

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ describe('Traffic Monitor API', function () {
4747
nock('https://mocked-api-gateway:8090').get('/api/rbac/permissions/currentuser').replyWithFile(200, './test/mockedReplies/apigateway/operatorChris.json');
4848
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');
4949
nock('https://mocked-api-gateway:8075').get(`/api/portal/v1.3/organizations/2bfaa1c2-49ab-4059-832d-CHRIS`).replyWithFile(200, './test/mockedReplies/apimanager/organizationChris.json');
50+
nock('https://mocked-api-gateway:8090').get('/api/topology').reply(200, { result: {} });
51+
5052
return requestAsync({
5153
method: 'GET',
5254
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/c8705e5ecc00adca32be7472/*/circuitpath`,
@@ -74,6 +76,8 @@ describe('Traffic Monitor API', function () {
7476
nock('https://mocked-api-gateway:8090').get('/api/rbac/permissions/currentuser').replyWithFile(200, './test/mockedReplies/apigateway/operatorRene.json');
7577
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');
7678
nock('https://mocked-api-gateway:8075').get(`/api/portal/v1.3/organizations/2bfaa1c2-49ab-4059-832d-MAX`).replyWithFile(200, './test/mockedReplies/apimanager/organizationMax.json');
79+
nock('https://mocked-api-gateway:8090').get('/api/topology').reply(200, { result: {} });
80+
7781
return requestAsync({
7882
method: 'GET',
7983
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/c8705e5ecc00adca32be7472/*/circuitpath`,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ describe('Endpoints', function () {
4646
it('[Disabled-AuthZ-Getinfo-0001] Should return a result, as user authorization is disabled', () => {
4747
nock('https://mocked-api-gateway:8090').get('/api/rbac/currentuser').reply(200, { "result": "chris" });
4848
nock('https://mocked-api-gateway:8090').get('/api/rbac/permissions/currentuser').replyWithFile(200, './test/mockedReplies/apigateway/operatorChris.json');
49+
nock('https://mocked-api-gateway:8090').get('/api/topology').reply(200, { result: {} });
50+
4951
return requestAsync({
5052
method: 'GET',
5153
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/http/0455ff5e82267be8182a553d/*/getinfo?format=json&details=1&rheaders=1&sheaders=1`,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe('Endpoints', function () {
4949
it('[Ext-Http AuthZ-Getinfo-0001] Should return a result', () => {
5050
nock('https://mocked-api-gateway:8090').get('/api/rbac/currentuser').reply(200, { "result": "chris" });
5151
nock('https://mocked-api-gateway:8090').get('/api/rbac/permissions/currentuser').replyWithFile(200, './test/mockedReplies/apigateway/operatorChris.json');
52+
nock('https://mocked-api-gateway:8090').get('/api/topology').reply(200, { result: {} });
5253

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

0 commit comments

Comments
 (0)