Skip to content

Commit ebea3c1

Browse files
Fix flaky Result List Successful case in integration tests
The test searched tenant-wide completed scan history for one with parseable results, but that history is dominated by zero-finding scans, causing the CLI to omit the results key and the test to fail. It now triggers its own SAST scan against the known-vulnerable tsc/tests/data/python-vul-file.py so results are always present. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 0383e02 commit ebea3c1

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

src/tests/ResultTest.test.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {CxCommandOutput} from "../main/wrapper/CxCommandOutput";
22
import {BaseTest} from "./BaseTest";
33
import * as fs from "fs";
44
import CxWrapperFactory from "../main/wrapper/CxWrapperFactory";
5+
import {CxParamType} from "../main/wrapper/CxParamType";
56

67
const cxWrapperFactory = new CxWrapperFactory();
78

@@ -29,18 +30,18 @@ describe("Results cases",() => {
2930

3031
it('Result List Successful case', async () => {
3132
const auth = await cxWrapperFactory.createWrapper(cxScanConfig);
32-
const scanList: CxCommandOutput = await auth.scanList("statuses=Completed");
33-
let output;
34-
while (!output && scanList && scanList.payload && scanList.payload.length > 0) {
35-
const scanId = scanList.payload.pop().id;
36-
console.log("Triage Successful case - ScanId " + scanId);
37-
output = await auth.getResultsList(scanId);
38-
if (output.status == "Error in the json file.") {
39-
output = undefined;
40-
}
41-
}
33+
const params = new Map();
34+
params.set(CxParamType.PROJECT_NAME, "ast-cli-javascript-integration-success");
35+
params.set(CxParamType.S, "./tsc/tests/data");
36+
params.set(CxParamType.FILTER, "*.py");
37+
params.set(CxParamType.BRANCH, "master");
38+
params.set(CxParamType.SCAN_TYPES, "sast");
39+
const scanCreateOutput: CxCommandOutput = await auth.scanCreate(params);
40+
const scanId = scanCreateOutput.payload.pop().id;
41+
42+
const output = await auth.getResultsList(scanId);
4243
expect(output.status).toBeUndefined();
43-
expect(output.payload.length).toBeGreaterThanOrEqual(0);
44+
expect(output.payload.length).toBeGreaterThan(0);
4445
});
4546

4647
it('Result summary html file generation successful case', async () => {

0 commit comments

Comments
 (0)