Skip to content

Commit e652056

Browse files
updated test
1 parent 59cdaf4 commit e652056

File tree

2 files changed

+1
-117
lines changed

2 files changed

+1
-117
lines changed

src/main/wrapper/CxWrapper.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ export class CxWrapper {
311311
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.PREDICATE_TYPE);
312312
}
313313

314-
async triageSCAUpdate(projectId: string, vulnerabilities: string, scanType: string, state: string, comment: string,stateId: number | null = null): Promise<CxCommandOutput> {
314+
async triageSCAUpdate(projectId: string, vulnerabilities: string, scanType: string, state: string, comment: string): Promise<CxCommandOutput> {
315315
const commands: string[] = [
316316
CxConstants.CMD_TRIAGE,
317317
CxConstants.SUB_CMD_UPDATE,
@@ -321,10 +321,6 @@ export class CxWrapper {
321321
CxConstants.COMMENT, comment,
322322
CxConstants.PROJECT_ID, projectId
323323
];
324-
if (stateId) {
325-
commands.push(CxConstants.STATE_ID);
326-
commands.push(stateId.toString());
327-
}
328324
commands.push(...this.initializeCommands(false));
329325
const exec = new ExecutionService();
330326
return await exec.executeCommands(this.config.pathToExecutable, commands);

src/tests/PredicateTest.test.ts

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -5,118 +5,6 @@ import CxResult from '../main/results/CxResult';
55
import {CxConstants} from '../main/wrapper/CxConstants';
66

77
describe("Triage cases", () => {
8-
9-
it('SCA Triage Show and Update Successful case', async () => {
10-
const projectId = "d4d7f382-8dee-48c7-ac8f-67fab2c313a8";
11-
const vulnerabilities = "packagename=Maven-org.apache.tomcat.embed:tomcat-embed-core,packageversion=9.0.14,vulnerabilityId=CVE-2024-56337,packagemanager=maven";
12-
const scanType = "sca";
13-
const state = "To_verify";
14-
const comment = "comment1";
15-
await handleTriageSCAShow(projectId, vulnerabilities, scanType);
16-
await handleTriageSCAUpdate(projectId, vulnerabilities, scanType, state, comment);
17-
});
18-
19-
// SCA Triage Update with stateId
20-
it('SCA Triage Update with stateId', async () => {
21-
const projectId = "d4d7f382-8dee-48c7-ac8f-67fab2c313a8";
22-
const vulnerabilities = "packagename=Maven-org.apache.tomcat.embed:tomcat-embed-core,packageversion=9.0.14,vulnerabilityId=CVE-2024-56337,packagemanager=maven";
23-
const scanType = "sca";
24-
const state = "To_verify";
25-
const comment = "comment1";
26-
const stateId = 123;
27-
await handleTriageSCAUpdate(projectId, vulnerabilities, scanType, state, comment, stateId);
28-
});
29-
30-
// SCA Triage Show and Update - Failure
31-
it('SCA Triage Show and Update Failure case', async () => {
32-
const projectId = "invalid-project-id";
33-
const vulnerabilities = "invalid-vulnerability-string";
34-
const scanType = "invalid";
35-
const state = "invalid_state";
36-
const comment = "invalid_comment";
37-
let errorShow = false;
38-
let errorUpdate = false;
39-
try {
40-
const cxShow: CxCommandOutput = await auth.triageSCAShow(projectId, vulnerabilities, scanType);
41-
expect(cxShow.exitCode).not.toEqual(0);
42-
} catch (e) {
43-
errorShow = true;
44-
}
45-
try {
46-
const cxUpdate: CxCommandOutput = await auth.triageSCAUpdate(projectId, vulnerabilities, scanType, state, comment);
47-
expect(cxUpdate.exitCode).not.toEqual(0);
48-
} catch (e) {
49-
errorUpdate = true;
50-
}
51-
expect(errorShow || errorUpdate).toBe(true);
52-
});
53-
54-
// SCA Triage Show and Update - Edge case: empty vulnerabilities
55-
it('SCA Triage Show and Update with empty vulnerabilities', async () => {
56-
const projectId = "d4d7f382-8dee-48c7-ac8f-67fab2c313a8";
57-
const vulnerabilities = "";
58-
const scanType = "sca";
59-
const state = "To_verify";
60-
const comment = "comment1";
61-
let errorShow = false;
62-
let errorUpdate = false;
63-
try {
64-
const cxShow: CxCommandOutput = await auth.triageSCAShow(projectId, vulnerabilities, scanType);
65-
expect(cxShow.exitCode).not.toEqual(0);
66-
} catch (e) {
67-
errorShow = true;
68-
}
69-
try {
70-
const cxUpdate: CxCommandOutput = await auth.triageSCAUpdate(projectId, vulnerabilities, scanType, state, comment);
71-
expect(cxUpdate.exitCode).not.toEqual(0);
72-
} catch (e) {
73-
errorUpdate = true;
74-
}
75-
expect(errorShow || errorUpdate).toBe(true);
76-
});
77-
78-
// SCA Triage Show and Update - Edge case: null/undefined arguments
79-
it('SCA Triage Show and Update with null/undefined arguments', async () => {
80-
let errorShow = false;
81-
let errorUpdate = false;
82-
try {
83-
const cxShow: CxCommandOutput = await auth.triageSCAShow(undefined, undefined, undefined);
84-
expect(cxShow.exitCode).not.toEqual(0);
85-
} catch (e) {
86-
errorShow = true;
87-
}
88-
try {
89-
const cxUpdate: CxCommandOutput = await auth.triageSCAUpdate(undefined, undefined, undefined, undefined, undefined);
90-
expect(cxUpdate.exitCode).not.toEqual(0);
91-
} catch (e) {
92-
errorUpdate = true;
93-
}
94-
expect(errorShow || errorUpdate).toBe(true);
95-
});
96-
97-
it('SCA Triage Show and Update Failure case', async () => {
98-
// Example values for SCA triage (simulate failure)
99-
const projectId = "invalid-project-id";
100-
const vulnerabilities = "invalid-vulnerability-string";
101-
const scanType = "invalid";
102-
const state = "invalid_state";
103-
const comment = "invalid_comment";
104-
let errorShow = false;
105-
let errorUpdate = false;
106-
try {
107-
const cxShow: CxCommandOutput = await auth.triageSCAShow(projectId, vulnerabilities, scanType);
108-
expect(cxShow.exitCode).not.toEqual(0);
109-
} catch (e) {
110-
errorShow = true;
111-
}
112-
try {
113-
const cxUpdate: CxCommandOutput = await auth.triageSCAUpdate(projectId, vulnerabilities, scanType, state, comment);
114-
expect(cxUpdate.exitCode).not.toEqual(0);
115-
} catch (e) {
116-
errorUpdate = true;
117-
}
118-
expect(errorShow || errorUpdate).toBe(true);
119-
});
1208
const cxScanConfig = new BaseTest();
1219
const auth = new CxWrapper(cxScanConfig);
12210
const getScanAndResult = async (): Promise<{ scan: any, result: CxResult }> => {

0 commit comments

Comments
 (0)