1+ import { CxWrapper } from '../main/wrapper/CxWrapper' ;
12import { CxCommandOutput } from "../main/wrapper/CxCommandOutput" ;
23import { CxParamType } from "../main/wrapper/CxParamType" ;
34import { BaseTest } from "./BaseTest" ;
4- import CxWrapperFactory from "../main/wrapper/CxWrapperFactory" ;
5-
6- const cxWrapperFactory = new CxWrapperFactory ( ) ;
75
86describe ( "ScanCreate cases" , ( ) => {
97 const cxScanConfig = new BaseTest ( ) ;
108 it ( 'ScanList Successful case' , async ( ) => {
11- const auth = await cxWrapperFactory . createWrapper ( cxScanConfig ) ;
9+ const auth = new CxWrapper ( cxScanConfig ) ;
1210 const cxCommandOutput : CxCommandOutput = await auth . scanList ( "" ) ;
1311 console . log ( " Json object from scanList successful case: " + JSON . stringify ( cxCommandOutput ) ) ;
1412 expect ( cxCommandOutput . payload . length ) . toBeGreaterThan ( 1 ) ;
@@ -22,7 +20,7 @@ describe("ScanCreate cases", () => {
2220 params . set ( CxParamType . FILTER , "*.ts,!**/node_modules/**/*" ) ;
2321 params . set ( CxParamType . BRANCH , "master" ) ;
2422 params . set ( CxParamType . SCAN_TYPES , "kics" ) ;
25- const auth = await cxWrapperFactory . createWrapper ( cxScanConfig ) ;
23+ const auth = new CxWrapper ( cxScanConfig ) ;
2624 const cxCommandOutput : CxCommandOutput = await auth . scanCreate ( params ) ;
2725 const scanObject = cxCommandOutput . payload . pop ( ) ;
2826 const scanShowObject = await auth . scanShow ( scanObject . id ) ;
@@ -37,7 +35,7 @@ describe("ScanCreate cases", () => {
3735 params . set ( CxParamType . SAST_PRESET_NAME , "Checkmarx Default Fake" ) ;
3836 params . set ( CxParamType . BRANCH , "master" ) ;
3937 params . set ( CxParamType . SCAN_TYPES , "sast" ) ;
40- const auth = await cxWrapperFactory . createWrapper ( cxScanConfig ) ;
38+ const auth = new CxWrapper ( cxScanConfig ) ;
4139 const cxCommandOutput : CxCommandOutput = await auth . scanCreate ( params ) ;
4240 const scanObject = cxCommandOutput . payload . pop ( ) ;
4341 const scanShowObject = await auth . scanShow ( scanObject . id ) ;
@@ -52,7 +50,7 @@ describe("ScanCreate cases", () => {
5250 params . set ( CxParamType . FILTER , "*.ts,!**/node_modules/**/*" ) ;
5351 params . set ( CxParamType . BRANCH , "master" ) ;
5452 params . set ( CxParamType . ADDITIONAL_PARAMETERS , "--scan-types sast" ) ;
55- const auth = await cxWrapperFactory . createWrapper ( cxScanConfig ) ;
53+ const auth = new CxWrapper ( cxScanConfig ) ;
5654 const cxCommandOutput : CxCommandOutput = await auth . scanCreate ( params ) ;
5755 const scanObject = cxCommandOutput . payload . pop ( ) ;
5856 const scanShowObject = await auth . scanShow ( scanObject . id ) ;
@@ -68,7 +66,7 @@ describe("ScanCreate cases", () => {
6866 params . set ( CxParamType . SAST_PRESET_NAME , "Checkmarx Default Fake" ) ;
6967 params . set ( CxParamType . ADDITIONAL_PARAMETERS , "--async" ) ;
7068 params . set ( CxParamType . BRANCH , "master" ) ;
71- const auth = await cxWrapperFactory . createWrapper ( cxScanConfig ) ;
69+ const auth = new CxWrapper ( cxScanConfig ) ;
7270 const cxCommandOutput : CxCommandOutput = await auth . scanCreate ( params ) ;
7371 const scanObject = cxCommandOutput . payload . pop ( ) ;
7472 const scanShowObject = await auth . scanShow ( scanObject . id ) ;
@@ -83,7 +81,7 @@ describe("ScanCreate cases", () => {
8381 params . set ( CxParamType . BRANCH , "master" ) ;
8482 params . set ( CxParamType . FILTER , "*.ts,!**/node_modules/**/*" ) ;
8583 params . set ( CxParamType . ADDITIONAL_PARAMETERS , "--async" ) ;
86- const auth = await cxWrapperFactory . createWrapper ( cxScanConfig ) ;
84+ const auth = new CxWrapper ( cxScanConfig ) ;
8785 const cxCommandOutput : CxCommandOutput = await auth . scanCreate ( params ) ;
8886 const scanObject = cxCommandOutput . payload . pop ( ) ;
8987 await auth . scanCancel ( scanObject . id )
@@ -92,7 +90,7 @@ describe("ScanCreate cases", () => {
9290 } )
9391
9492 it ( 'KicsRealtime Successful case ' , async ( ) => {
95- const auth = await cxWrapperFactory . createWrapper ( cxScanConfig ) ;
93+ const auth = new CxWrapper ( cxScanConfig ) ;
9694 const [ outputProcess , pid ] = await auth . kicsRealtimeScan ( "dist/tests/data/Dockerfile" , "docker" , "-v" ) ;
9795 const cxCommandOutput : CxCommandOutput = await outputProcess ;
9896 console . log ( " Json object from successful no wait mode case: " + JSON . stringify ( cxCommandOutput . payload ) ) ;
@@ -103,7 +101,7 @@ describe("ScanCreate cases", () => {
103101 } )
104102
105103 it ( 'ScaRealtime Successful case' , async ( ) => {
106- const wrapper = await cxWrapperFactory . createWrapper ( cxScanConfig ) ;
104+ const wrapper = new CxWrapper ( cxScanConfig ) ;
107105 const cxCommandOutput : CxCommandOutput = await wrapper . runScaRealtimeScan ( process . cwd ( ) ) ;
108106 if ( cxCommandOutput . exitCode == 1 ) {
109107 expect ( cxCommandOutput . payload ) . toBeUndefined ( ) ;
@@ -115,58 +113,58 @@ describe("ScanCreate cases", () => {
115113
116114 it ( "Should check if scan create is possible" , async ( ) => {
117115 const cxScanConfig = new BaseTest ( ) ;
118- const auth = await cxWrapperFactory . createWrapper ( cxScanConfig ) ;
116+ const auth = new CxWrapper ( cxScanConfig ) ;
119117 const tenantSettings : boolean = await auth . ideScansEnabled ( ) ;
120118 expect ( tenantSettings ) . toBeDefined ( ) ;
121119 } )
122120
123121 it ( "Should check if AI guided remediation is active" , async ( ) => {
124122 const cxScanConfig = new BaseTest ( ) ;
125- const auth = await cxWrapperFactory . createWrapper ( cxScanConfig ) ;
123+ const auth = new CxWrapper ( cxScanConfig ) ;
126124 const aiEnabled : boolean = await auth . guidedRemediationEnabled ( ) ;
127125 expect ( aiEnabled ) . toBeDefined ( ) ;
128126 } )
129127
130- // it('ScanVorpal fail case Without extensions', async () => {
131- // const auth = await cxWrapperFactory.createWrapper (cxScanConfig);
132- // const cxCommandOutput: CxCommandOutput = await auth.scanVorpal ("tsc/tests/data/python-file");
133- // console.log(" Json object from failure case: " + JSON.stringify(cxCommandOutput));
134- //
135- // expect(cxCommandOutput.payload[0].error.description).toEqual("The file name must have an extension.");
136- // expect(cxCommandOutput.exitCode).toBe(0);
137- // expect(cxCommandOutput.payload[0].status).toBeUndefined();
138- // });
139-
140- // it('ScanVorpal Successful case', async () => {
141- // const auth = await cxWrapperFactory.createWrapper (cxScanConfig);
142- // const cxCommandOutput: CxCommandOutput = await auth.scanVorpal ("tsc/tests/data/python-vul-file.py");
143- // console.log("Json object from scanVorpal successful case: " + JSON.stringify(cxCommandOutput));
144- // const scanObject = cxCommandOutput.payload.pop();
145- // expect(cxCommandOutput.payload).toBeDefined();
146- // expect(cxCommandOutput.exitCode).toBe(0);
147- // expect(scanObject.status).toEqual(true);
148- // });
149- //
150- // it('ScanVorpal with complex name Successful case', async () => {
151- // const auth = await cxWrapperFactory.createWrapper (cxScanConfig);
152- // const cxCommandOutput: CxCommandOutput = await auth.scanVorpal ("tsc/tests/data/var express = require('express';.js");
153- // console.log("Json object from scanVorpal successful case: " + JSON.stringify(cxCommandOutput));
154- // const scanObject = cxCommandOutput.payload.pop();
155- // expect(cxCommandOutput.payload).toBeDefined();
156- // expect(cxCommandOutput.exitCode).toBe(0);
157- // expect(scanObject.status).toEqual(true);
158- // });
159- //
160- // it('ScanVorpal Successful case with update version', async () => {
161- // const auth = await cxWrapperFactory.createWrapper (cxScanConfig);
162- // const cxCommandOutput: CxCommandOutput = await auth.scanVorpal ("tsc/tests/data/python-vul-file.py", true);
163- // console.log("Json object from scanVorpal successful case with update version: " + JSON.stringify(cxCommandOutput));
164- // const scanObject = cxCommandOutput.payload.pop();
165- // expect(cxCommandOutput.payload).toBeDefined();
166- // expect(cxCommandOutput.exitCode).toBe(0);
167- // expect(scanObject.status).toEqual(true);
168- // expect(Number.isInteger(scanObject.scanDetails[0].line)).toBe(true);
169- // expect(typeof scanObject.scanDetails[0].description).toBe('string');
170- // });
128+ it ( 'ScanAsca fail case Without extensions' , async ( ) => {
129+ const auth = new CxWrapper ( cxScanConfig ) ;
130+ const cxCommandOutput : CxCommandOutput = await auth . scanAsca ( "tsc/tests/data/python-file" ) ;
131+ console . log ( " Json object from failure case: " + JSON . stringify ( cxCommandOutput ) ) ;
132+
133+ expect ( cxCommandOutput . payload [ 0 ] . error . description ) . toEqual ( "The file name must have an extension." ) ;
134+ expect ( cxCommandOutput . exitCode ) . toBe ( 0 ) ;
135+ expect ( cxCommandOutput . payload [ 0 ] . status ) . toBeUndefined ( ) ;
136+ } ) ;
137+
138+ it ( 'ScanAsca Successful case' , async ( ) => {
139+ const auth = new CxWrapper ( cxScanConfig ) ;
140+ const cxCommandOutput : CxCommandOutput = await auth . scanAsca ( "tsc/tests/data/python-vul-file.py" ) ;
141+ console . log ( "Json object from scanAsca successful case: " + JSON . stringify ( cxCommandOutput ) ) ;
142+ const scanObject = cxCommandOutput . payload . pop ( ) ;
143+ expect ( cxCommandOutput . payload ) . toBeDefined ( ) ;
144+ expect ( cxCommandOutput . exitCode ) . toBe ( 0 ) ;
145+ expect ( scanObject . status ) . toEqual ( true ) ;
146+ } ) ;
147+
148+ it ( 'ScanAsca with complex name Successful case' , async ( ) => {
149+ const auth = new CxWrapper ( cxScanConfig ) ;
150+ const cxCommandOutput : CxCommandOutput = await auth . scanAsca ( "tsc/tests/data/var express = require('express';.js" ) ;
151+ console . log ( "Json object from scanAsca successful case: " + JSON . stringify ( cxCommandOutput ) ) ;
152+ const scanObject = cxCommandOutput . payload . pop ( ) ;
153+ expect ( cxCommandOutput . payload ) . toBeDefined ( ) ;
154+ expect ( cxCommandOutput . exitCode ) . toBe ( 0 ) ;
155+ expect ( scanObject . status ) . toEqual ( true ) ;
156+ } ) ;
157+
158+ it ( 'ScanAsca Successful case with update version' , async ( ) => {
159+ const auth = new CxWrapper ( cxScanConfig ) ;
160+ const cxCommandOutput : CxCommandOutput = await auth . scanAsca ( "tsc/tests/data/python-vul-file.py" , true ) ;
161+ console . log ( "Json object from scanAsca successful case with update version: " + JSON . stringify ( cxCommandOutput ) ) ;
162+ const scanObject = cxCommandOutput . payload . pop ( ) ;
163+ expect ( cxCommandOutput . payload ) . toBeDefined ( ) ;
164+ expect ( cxCommandOutput . exitCode ) . toBe ( 0 ) ;
165+ expect ( scanObject . status ) . toEqual ( true ) ;
166+ expect ( Number . isInteger ( scanObject . scanDetails [ 0 ] . line ) ) . toBe ( true ) ;
167+ expect ( typeof scanObject . scanDetails [ 0 ] . description ) . toBe ( 'string' ) ;
168+ } ) ;
171169
172170} ) ;
0 commit comments