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

Commit 52c86e6

Browse files
author
Chris Wiechmann
committed
Now region is used to load the payload / New Integration-Test
Fixes #121
1 parent b7da55f commit 52c86e6

File tree

7 files changed

+57
-20
lines changed

7 files changed

+57
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
- Failed to validated API-Manager connection, when using Load-Balanced API-Manager instances [#117](https://github.com/Axway-API-Management-Plus/apigateway-openlogging-elk/issues/117)
1010
- For JMS-Traffic the fields: leg0.protocolInfo.recvHeader and leg0.protocolInfo.sentHeader are copied into the summary index, as they are used for JMS-Property filtering
1111
- Error when setting up Traffic-Summary index without having a Default-API-Manager configured [#119](https://github.com/Axway-API-Management-Plus/apigateway-openlogging-elk/issues/119)
12+
- Region is not used to load the payload [#121](https://github.com/Axway-API-Management-Plus/apigateway-openlogging-elk/issues/121)
1213

1314
### Changed
1415
- Added new optional parameter: UNRESTRICTED_PERMISSIONS to control which users see all traffic [#120](https://github.com/Axway-API-Management-Plus/apigateway-openlogging-elk/issues/120)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ async function lookupCurrentUser(params, options) {
5555
if(!requestHeaders.cookie && !requestHeaders.authorization) {
5656
throw new Error('You must provide either the VIDUSR cookie + csrf-token or an HTTP-Basic Authorization header.');
5757
}
58-
debugger;
5958
if (!unrestrictedPermissions || unrestrictedPermissions=="") {
6059
unrestrictedPermissions = "adminusers_modify";
6160
}
@@ -330,7 +329,6 @@ async function getCustomPropertiesConfig(params, options) {
330329
const { logger } = options;
331330
cache = options.pluginContext.cache;
332331
let apiManagerConfig;
333-
debugger;
334332
var mergedCustomProperties = {};
335333
if(!pluginConfig.apimanager.perGroupAndRegion) {
336334
// Using a single API-Manager only.

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ function getManagerConfig(apiManagerConfig, groupId, region) {
153153
if(region != undefined && region != "N/A" && region != "n/a") {
154154
key = `${groupId}###${region}`.toLowerCase();
155155
}
156-
debugger;
157156
// Check if the requested combination based on groupId and region exists and return it directly
158157
if (apiManagerConfig.configs && apiManagerConfig.configs[key]) {
159158
return apiManagerConfig.configs[key];
@@ -167,7 +166,6 @@ function getManagerConfig(apiManagerConfig, groupId, region) {
167166

168167
async function checkAPIManagers(apiManagerConfig, options) {
169168
var finalResult = { isValid: true };
170-
debugger;
171169
for (const [key, config] of Object.entries(apiManagerConfig.configs)) {
172170
if(typeof config != 'object') continue;
173171
finalResult[key] = config;

apibuilder4elastic/flows/trafficMonitorApi-payload.json

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@
227227
"value": "$.params.legID",
228228
"metaName": "Leg-Number",
229229
"metaDescription": "The Leg-Number"
230+
},
231+
{
232+
"name": "region",
233+
"type": "jsonpath",
234+
"value": "$.params.region"
230235
}
231236
],
232237
"outputs": {
@@ -726,23 +731,28 @@
726731
{
727732
"name": "requestHeaders",
728733
"type": "jsonpath",
729-
"value": "$.request.headers"
734+
"value": "$.request.headers",
735+
"metaName": "Request Headers",
736+
"metaDescription": "The request headers are used to lookup the topology using the currently logged in user."
730737
}
731738
],
732739
"outputs": {
733740
"next": {
734741
"routes": [
735742
"traffic-monitor-api-utils.1"
736743
],
737-
"context": "$.gatewayTopology"
744+
"context": "$.gatewayTopology",
745+
"metaName": "Next"
738746
},
739747
"error": {
740748
"routes": [
741749
"http.3"
742750
],
743-
"context": "$.error"
751+
"context": "$.error",
752+
"metaName": "Error"
744753
}
745-
}
754+
},
755+
"metaMethod": "Lookup topology"
746756
},
747757
"traffic-monitor-api-utils.1": {
748758
"type": "nodehandler://api-builder-plugin-traffic-monitor-api-utils/traffic-monitor-api-utils",
@@ -752,38 +762,49 @@
752762
{
753763
"name": "gatewayTopology",
754764
"type": "jsonpath",
755-
"value": "$.gatewayTopology"
765+
"value": "$.gatewayTopology",
766+
"metaName": "API-Gateway Topology",
767+
"metaDescription": "The API-Gateway topology as read by flow-node: axway-api-management->lookupTopology"
756768
},
757769
{
758770
"name": "authzConfig",
759771
"type": "jsonpath",
760-
"value": "$.authzConfig"
772+
"value": "$.authzConfig",
773+
"metaName": "Authorization configuration",
774+
"metaDescription": "The authorization configuration object returned from Get AuthZ Config"
761775
},
762776
{
763777
"name": "params",
764778
"type": "jsonpath",
765-
"value": "$.params"
779+
"value": "$.params",
780+
"metaName": "Params",
781+
"metaDescription": "The object must contain the given request parameters."
766782
},
767783
{
768784
"name": "user",
769785
"type": "jsonpath",
770-
"value": "$.user"
786+
"value": "$.user",
787+
"metaName": "User",
788+
"metaDescription": "The user object using the API-Gateway Traffic-Monitor"
771789
}
772790
],
773791
"outputs": {
774792
"next": {
775793
"routes": [
776794
"authorization.1"
777795
],
778-
"context": "$.elasticsearch.query"
796+
"context": "$.elasticsearch.query",
797+
"metaName": "Next"
779798
},
780799
"error": {
781800
"routes": [
782801
"http.3"
783802
],
784-
"context": "$.error"
803+
"context": "$.error",
804+
"metaName": "Error"
785805
}
786-
}
806+
},
807+
"metaMethod": "Create circuit path query"
787808
}
788809
}
789810
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
US-DC1-SENT-PAYLOAD-LEG-0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
US-DC1-RECEIVED-PAYLOAD-LEG-1

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('Payload', function () {
5757

5858
describe('Payload tests', () => {
5959
it('[Payload-0001] Should return sent payload for leg 0', () => {
60-
const testPayload = fs.readFileSync(`${payloadFolder}/2020-07-03/08.55/0455ff5e82267be8182a553d-0-sent`);
60+
const testPayload = fs.readFileSync(`${payloadFolder}/2020-07-03/08.55/0455ff5e82267be8182a553d-0-sent`, { encoding: "UTF-8" });
6161
return requestAsync({
6262
method: 'GET', //
6363
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/0455ff5e82267be8182a553d/0/sent`,
@@ -75,7 +75,7 @@ describe('Payload', function () {
7575
});
7676

7777
it('[Payload-0002] Should return the received payload from leg 1', () => {
78-
const testPayload = fs.readFileSync(`${payloadFolder}/2020-07-03/08.55/0455ff5e82267be8182a553d-1-received`);
78+
const testPayload = fs.readFileSync(`${payloadFolder}/2020-07-03/08.55/0455ff5e82267be8182a553d-1-received`, { encoding: "UTF-8" });
7979
return requestAsync({
8080
method: 'GET',
8181
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/0455ff5e82267be8182a553d/1/received`,
@@ -112,7 +112,7 @@ describe('Payload', function () {
112112
});
113113

114114
it('[Payload-0004] Payload should be SAVED and is NOT limited to a certain size (request is missing a CSRF-Token)', () => {
115-
const testPayload = fs.readFileSync(`${payloadFolder}/2021-01-09/10.00/LargePayloadTest-1-received`);
115+
const testPayload = fs.readFileSync(`${payloadFolder}/2021-01-09/10.00/LargePayloadTest-1-received`, { encoding: "UTF-8" });
116116
return requestAsync({
117117
method: 'GET',
118118
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/LargePayloadTest/1/received`,
@@ -129,6 +129,23 @@ describe('Payload', function () {
129129
expect(body).to.include(testPayload);
130130
});
131131
});
132+
133+
it('[Payload-0005] Should return REGIONAL sent payload for leg 0', () => {
134+
const testPayload = fs.readFileSync(`${payloadFolder}/US-DC1/2020-07-03/08.55/0455ff5e82267be8182a553d-0-sent`, { encoding: "UTF-8" });
135+
return requestAsync({
136+
method: 'GET', //
137+
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/0455ff5e82267be8182a553d/0/sent?region=US-DC1`,
138+
headers: {
139+
'cookie': 'VIDUSR=Getinfo-0001-DAVID-1597762865-iUI5a8+v+zLkNA%3d%3d; APIMANAGERSTATIC=92122e5c-6bb3-4fd1-ad2f-08b65554d116',
140+
'csrf-token': '04F9F07E59F588CDE469FC367A12ED3A4B845FDA9A9AE2D9A77686823067CDDC'
141+
},
142+
json: true
143+
}).then(({ response, body }) => {
144+
expect(response.statusCode).to.equal(200);
145+
expect(response.headers["content-type"]).to.equal("application/vordel-xact-data; charset=utf-8");
146+
expect(body).to.be.an('String');
147+
expect(body).to.include(testPayload);
148+
});
149+
});
132150
});
133-
});
134-
151+
});

0 commit comments

Comments
 (0)