@@ -5,118 +5,6 @@ import CxResult from '../main/results/CxResult';
55import { CxConstants } from '../main/wrapper/CxConstants' ;
66
77describe ( "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