This repository has been archived by the owner on Dec 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for EMT-Search to include serviceID not longer active
Fixes #114
- Loading branch information
Chris Wiechmann
committed
Jun 21, 2021
1 parent
3138a4f
commit 20b4c96
Showing
15 changed files
with
1,024 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...tic/custom_flow_nodes/api-builder-plugin-axway-api-management/test/test-topologyLookup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
const { expect } = require('chai'); | ||
const { MockRuntime } = require('@axway/api-builder-test-utils'); | ||
const getPlugin = require('../src'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const nock = require('nock'); | ||
const envLoader = require('dotenv'); | ||
const decache = require('decache'); | ||
|
||
describe('Tests Topology-Lookup', () => { | ||
let plugin; | ||
let flowNode; | ||
|
||
// Loads environment variables from .env if the file exists | ||
const envFilePath = path.join(__dirname, '.env'); | ||
if (fs.existsSync(envFilePath)) { | ||
delete process.env.API_MANAGER; // Otherwise it is not overwritten | ||
envLoader.config({ path: envFilePath }); | ||
} | ||
// Delete the cached module | ||
decache('../config/axway-api-utils.default.js'); | ||
var pluginConfig = require('../config/axway-api-utils.default.js').pluginConfig['api-builder-plugin-axway-api-management']; | ||
|
||
beforeEach(async () => { | ||
plugin = await MockRuntime.loadPlugin(getPlugin,pluginConfig); | ||
plugin.setOptions({ validateOutputs: true }); | ||
flowNode = plugin.getFlowNode('axway-api-management'); | ||
}); | ||
|
||
describe('#lookupTopology', () => { | ||
it('should error when requestHeaders are not set', async () => { | ||
const { value, output } = await flowNode.lookupTopology({ | ||
requestHeaders: null | ||
}); | ||
|
||
expect(value).to.be.instanceOf(Error) | ||
.and.to.have.property('message', 'You need to provide Request-Headers with Cookies or an Authorization header.'); | ||
expect(output).to.equal('error'); | ||
}); | ||
|
||
it('should error when requestHeaders are set, but contain no cookie header', async () => { | ||
const { value, output } = await flowNode.lookupTopology({ | ||
requestHeaders: {"host":"api-gateway:8090","max-forwards":"20"} | ||
}); | ||
|
||
expect(value).to.be.instanceOf(Error) | ||
.and.to.have.property('message', 'You must provide either the VIDUSR cookie + csrf-token or an HTTP-Basic Authorization header.'); | ||
expect(output).to.equal('error'); | ||
}); | ||
|
||
it('should error when requestHeaders are set, but the VIDUSR cookie is missing', async () => { | ||
const { value, output } = await flowNode.lookupTopology({ | ||
requestHeaders: {"host":"api-gateway:8090","max-forwards":"20", "cookie":"XXX-VIDUSR=1597381095-XTawGDtJhBA7Zw%3d%3d;"} | ||
}); | ||
|
||
expect(value).to.be.instanceOf(Error) | ||
.and.to.have.property('message', 'The requestHeaders do not contain the required cookie VIDUSR'); | ||
expect(output).to.equal('error'); | ||
}); | ||
|
||
it('should error when requestHeaders are set, but the CSRF-Token is missing', async () => { | ||
const { value, output } = await flowNode.lookupTopology({ | ||
requestHeaders: {"host":"api-gateway:8090","max-forwards":"20", "cookie":"VIDUSR=1597381095-XTawGDtJhBA7Zw%3d%3d;"} | ||
}); | ||
|
||
expect(value).to.be.instanceOf(Error) | ||
.and.to.have.property('message', 'The requestHeaders do not contain the required header csrf-token'); | ||
expect(output).to.equal('error'); | ||
}); | ||
|
||
it('should result into the API-Gateway topology', async () => { | ||
nock('https://mocked-api-gateway:8190').get('/api/topology').replyWithFile(200, './test/testReplies/gateway/gatewayEMTTopology.json'); | ||
|
||
const { value, output } = await flowNode.lookupTopology({ | ||
requestHeaders: {"host":"api-gateway:8090","max-forwards":"20", "cookie":"VIDUSR=1597381095-XTawGDtJhBA7Zw==;", "csrf-token": "CF2796B3BD18C1B0B5AB1C8E95B75662E92FBC04BD799DEB97838FC5B9C39348"} | ||
}); | ||
|
||
expect(value.emtEnabled).to.equal(true); | ||
expect(value.services).to.lengthOf(3); // We expect only 3 services, as the ANM is removed already | ||
expect(output).to.equal('next'); | ||
}); | ||
}); | ||
}); |
154 changes: 154 additions & 0 deletions
154
.../api-builder-plugin-axway-api-management/test/testReplies/gateway/gatewayEMTTopology.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
{ | ||
"result": { | ||
"id": "DefaultDomain", | ||
"version": 44, | ||
"timestamp": 1624264680386, | ||
"productVersion": "7.7.0", | ||
"hosts": [ | ||
{ | ||
"id": "host-24", | ||
"name": "192.168.81.10" | ||
}, | ||
{ | ||
"id": "host-6", | ||
"name": "192.168.86.81" | ||
}, | ||
{ | ||
"id": "host-23", | ||
"name": "192.168.94.252" | ||
}, | ||
{ | ||
"id": "host-1", | ||
"name": "anm-d5574b69-qwnmj" | ||
} | ||
], | ||
"groups": [ | ||
{ | ||
"id": "DefaultGroup", | ||
"name": "DefaultGroup", | ||
"tags": {}, | ||
"services": [ | ||
{ | ||
"id": "apimgr-6c9876cb48-g4sdq", | ||
"name": "apimgr-6c9876cb48-g4sdq", | ||
"type": "gateway", | ||
"scheme": "https", | ||
"hostID": "host-6", | ||
"managementPort": 8085, | ||
"tags": { | ||
"image": "docker.pkg.github.com/cwiechmann/axway-api-management-automated/manager:77-20210330-v1-833aab9", | ||
"productVersion": "7.7.20210330" | ||
}, | ||
"enabled": true | ||
}, | ||
{ | ||
"id": "traffic-7cb4f6989f-bjw8n", | ||
"name": "traffic-7cb4f6989f-bjw8n", | ||
"type": "gateway", | ||
"scheme": "https", | ||
"hostID": "host-24", | ||
"managementPort": 8085, | ||
"tags": { | ||
"image": "docker.pkg.github.com/cwiechmann/axway-api-management-automated/manager:77-20210330-v1-696cc6d", | ||
"productVersion": "7.7.20210330" | ||
}, | ||
"enabled": true | ||
}, | ||
{ | ||
"id": "traffic-7cb4f6989f-jbmf7", | ||
"name": "traffic-7cb4f6989f-jbmf7", | ||
"type": "gateway", | ||
"scheme": "https", | ||
"hostID": "host-23", | ||
"managementPort": 8085, | ||
"tags": { | ||
"image": "docker.pkg.github.com/cwiechmann/axway-api-management-automated/manager:77-20210330-v1-696cc6d", | ||
"productVersion": "7.7.20210330" | ||
}, | ||
"enabled": true | ||
} | ||
], | ||
"lock": null | ||
}, | ||
{ | ||
"id": "emt_anm_group", | ||
"name": "Node Manager Group", | ||
"tags": {}, | ||
"services": [ | ||
{ | ||
"id": "nodemanager-1", | ||
"name": "Admin Node Manager", | ||
"type": "nodemanager", | ||
"scheme": "https", | ||
"hostID": "host-1", | ||
"managementPort": 8090, | ||
"tags": { | ||
"internal_admin_nm": "true" | ||
}, | ||
"enabled": true | ||
} | ||
], | ||
"lock": null | ||
} | ||
], | ||
"uniqueIdCounters": { | ||
"Host": 25, | ||
"NodeManager": 2, | ||
"Group": 2 | ||
}, | ||
"emtEnabled": true, | ||
"services": [ | ||
{ | ||
"id": "nodemanager-1", | ||
"name": "Admin Node Manager", | ||
"type": "nodemanager", | ||
"scheme": "https", | ||
"hostID": "host-1", | ||
"managementPort": 8090, | ||
"tags": { | ||
"internal_admin_nm": "true" | ||
}, | ||
"enabled": true | ||
}, | ||
{ | ||
"id": "apimgr-6c9876cb48-g4sdq", | ||
"name": "apimgr-6c9876cb48-g4sdq", | ||
"type": "gateway", | ||
"scheme": "https", | ||
"hostID": "host-6", | ||
"managementPort": 8085, | ||
"tags": { | ||
"image": "docker.pkg.github.com/cwiechmann/axway-api-management-automated/manager:77-20210330-v1-833aab9", | ||
"productVersion": "7.7.20210330" | ||
}, | ||
"enabled": true | ||
}, | ||
{ | ||
"id": "traffic-7cb4f6989f-bjw8n", | ||
"name": "traffic-7cb4f6989f-bjw8n", | ||
"type": "gateway", | ||
"scheme": "https", | ||
"hostID": "host-24", | ||
"managementPort": 8085, | ||
"tags": { | ||
"image": "docker.pkg.github.com/cwiechmann/axway-api-management-automated/manager:77-20210330-v1-696cc6d", | ||
"productVersion": "7.7.20210330" | ||
}, | ||
"enabled": true | ||
}, | ||
{ | ||
"id": "traffic-7cb4f6989f-jbmf7", | ||
"name": "traffic-7cb4f6989f-jbmf7", | ||
"type": "gateway", | ||
"scheme": "https", | ||
"hostID": "host-23", | ||
"managementPort": 8085, | ||
"tags": { | ||
"image": "docker.pkg.github.com/cwiechmann/axway-api-management-automated/manager:77-20210330-v1-696cc6d", | ||
"productVersion": "7.7.20210330" | ||
}, | ||
"enabled": true | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.