@@ -21,10 +21,11 @@ import (
2121)
2222
2323const (
24- fileName = "result-test"
25- resultsDirectory = "output-results-folder/"
26- fileExtention = "report.json"
27-
24+ fileName = "result-test"
25+ resultsDirectory = "output-results-folder/"
26+ fileExtention = "report.json"
27+ queryIDWrongValueValue = "11666704984804998184"
28+ queryIDValue = "8481125285487743346"
2829 //----------------------------------------------------------------------------------------------------------------------
2930 // This ScanIDWithDevAndTestDep is associated with the CXOne project: ASTCLI/HideDevAndTestsVulnerabilities/Test (DEU, Galactica tenant).
3031 // All vulnerable packages in this project have been snoozed or muted, so no vulnerabilities should appear in this scan.
@@ -192,7 +193,7 @@ func TestCodeBashingParamFailed(t *testing.T) {
192193 }
193194
194195 err , _ := executeCommand (t , args ... )
195- assertError (t , err , "required flag(s) \" cwe -id\" , \" language \" , \" vulnerability-type \" not set" )
196+ assertError (t , err , "required flag(s) \" query -id\" not set" )
196197}
197198
198199func TestCodeBashingList (t * testing.T ) {
@@ -201,9 +202,7 @@ func TestCodeBashingList(t *testing.T) {
201202 "Getting results should pass" ,
202203 "results" ,
203204 "codebashing" ,
204- flag (params .LanguageFlag ), "PHP" ,
205- flag (params .VulnerabilityTypeFlag ), "Reflected XSS All Clients" ,
206- flag (params .CweIDFlag ), "79" )
205+ flag (params .QueryIDFlag ), queryIDValue )
207206
208207 codebashing := []wrappers.CodeBashingCollection {}
209208
@@ -218,9 +217,7 @@ func TestCodeBashingListJson(t *testing.T) {
218217 "Getting results should pass" ,
219218 "results" ,
220219 "codebashing" ,
221- flag (params .LanguageFlag ), "PHP" ,
222- flag (params .VulnerabilityTypeFlag ), "Reflected XSS All Clients" ,
223- flag (params .CweIDFlag ), "79" ,
220+ flag (params .QueryIDFlag ), queryIDValue ,
224221 flag (params .FormatFlag ), "json" )
225222
226223 codebashing := []wrappers.CodeBashingCollection {}
@@ -236,34 +233,33 @@ func TestCodeBashingListTable(t *testing.T) {
236233 "Getting results should pass" ,
237234 "results" ,
238235 "codebashing" ,
239- flag (params .LanguageFlag ), "PHP" ,
240- flag (params .VulnerabilityTypeFlag ), "Reflected XSS All Clients" ,
241- flag (params .CweIDFlag ), "79" ,
236+ flag (params .QueryIDFlag ), queryIDValue ,
242237 flag (params .FormatFlag ), "table" )
243238
244239 assert .Assert (t , outputBuffer != nil , "Should exist codebashing link" )
245240}
246241
247242func TestCodeBashingListEmpty (t * testing.T ) {
248- args := []string {
243+ outputBuffer := executeCmdNilAssertion (
244+ t ,
245+ "Getting results should pass" ,
249246 "results" ,
250247 "codebashing" ,
251- flag (params .LanguageFlag ), "PHP" ,
252- flag (params .VulnerabilityTypeFlag ), "Reflected XSS All Clients" ,
253- flag (params .CweIDFlag ), "11" ,
254- }
248+ flag (params .QueryIDFlag ), queryIDWrongValueValue )
255249
256- err , _ := executeCommand (t , args ... )
257- assertError (t , err , "No codebashing link available" )
250+ assert .Assert (t , outputBuffer != nil , "Output buffer should not be nil" )
251+ output := outputBuffer .String ()
252+ assert .Assert (t ,
253+ strings .Contains (output , "lessonUrl" ) &&
254+ strings .Contains (output , "/app/home" ),
255+ "Output should contain expected codebashing lesson information" )
258256}
259257
260258func TestCodeBashingFailedListingAuth (t * testing.T ) {
261259 args := []string {
262260 "results" ,
263261 "codebashing" ,
264- flag (params .LanguageFlag ), "PHP" ,
265- flag (params .VulnerabilityTypeFlag ), "Reflected XSS All Clients" ,
266- flag (params .CweIDFlag ), "11" ,
262+ flag (params .QueryIDFlag ), queryIDValue ,
267263 flag (params .AccessKeySecretFlag ), "mock" ,
268264 flag (params .AccessKeyIDFlag ), "mock" ,
269265 flag (params .AstAPIKeyFlag ), "mock" ,
0 commit comments