@@ -39,6 +39,19 @@ describe("Triage cases", () => {
3939 ) ;
4040 expect ( cxUpdate . exitCode ) . toEqual ( 0 ) ;
4141 } ;
42+
43+ // Helper for SCA triage show
44+ const handleTriageSCAShow = async ( projectId : string , vulnerabilities : string , scanType : string ) => {
45+ const cxShow : CxCommandOutput = await auth . triageSCAShow ( projectId , vulnerabilities , scanType ) ;
46+ expect ( cxShow . exitCode ) . toEqual ( 0 ) ;
47+ } ;
48+
49+ // Helper for SCA triage update
50+ const handleTriageSCAUpdate = async ( projectId : string , vulnerabilities : string , scanType : string , state : string , comment : string ) => {
51+ const cxUpdate : CxCommandOutput = await auth . triageSCAUpdate ( projectId , vulnerabilities , scanType , state , comment ) ;
52+ expect ( cxUpdate . exitCode ) . toEqual ( 0 ) ;
53+ } ;
54+
4255 const handlegetStates = async ( ) => {
4356 const cxCommandOutput : CxCommandOutput = await auth . triageGetStates ( false ) ;
4457 console . log ( "Json object from states successful case: " + JSON . stringify ( cxCommandOutput ) ) ;
@@ -47,12 +60,57 @@ describe("Triage cases", () => {
4760 return cxCommandOutput
4861 } ;
4962
63+ it ( 'SCA Triage Show and Update Successful case' , async ( ) => {
64+ const projectId = "d4d7f382-8dee-48c7-ac8f-67fab2c313a8" ;
65+ const vulnerabilities = "packagename=Maven-org.apache.tomcat.embed:tomcat-embed-core,packageversion=9.0.14,vulnerabilityId=CVE-2024-56337,packagemanager=maven" ;
66+ const scanType = "sca" ;
67+ const state = "To_verify" ;
68+ const comment = "comment1" ;
69+ await handleTriageSCAShow ( projectId , vulnerabilities , scanType ) ;
70+ await handleTriageSCAUpdate ( projectId , vulnerabilities , scanType , state , comment ) ;
71+ } ) ;
72+
73+ it ( 'SCA Triage Show and Update Failure case' , async ( ) => {
74+ const projectId = "invalid-project-id" ;
75+ const vulnerabilities = "invalid-vulnerability-string" ;
76+ const scanType = "invalid" ;
77+ const state = "invalid_state" ;
78+ const comment = "invalid_comment" ;
79+
80+ const cxShow : CxCommandOutput = await auth . triageSCAShow ( projectId , vulnerabilities , scanType ) ;
81+ expect ( cxShow . exitCode ) . not . toEqual ( 0 ) ;
82+
83+ const cxUpdate : CxCommandOutput = await auth . triageSCAUpdate ( projectId , vulnerabilities , scanType , state , comment ) ;
84+ expect ( cxUpdate . exitCode ) . not . toEqual ( 0 ) ;
85+ } ) ;
86+
87+ it ( 'SCA Triage Show and Update with empty vulnerabilities' , async ( ) => {
88+ const projectId = "d4d7f382-8dee-48c7-ac8f-67fab2c313a8" ;
89+ const vulnerabilities = "" ;
90+ const scanType = "sca" ;
91+ const state = "To_verify" ;
92+ const comment = "comment1" ;
93+ const cxShow : CxCommandOutput = await auth . triageSCAShow ( projectId , vulnerabilities , scanType ) ;
94+ expect ( cxShow . exitCode ) . not . toEqual ( 0 ) ;
95+
96+ const cxUpdate : CxCommandOutput = await auth . triageSCAUpdate ( projectId , vulnerabilities , scanType , state , comment ) ;
97+ expect ( cxUpdate . exitCode ) . not . toEqual ( 0 ) ;
98+ } ) ;
99+
100+ it ( 'SCA Triage Show and Update with null/undefined arguments' , async ( ) => {
101+ const cxShow : CxCommandOutput = await auth . triageSCAShow ( undefined , undefined , undefined ) ;
102+ expect ( cxShow . exitCode ) . not . toEqual ( 0 ) ;
103+ const cxUpdate : CxCommandOutput = await auth . triageSCAUpdate ( undefined , undefined , undefined , undefined , undefined ) ;
104+ expect ( cxUpdate . exitCode ) . not . toEqual ( 0 ) ;
105+ } ) ;
106+
50107 it ( 'Triage Successful case' , async ( ) => {
51108 const { scan, result } = await getScanAndResult ( ) ;
52109 await handleTriageShow ( scan , result ) ;
53110 await handleTriageUpdate ( scan , result , result . state , result . severity . toLowerCase ( ) === "high" ? CxConstants . SEVERITY_MEDIUM : CxConstants . SEVERITY_HIGH ) ;
54111 } ) ;
55112
113+
56114 it . skip ( 'Triage with custom state Successful case' , async ( ) => {
57115 const { scan, result } = await getScanAndResult ( ) ;
58116
0 commit comments