@@ -2,30 +2,36 @@ import {CxWrapper} from '../main/wrapper/CxWrapper';
22import { CxCommandOutput } from "../main/wrapper/CxCommandOutput" ;
33import { BaseTest } from "./BaseTest" ;
44import CxResult from '../main/results/CxResult' ;
5- import { CxConstants } from '../main/wrapper/CxConstants' ;
5+ import { CxConstants } from '../main/wrapper/CxConstants' ;
66
7- describe ( "Triage cases" , ( ) => {
7+ describe ( "Triage cases" , ( ) => {
88 const cxScanConfig = new BaseTest ( ) ;
99
10- it ( 'TriageShow Successful case' , async ( ) => {
10+ it ( 'Triage Successful case' , async ( ) => {
1111 const auth = new CxWrapper ( cxScanConfig ) ;
12- const scan = ( await auth . scanShow ( cxScanConfig . scanId ) ) . payload . pop ( ) ;
13- const results = await auth . getResultsList ( cxScanConfig . scanId )
14- const result : CxResult = results . payload . find ( res => res . type == CxConstants . SAST )
1512
16- const cxCommandOutput : CxCommandOutput = await auth . triageShow ( scan . projectID , result . similarityId , result . type ) ;
17-
18- expect ( cxCommandOutput . exitCode ) . toEqual ( 0 ) ;
19- } )
13+ const scanList : CxCommandOutput = await auth . scanList ( "statuses=Completed" ) ;
14+ let scan , output ;
15+ while ( ! output && scanList && scanList . payload && scanList . payload . length > 0 ) {
16+ scan = scanList . payload . pop ( )
17+ console . log ( "Triage Successful case - ScanId " + scan . id )
18+ output = await auth . getResultsList ( scan . id )
19+ if ( output . status == "Error in the json file." ) {
20+ output = undefined ;
21+ }
22+ }
2023
21- it ( 'TriageUpdate Successful case' , async ( ) => {
22- const auth = new CxWrapper ( cxScanConfig ) ;
23- const scan = ( await auth . scanShow ( cxScanConfig . scanId ) ) . payload . pop ( ) ;
24- const results = await auth . getResultsList ( cxScanConfig . scanId )
25- const result : CxResult = results . payload . find ( res => res . type == CxConstants . SAST )
24+ const result : CxResult = output . payload . find ( res => res . type == CxConstants . SAST )
25+
26+ const cxShow : CxCommandOutput = await auth . triageShow ( scan . projectID , result . similarityId , result . type ) ;
27+
28+ expect ( cxShow . exitCode ) . toEqual ( 0 ) ;
2629
27- const cxCommandOutput : CxCommandOutput = await auth . triageUpdate ( scan . projectID , result . similarityId , result . type , CxConstants . STATE_CONFIRMED , "Edited via JavascriptWrapper" , result . severity . toLowerCase ( ) == "high" ? CxConstants . SEVERITY_MEDIUM : CxConstants . SEVERITY_HIGH ) ;
30+ const cxUpdate : CxCommandOutput = await
31+ auth . triageUpdate ( scan . projectID , result . similarityId , result . type , result . state ,
32+ "Edited via JavascriptWrapper" ,
33+ result . severity . toLowerCase ( ) == "high" ? CxConstants . SEVERITY_MEDIUM : CxConstants . SEVERITY_HIGH ) ;
2834
29- expect ( cxCommandOutput . exitCode ) . toEqual ( 0 ) ;
30- } )
35+ expect ( cxUpdate . exitCode ) . toEqual ( 0 ) ;
36+ } ) ;
3137} ) ;
0 commit comments