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

Commit 0466262

Browse files
committed
Add integration test for a erroring scan
1 parent 05bbb61 commit 0466262

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

tests/integration/helpers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ async function scan(name, scanType, parameters = [], timeout = 180) {
8585
if (status && status.state === "Done") {
8686
await deleteScan(actualName);
8787
return status.findings;
88+
} else if (status && status.state === "Errored") {
89+
await deleteScan(actualName);
90+
throw new Error(`Scan failed with description "${status.errorDescription}"`)
8891
}
8992
}
9093

tests/integration/nmap.test.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test(
77
"nmap-localhost",
88
"nmap",
99
["localhost"],
10-
7 * 60
10+
90
1111
);
1212

1313
expect(count).toBe(1);
@@ -22,5 +22,18 @@ test(
2222
}
2323
`);
2424
},
25-
10 * 60 * 1000
25+
3 * 60 * 1000
26+
);
27+
28+
test(
29+
"invalid port scan should be marked as errored",
30+
async () => {
31+
await expect(scan(
32+
"nmap-localhost",
33+
"nmap",
34+
["-invalidFlag", "localhost"],
35+
90
36+
)).rejects.toThrow('Scan failed with description "Failed to run the Scan Container, check k8s Job and its logs for more details"');
37+
},
38+
3 * 60 * 1000
2639
);

0 commit comments

Comments
 (0)