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

Commit 723f1f7

Browse files
author
Chris Wiechmann
committed
Tests must be async for await
1 parent 900b0d7 commit 723f1f7

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ describe('Endpoints', function () {
5151
*/
5252
after(() => stopApiBuilder(server));
5353

54-
describe('Search', () => {
55-
it('[Search-0001] Execute a search without a limit including all requests from instance-1', () => {
54+
describe('Search', async () => {
55+
it('[Search-0001] Execute a search without a limit including all requests from instance-1', async () => {
5656
return await requestAsync({
5757
method: 'GET',
5858
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search`,
@@ -74,7 +74,7 @@ describe('Endpoints', function () {
7474
});
7575
});
7676

77-
it('[Endpoint-0002] should return with one result for instance-2', () => {
77+
it('[Endpoint-0002] should return with one result for instance-2', async () => {
7878
const auth = {
7979
user: server.apibuilder.config.apikey || 'test',
8080
password: ''
@@ -96,7 +96,7 @@ describe('Endpoints', function () {
9696
});
9797
});
9898

99-
it('[Endpoint-0003] should restrict based on the URI and HTTP Verb', () => {
99+
it('[Endpoint-0003] should restrict based on the URI and HTTP Verb', async () => {
100100
const auth = {
101101
user: server.apibuilder.config.apikey || 'test',
102102
password: ''
@@ -119,7 +119,7 @@ describe('Endpoints', function () {
119119
checkFields(body.data, true);
120120
});
121121
});
122-
it('[Endpoint-0004] should return 1 entry based on duration filter', () => {
122+
it('[Endpoint-0004] should return 1 entry based on duration filter', async () => {
123123
const auth = {
124124
user: server.apibuilder.config.apikey || 'test',
125125
password: ''
@@ -140,7 +140,7 @@ describe('Endpoints', function () {
140140
checkFields(body.data, true);
141141
});
142142
});
143-
it('[Endpoint-0005] should return 1 entry based on operation filter', () => {
143+
it('[Endpoint-0005] should return 1 entry based on operation filter', async () => {
144144
const auth = {
145145
user: server.apibuilder.config.apikey || 'test',
146146
password: ''
@@ -162,7 +162,7 @@ describe('Endpoints', function () {
162162
checkFields(body.data, true);
163163
});
164164
});
165-
it('[Endpoint-0006] should return 0 entries as all test data is in the past', () => {
165+
it('[Endpoint-0006] should return 0 entries as all test data is in the past', async () => {
166166
const auth = {
167167
user: server.apibuilder.config.apikey || 'test',
168168
password: ''
@@ -182,7 +182,7 @@ describe('Endpoints', function () {
182182
expect(body.data).to.have.lengthOf(0);
183183
});
184184
});
185-
it('[Endpoint-0007] should return 2 when using a custom time-range', () => {
185+
it('[Endpoint-0007] should return 2 when using a custom time-range', async () => {
186186
//
187187
/**
188188
* The dates given here must be aligned with dates in search_test_documents.js. Currently configured like so:
@@ -212,7 +212,7 @@ describe('Endpoints', function () {
212212
expect(body.data[1].correlationId).to.equal("19250f5f4321b5ba2a4de364");
213213
});
214214
});
215-
it('[Endpoint-0008] should return 3 when using a wider custom time-range', () => {
215+
it('[Endpoint-0008] should return 3 when using a wider custom time-range', async () => {
216216
//
217217
/**
218218
* The dates given here must be aligned with dates in search_test_documents.js. Currently configured like so:
@@ -245,7 +245,7 @@ describe('Endpoints', function () {
245245
expect(body.data[3].correlationId).to.equal("19250f5f4321b5ba2a4de364");
246246
});
247247
});
248-
it('[Endpoint-0009] should return two entries with localport 8080', () => {
248+
it('[Endpoint-0009] should return two entries with localport 8080', async () => {
249249
return await requestAsync({
250250
method: 'GET',
251251
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=localPort&value=8080`,
@@ -263,7 +263,7 @@ describe('Endpoints', function () {
263263
});
264264
});
265265

266-
it('[Endpoint-0010A] should return one entry with localport 8080 and given subject-id', () => {
266+
it('[Endpoint-0010A] should return one entry with localport 8080 and given subject-id', async () => {
267267
return await requestAsync({
268268
method: 'GET',
269269
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=localPort&value=8080&field=subject&value=Chris-Test`,
@@ -281,7 +281,7 @@ describe('Endpoints', function () {
281281
expect(body.data[0].subject).to.equals('Chris-Test');
282282
});
283283
});
284-
it('[Endpoint-0010B] should return one entry with localport 8080 and a part of the original subject ID', () => {
284+
it('[Endpoint-0010B] should return one entry with localport 8080 and a part of the original subject ID', async () => {
285285
return await requestAsync({
286286
method: 'GET',
287287
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=localPort&value=8080&field=subject&value=Chris`,
@@ -299,7 +299,7 @@ describe('Endpoints', function () {
299299
expect(body.data[0].subject).to.equals('Chris-Test');
300300
});
301301
});
302-
it('[Endpoint-0011] should return one entry with localport 8080 and given subject-id', () => {
302+
it('[Endpoint-0011] should return one entry with localport 8080 and given subject-id', async () => {
303303
return await requestAsync({
304304
method: 'GET',
305305
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=status&value=404`,
@@ -317,7 +317,7 @@ describe('Endpoints', function () {
317317
expect(body.data[0].uri).to.equals('/favicon.ico');
318318
});
319319
});
320-
it('[Endpoint-0012] should return one entry with localadr 1.1.1.1', () => {
320+
it('[Endpoint-0012] should return one entry with localadr 1.1.1.1', async () => {
321321
return await requestAsync({
322322
method: 'GET',
323323
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=localAddr&value=1.1.1.1`,
@@ -335,7 +335,7 @@ describe('Endpoints', function () {
335335
expect(body.data[0].uri).to.equals('/healthcheck');
336336
});
337337
});
338-
it('[Endpoint-0013] should return one entry with remoteName (remoteHost) TestHost', () => {
338+
it('[Endpoint-0013] should return one entry with remoteName (remoteHost) TestHost', async () => {
339339
return await requestAsync({
340340
method: 'GET',
341341
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=remoteName&value=TestHost`,
@@ -353,7 +353,7 @@ describe('Endpoints', function () {
353353
expect(body.data[0].uri).to.equals('/healthcheck');
354354
});
355355
});
356-
it('[Endpoint-0014] should return one entry with remotePort 59641', () => {
356+
it('[Endpoint-0014] should return one entry with remotePort 59641', async () => {
357357
return await requestAsync({
358358
method: 'GET',
359359
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=remotePort&value=59641`,
@@ -371,7 +371,7 @@ describe('Endpoints', function () {
371371
expect(body.data[0].uri).to.equals('/favicon.ico');
372372
});
373373
});
374-
it('[Endpoint-0015] should return one entry with service name Petstore HTTP', () => {
374+
it('[Endpoint-0015] should return one entry with service name Petstore HTTP', async () => {
375375
return await requestAsync({
376376
method: 'GET',
377377
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=serviceName&value=Petstore%20HTTP`,
@@ -390,7 +390,7 @@ describe('Endpoints', function () {
390390
expect(body.data[1].uri).to.equals('/petstore/v2/pet/findByStatus');
391391
});
392392
});
393-
it('[Endpoint-0016] should return one entry WAF-Status 1', () => {
393+
it('[Endpoint-0016] should return one entry WAF-Status 1', async () => {
394394
return await requestAsync({
395395
method: 'GET',
396396
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=wafStatus&value=1`,
@@ -408,7 +408,7 @@ describe('Endpoints', function () {
408408
expect(body.data[0].uri).to.equals('/favicon.ico');
409409
});
410410
});
411-
it('[Endpoint-0017] should return one entry with the given correlation id', () => {
411+
it('[Endpoint-0017] should return one entry with the given correlation id', async () => {
412412
return await requestAsync({
413413
method: 'GET',
414414
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=correlationId&value=682c0f5fbe23dc8e1d80efe2`,
@@ -426,7 +426,7 @@ describe('Endpoints', function () {
426426
expect(body.data[0].serviceName).to.equals('Petstore');
427427
});
428428
});
429-
it('[Endpoint-0018] should return one entry with final status Error', () => {
429+
it('[Endpoint-0018] should return one entry with final status Error', async () => {
430430
return await requestAsync({
431431
method: 'GET',
432432
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=finalStatus&value=Error`,
@@ -443,7 +443,7 @@ describe('Endpoints', function () {
443443
expect(body.data[0].uri).to.equals('/healthcheck');
444444
});
445445
});
446-
it('[Endpoint-0019] should return results with a wildcard path.', () => {
446+
it('[Endpoint-0019] should return results with a wildcard path.', async () => {
447447
return await requestAsync({
448448
method: 'GET',
449449
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=uri&value=%2Fv2%2Fpet`,
@@ -461,7 +461,7 @@ describe('Endpoints', function () {
461461
expect(body.data[1].uri).to.equals('/petstore/v2/pet/findByStatus');
462462
});
463463
});
464-
it('[Endpoint-0020] Should return 1 entry in the last 10 minutes (ago=10m)', () => {
464+
it('[Endpoint-0020] Should return 1 entry in the last 10 minutes (ago=10m)', async () => {
465465
return await requestAsync({
466466
method: 'GET',
467467
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?ago=10m`,
@@ -478,7 +478,7 @@ describe('Endpoints', function () {
478478
expect(body.data[0].uri).to.equals('/petstore/v2/pet/findByTag');
479479
});
480480
});
481-
it('[Endpoint-0021] Should return 2 entries in the last 30 minutes (ago=30m)', () => {
481+
it('[Endpoint-0021] Should return 2 entries in the last 30 minutes (ago=30m)', async () => {
482482
return await requestAsync({
483483
method: 'GET',
484484
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?ago=30m`,
@@ -495,7 +495,7 @@ describe('Endpoints', function () {
495495
expect(body.data[0].uri).to.equals('/petstore/v2/pet/findByTag');
496496
});
497497
});
498-
it('[Endpoint-0022] Should return 4 entries in the last 2 hours (ago=120h)', () => {
498+
it('[Endpoint-0022] Should return 4 entries in the last 2 hours (ago=120h)', async () => {
499499
return await requestAsync({
500500
method: 'GET',
501501
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?ago=2h`,
@@ -512,7 +512,7 @@ describe('Endpoints', function () {
512512
expect(body.data[0].uri).to.equals('/petstore/v2/pet/findByTag');
513513
});
514514
});
515-
it('[Endpoint-0023] Should include the V-Host value', () => {
515+
it('[Endpoint-0023] Should include the V-Host value', async () => {
516516
return await requestAsync({
517517
method: 'GET',
518518
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=correlationId&value=7a240f5f0e21555d2d343482`,
@@ -527,7 +527,7 @@ describe('Endpoints', function () {
527527
expect(body.data[0].vhost).to.equal('api.customer.com:443', 'V-Host is not part of the result');
528528
});
529529
});
530-
it('[Endpoint-0024] Should not return anything when using the wrong request protocol.', () => {
530+
it('[Endpoint-0024] Should not return anything when using the wrong request protocol.', async () => {
531531
return await requestAsync({
532532
method: 'GET',
533533
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?protocol=filetransfer`,
@@ -543,7 +543,7 @@ describe('Endpoints', function () {
543543
expect(body.data).to.have.lengthOf(0);
544544
});
545545
});
546-
it('[Endpoint-0025] Should return the OPTIONS request including the URI', () => {
546+
it('[Endpoint-0025] Should return the OPTIONS request including the URI', async () => {
547547
return await requestAsync({
548548
method: 'GET',
549549
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-2/ops/search?protocol=http&field=method&value=OPTIONS`,
@@ -562,7 +562,7 @@ describe('Endpoints', function () {
562562
});
563563

564564
// See issue #52
565-
it('[Endpoint-0026] With query on v2/pet/findByTag should return only ONE API.', () => {
565+
it('[Endpoint-0026] With query on v2/pet/findByTag should return only ONE API.', async () => {
566566
return await requestAsync({
567567
method: 'GET',
568568
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=uri&value=%2Fpetstore%2Fv2%2Fpet%2FfindByTag&field=method&value=GET`,
@@ -581,7 +581,7 @@ describe('Endpoints', function () {
581581
});
582582
});
583583

584-
it('[Endpoint-0027] Should ignore the region if null', () => {
584+
it('[Endpoint-0027] Should ignore the region if null', async () => {
585585
return await requestAsync({
586586
method: 'GET',
587587
uri: `http://localhost:${server.apibuilder.port}/api/elk/v1/api/router/service/instance-1/ops/search?field=uri&value=%2Fpetstore%2Fv2%2Fpet%2FfindByTag&field=method&value=GET`,

0 commit comments

Comments
 (0)