Skip to content

Commit 0041c3f

Browse files
committed
Fix unit test
1 parent 957f516 commit 0041c3f

File tree

1 file changed

+70
-91
lines changed

1 file changed

+70
-91
lines changed

library/sources/HTTPServer.test.ts

Lines changed: 70 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,101 +1010,80 @@ t.test("it reports attack waves", async (t) => {
10101010

10111011
await new Promise<void>((resolve) => {
10121012
server.listen(3229, async () => {
1013-
t.equal(
1014-
(
1015-
await fetch({
1016-
url: new URL("http://localhost:3229/.env"),
1017-
method: "GET",
1018-
headers: {},
1019-
timeoutInMS: 500,
1020-
})
1021-
).statusCode,
1022-
404
1023-
);
1024-
1025-
t.equal(
1026-
(
1027-
await fetch({
1028-
url: new URL("http://localhost:3229/wp-config.php"),
1029-
method: "GET",
1030-
headers: {},
1031-
timeoutInMS: 500,
1032-
})
1033-
).statusCode,
1034-
404
1035-
);
1036-
1037-
t.equal(
1038-
(
1039-
await fetch({
1040-
url: new URL("http://localhost:3229/../test"),
1041-
method: "GET",
1042-
headers: {},
1043-
timeoutInMS: 500,
1044-
})
1045-
).statusCode,
1046-
404
1047-
);
1048-
1049-
t.equal(
1050-
(
1051-
await fetch({
1052-
url: new URL("http://localhost:3229/etc/passwd"),
1053-
method: "GET",
1054-
headers: {},
1055-
timeoutInMS: 500,
1056-
})
1057-
).statusCode,
1058-
404
1059-
);
1013+
for (let i = 0; i < 3; i++) {
1014+
t.equal(
1015+
(
1016+
await fetch({
1017+
url: new URL("http://localhost:3229/.env"),
1018+
method: "GET",
1019+
headers: {},
1020+
timeoutInMS: 500,
1021+
})
1022+
).statusCode,
1023+
404
1024+
);
10601025

1061-
t.equal(
1062-
(
1063-
await fetch({
1064-
url: new URL("http://localhost:3229/etc/passwd"),
1065-
method: "GET",
1066-
headers: {},
1067-
timeoutInMS: 500,
1068-
})
1069-
).statusCode,
1070-
404
1071-
);
1026+
t.equal(
1027+
(
1028+
await fetch({
1029+
url: new URL("http://localhost:3229/wp-config.php"),
1030+
method: "GET",
1031+
headers: {},
1032+
timeoutInMS: 500,
1033+
})
1034+
).statusCode,
1035+
404
1036+
);
10721037

1073-
t.equal(
1074-
(
1075-
await fetch({
1076-
url: new URL("http://localhost:3229/etc/passwd"),
1077-
method: "GET",
1078-
headers: {},
1079-
timeoutInMS: 500,
1080-
})
1081-
).statusCode,
1082-
404
1083-
);
1038+
t.equal(
1039+
(
1040+
await fetch({
1041+
url: new URL("http://localhost:3229/../test"),
1042+
method: "GET",
1043+
headers: {},
1044+
timeoutInMS: 500,
1045+
})
1046+
).statusCode,
1047+
404
1048+
);
10841049

1085-
t.equal(
1086-
(
1087-
await fetch({
1088-
url: new URL("http://localhost:3229/.git/config"),
1089-
method: "GET",
1090-
headers: {},
1091-
timeoutInMS: 500,
1092-
})
1093-
).statusCode,
1094-
404
1095-
);
1050+
t.equal(
1051+
(
1052+
await fetch({
1053+
url: new URL("http://localhost:3229/etc/passwd"),
1054+
method: "GET",
1055+
headers: {},
1056+
timeoutInMS: 500,
1057+
})
1058+
).statusCode,
1059+
404
1060+
);
1061+
t.equal(
1062+
(
1063+
await fetch({
1064+
url: new URL("http://localhost:3229/.git/config"),
1065+
method: "GET",
1066+
headers: {},
1067+
timeoutInMS: 500,
1068+
})
1069+
).statusCode,
1070+
404
1071+
);
10961072

1097-
t.equal(
1098-
(
1099-
await fetch({
1100-
url: new URL("http://localhost:3229/%systemroot%/system32/cmd.exe"),
1101-
method: "GET",
1102-
headers: {},
1103-
timeoutInMS: 500,
1104-
})
1105-
).statusCode,
1106-
404
1107-
);
1073+
t.equal(
1074+
(
1075+
await fetch({
1076+
url: new URL(
1077+
"http://localhost:3229/%systemroot%/system32/cmd.exe"
1078+
),
1079+
method: "GET",
1080+
headers: {},
1081+
timeoutInMS: 500,
1082+
})
1083+
).statusCode,
1084+
404
1085+
);
1086+
}
11081087

11091088
t.match(api.getEvents(), [
11101089
{

0 commit comments

Comments
 (0)