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

Commit 6916e17

Browse files
committed
Added tests for circuitpath endpoint
1 parent ea6eecf commit 6916e17

File tree

1 file changed

+68
-5
lines changed

1 file changed

+68
-5
lines changed

elk-traffic-monitor-api/test/test_circuitpath.js

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ describe('Traffic Monitor API', function () {
3838

3939
describe('circuitpath endpoint tests', () => {
4040

41-
it('[circuitpath-0001] Execute a GET on circuitpath resource to retrieve the filterpath 1 policy with 2 Filter (Healthcheck API) for a given transactionID from instance-1', () => {
41+
it('[circuitpath-0001] Should return http 200 and (Health Check) Policy with 2 filters', () => {
4242
return requestAsync({
4343
method: 'GET',
44-
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/c8705e5ecc00adca32be7472/*/circuitpath`,
44+
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/4e645e5e4600bb590c881179/*/circuitpath`,
4545
auth: auth,
4646
json: true
4747
}).then(({ response, body }) => {
@@ -56,11 +56,10 @@ describe('Traffic Monitor API', function () {
5656
expect(body[0].filters[0].status).to.equal('Pass');
5757
});
5858
});
59-
60-
it('[circuitpath-0002] Execute a GET on circuitpath resource to retrieve the filterpath with 5 policies (Todo API) for a given transactionID from instance-1', () => {
59+
it('[circuitpath-0002] Should return HTTP 200 and a API Broker Policy with 2 Filters and sub-Policys and -filters', () => {
6160
return requestAsync({
6261
method: 'GET',
63-
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/5a22b35e4254b9c6d22d7dc4/*/circuitpath`,
62+
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/c8705e5ecc00adca32be7472/*/circuitpath`,
6463
auth: auth,
6564
json: true
6665
}).then(({ response, body }) => {
@@ -73,6 +72,70 @@ describe('Traffic Monitor API', function () {
7372
expect(body[0].filters).to.be.an('Array');
7473
expect(body[0].filters).to.have.lengthOf(2);
7574
expect(body[0].filters[0].status).to.equal('Pass');
75+
expect(body[0].filters[0].subPaths).to.not.exist;
76+
expect(body[0].filters[1].subPaths).to.be.an('Array');
77+
expect(body[0].filters[1].subPaths).to.have.lengthOf(1);
78+
expect(body[0].filters[1].subPaths[0].policy).to.equal('Default API Proxy Routing');
79+
expect(body[0].filters[1].subPaths[0].filters).to.have.lengthOf(1);
80+
81+
});
82+
});
83+
it('[circuitpath-0003] Should return http 200 and an empty array because no policies have been executed', () => {
84+
return requestAsync({
85+
method: 'GET',
86+
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/edb1705e7d0168a34d74bfba/*/circuitpath`,
87+
auth: auth,
88+
json: true
89+
}).then(({ response, body }) => {
90+
expect(response.statusCode).to.equal(200);
91+
expect(body).to.be.an('Array');
92+
expect(body).to.have.lengthOf(0);
93+
});
94+
});
95+
it('[circuitpath-0004] Should return http 200 and empty array even the correlationID does not exist in database', () => {
96+
return requestAsync({
97+
method: 'GET',
98+
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/111111111111111111111111/*/circuitpath`,
99+
auth: auth,
100+
json: true
101+
}).then(({ response, body }) => {
102+
expect(response.statusCode).to.equal(200);
103+
expect(body).to.be.an('Array');
104+
expect(body).to.have.lengthOf(0);
105+
});
106+
});
107+
it('[circuitpath-0005] Should return http 200 and have a API Manager Protection Policy with 7 filters with 2 fails and subpath with several filters', () => {
108+
return requestAsync({
109+
method: 'GET',
110+
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/stream/1ab3705e920284217e6aae73/*/circuitpath`,
111+
auth: auth,
112+
json: true
113+
}).then(({ response, body }) => {
114+
expect(response.statusCode).to.equal(200);
115+
expect(body).to.be.an('Array');
116+
expect(body).to.have.lengthOf(1);
117+
expect(body).to.have.lengthOf(1);
118+
expect(body[0].filters).to.be.an('Array');
119+
expect(body[0].policy).to.equal('API Manager Protection Policy');
120+
expect(body[0].filters).to.have.lengthOf(7);
121+
expect(body[0].filters[0].status).to.equal('Pass');
122+
expect(body[0].filters[1].status).to.equal('Pass');
123+
expect(body[0].filters[2].status).to.equal('Fail');
124+
expect(body[0].filters[3].status).to.equal('Pass');
125+
expect(body[0].filters[4].status).to.equal('Fail');
126+
expect(body[0].filters[5].status).to.equal('Pass');
127+
expect(body[0].filters[6].status).to.equal('Pass');
128+
expect(body[0].filters[1].subPaths).to.be.an('Array');
129+
expect(body[0].filters[1].subPaths).to.have.lengthOf(1);
130+
expect(body[0].filters[1].subPaths[0].policy).to.equal('Secure Headers');
131+
expect(body[0].filters[1].subPaths[0].filters).to.have.lengthOf(7);
132+
expect(body[0].filters[1].subPaths[0].filters[0].status).to.equal('Pass');
133+
expect(body[0].filters[1].subPaths[0].filters[1].status).to.equal('Pass');
134+
expect(body[0].filters[1].subPaths[0].filters[2].status).to.equal('Pass');
135+
expect(body[0].filters[1].subPaths[0].filters[3].status).to.equal('Pass');
136+
expect(body[0].filters[1].subPaths[0].filters[4].status).to.equal('Pass');
137+
expect(body[0].filters[1].subPaths[0].filters[5].status).to.equal('Pass');
138+
expect(body[0].filters[1].subPaths[0].filters[6].status).to.equal('Pass');
76139
});
77140
});
78141

0 commit comments

Comments
 (0)