33package integration
44
55import (
6- "gotest.tools/assert"
76 "strings"
87 "testing"
8+
9+ "gotest.tools/assert"
910)
1011
12+ // Help
1113/*
1214This function helps to validate all the cx --help command content.
1315Expected help content value is stored in the "integration/data/cxHelpText.txt"
@@ -23,7 +25,6 @@ func TestHelpFlag_Validate_CxHelpOutput(t *testing.T) {
2325}
2426
2527// Auth
26-
2728// Validate cx auth register --help command
2829func TestHelpFlag_Validate_AuthRegisterHelpMessage (t * testing.T ) {
2930
@@ -35,7 +36,7 @@ func TestHelpFlag_Validate_AuthRegisterHelpMessage(t *testing.T) {
3536
3637 _ , outputText := executeCommand (t , args ... )
3738
38- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
39+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
3940 textCapturedForValidation := GetFlagHelpText (normalizedOut )
4041
4142 assert .Equal (t , "Register new OAuth2 client and outputs its generated credentials in the format <key>=<value>" , textCapturedForValidation , "Incorrect help text found" )
@@ -52,7 +53,7 @@ func TestHelpFlag_Validate_AuthValidateHelpMessage(t *testing.T) {
5253
5354 _ , outputText := executeCommand (t , args ... )
5455
55- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
56+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
5657 textCapturedForValidation := GetFlagHelpText (normalizedOut )
5758
5859 assert .Equal (t , "Validates if CLI is able to communicate with Checkmarx One" , textCapturedForValidation , "Incorrect help text found" )
@@ -70,7 +71,7 @@ func TestHelpFlag_Validate_ConfigureHelpMessage(t *testing.T) {
7071
7172 _ , outputText := executeCommand (t , args ... )
7273
73- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
74+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
7475 textCapturedForValidation := GetFlagHelpText (normalizedOut )
7576
7677 assert .Equal (t , "The configure command is the fastest way to set up your AST CLI" , textCapturedForValidation , "Incorrect help text found" )
@@ -87,7 +88,7 @@ func TestHelpFlag_Validate_ConfigureSetHelpMessage(t *testing.T) {
8788
8889 _ , outputText := executeCommand (t , args ... )
8990
90- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
91+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
9192 textCapturedForValidation := GetFlagHelpText (normalizedOut )
9293
9394 assert .Equal (t , "Set configuration properties" , textCapturedForValidation , "Incorrect help text found" )
@@ -104,7 +105,7 @@ func TestHelpFlag_Validate_ConfigureShowHelpMessage(t *testing.T) {
104105
105106 _ , outputText := executeCommand (t , args ... )
106107
107- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
108+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
108109 textCapturedForValidation := GetFlagHelpText (normalizedOut )
109110
110111 assert .Equal (t , "Shows effective profile configuration" , textCapturedForValidation , "Incorrect help text found" )
@@ -123,7 +124,7 @@ func TestHelpFlag_Validate_HooksPreCommitHelpMessage(t *testing.T) {
123124
124125 _ , outputText := executeCommand (t , args ... )
125126
126- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
127+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
127128 textCapturedForValidation := GetFlagHelpText (normalizedOut )
128129
129130 assert .Equal (t , "The pre-commit command enables the ability to manage Git pre-commit hooks for secret detection." , textCapturedForValidation , "Incorrect help text found" )
@@ -142,7 +143,7 @@ func TestHelpFlag_ValidateProjectListHelpMessage(t *testing.T) {
142143
143144 _ , outputText := executeCommand (t , args ... )
144145
145- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
146+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
146147 textCapturedForValidation := GetFlagHelpText (normalizedOut )
147148
148149 assert .Equal (t , "List all projects in the system" , textCapturedForValidation , "Incorrect help text found" )
@@ -175,7 +176,7 @@ func TestHelpFlag_ValidateProjectDeleteHelpMessage(t *testing.T) {
175176
176177 _ , outputText := executeCommand (t , args ... )
177178
178- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
179+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
179180 textCapturedForValidation := GetFlagHelpText (normalizedOut )
180181
181182 assert .Equal (t , "Delete a project" , textCapturedForValidation , "Incorrect help text found" )
@@ -192,7 +193,7 @@ func TestHelpFlag_ValidateProjectShowHelpMessage(t *testing.T) {
192193
193194 _ , outputText := executeCommand (t , args ... )
194195
195- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
196+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
196197 textCapturedForValidation := GetFlagHelpText (normalizedOut )
197198
198199 assert .Equal (t , "Show information about a project" , textCapturedForValidation , "Incorrect help text found" )
@@ -209,7 +210,7 @@ func TestHelpFlag_ValidateProjectTagsHelpMessage(t *testing.T) {
209210
210211 _ , outputText := executeCommand (t , args ... )
211212
212- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
213+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
213214 textCapturedForValidation := GetFlagHelpText (normalizedOut )
214215
215216 assert .Equal (t , "Get a list of all available tags" , textCapturedForValidation , "Incorrect help text found" )
@@ -226,7 +227,7 @@ func TestHelpFlag_ValidateProjectBranchHelpMessage(t *testing.T) {
226227
227228 _ , outputText := executeCommand (t , args ... )
228229
229- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
230+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
230231 textCapturedForValidation := GetFlagHelpText (normalizedOut )
231232
232233 assert .Equal (t , "Show list of branches from a project" , textCapturedForValidation , "Incorrect help text found" )
@@ -244,7 +245,7 @@ func TestHelpFlag_Validate_ResultsHelpMessage(t *testing.T) {
244245
245246 _ , outputText := executeCommand (t , args ... )
246247
247- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
248+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
248249 textCapturedForValidation := GetFlagHelpText (normalizedOut )
249250
250251 assert .Equal (t , "Retrieve results" , textCapturedForValidation , "Incorrect help text found" )
@@ -275,7 +276,7 @@ func TestHelpFlag_Validate_ResultsCodeBashingHelpMessage(t *testing.T) {
275276
276277 _ , outputText := executeCommand (t , args ... )
277278
278- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
279+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
279280 textCapturedForValidation := GetFlagHelpText (normalizedOut )
280281
281282 assert .Equal (t , "The codebashing command enables the ability to retrieve the link about a specific vulnerability" , textCapturedForValidation , "Incorrect help text found" )
@@ -292,7 +293,7 @@ func TestHelpFlag_Validate_ResultsExitCodeHelpMessage(t *testing.T) {
292293
293294 _ , outputText := executeCommand (t , args ... )
294295
295- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
296+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
296297 textCapturedForValidation := GetFlagHelpText (normalizedOut )
297298
298299 assert .Equal (t , "The exit-code command enables you to get the exit code and failure details of a requested scan in Checkmarx One" , textCapturedForValidation , "Incorrect help text found" )
@@ -308,7 +309,7 @@ func TestHelpFlag_Validate_TriageHelpMessage(t *testing.T) {
308309
309310 _ , outputText := executeCommand (t , args ... )
310311
311- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
312+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
312313 textCapturedForValidation := GetFlagHelpText (normalizedOut )
313314
314315 assert .Equal (t , "The 'triage' command enables the ability to manage results in Checkmarx One" , textCapturedForValidation , "Incorrect help text found" )
@@ -325,7 +326,7 @@ func TestHelpFlag_Validate_TriageGetStatesHelpMessage(t *testing.T) {
325326
326327 _ , outputText := executeCommand (t , args ... )
327328
328- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
329+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
329330 textCapturedForValidation := GetFlagHelpText (normalizedOut )
330331
331332 assert .Equal (t , "The get-states command shows information about each of the custom states that have been configured in your tenant account" , textCapturedForValidation , "Incorrect help text found" )
@@ -341,7 +342,7 @@ func TestHelpFlag_Validate_TriageUpdateHelpMessage(t *testing.T) {
341342 }
342343 _ , outputText := executeCommand (t , args ... )
343344
344- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
345+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
345346 textCapturedForValidation := GetFlagHelpText (normalizedOut )
346347
347348 assert .Equal (t , "The update command enables the ability to triage the results in Checkmarx One" , textCapturedForValidation , "Incorrect help text found" )
@@ -357,7 +358,7 @@ func TestHelpFlag_Validate_TriageShowHelpMessage(t *testing.T) {
357358 }
358359 _ , outputText := executeCommand (t , args ... )
359360
360- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
361+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
361362 textCapturedForValidation := GetFlagHelpText (normalizedOut )
362363
363364 assert .Equal (t , "The show command provides a list of all the predicates in the issue" , textCapturedForValidation , "Incorrect help text found" )
@@ -376,13 +377,13 @@ func TestHelpFlag_Validate_ScanCancelHelpMessage(t *testing.T) {
376377
377378 _ , outputText := executeCommand (t , args ... )
378379
379- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
380+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
380381 textCapturedForValidation := GetFlagHelpText (normalizedOut )
381382
382383 assert .Equal (t , "The cancel command enables the ability to cancel one or more running scans in Checkmarx One" , textCapturedForValidation , "Incorrect help text found" )
383384}
384385
385- // Validate cx scan cancel --help command
386+ // Validate cx scan create --help command
386387func TestHelpFlag_Validate_CxScanCreateHelpOutput (t * testing.T ) {
387388 referenceFile := "data/console-help-text-log/scanCreateHelpLog.txt"
388389
@@ -407,7 +408,7 @@ func TestHelpFlag_Validate_ScanDeleteHelpMessage(t *testing.T) {
407408
408409 _ , outputText := executeCommand (t , args ... )
409410
410- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
411+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
411412 textCapturedForValidation := GetFlagHelpText (normalizedOut )
412413
413414 assert .Equal (t , "Deletes one or more scans" , textCapturedForValidation , "Incorrect help text found" )
@@ -424,7 +425,7 @@ func TestHelpFlag_Validate_ScanListHelpMessage(t *testing.T) {
424425
425426 _ , outputText := executeCommand (t , args ... )
426427
427- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
428+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
428429 textCapturedForValidation := GetFlagHelpText (normalizedOut )
429430
430431 assert .Equal (t , "The list command provides a list of all the scans in Checkmarx One" , textCapturedForValidation , "Incorrect help text found" )
@@ -441,7 +442,7 @@ func TestHelpFlag_Validate_ScanShowHelpMessage(t *testing.T) {
441442
442443 _ , outputText := executeCommand (t , args ... )
443444
444- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
445+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
445446 textCapturedForValidation := GetFlagHelpText (normalizedOut )
446447
447448 assert .Equal (t , "The show command enables the ability to show information about a requested scan in Checkmarx One" , textCapturedForValidation , "Incorrect help text found" )
@@ -458,7 +459,7 @@ func TestHelpFlag_Validate_ScanTagsHelpMessage(t *testing.T) {
458459
459460 _ , outputText := executeCommand (t , args ... )
460461
461- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
462+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
462463 textCapturedForValidation := GetFlagHelpText (normalizedOut )
463464
464465 assert .Equal (t , "The tags command enables the ability to provide a list of all the available tags in Checkmarx One" , textCapturedForValidation , "Incorrect help text found" )
@@ -475,7 +476,7 @@ func TestHelpFlag_Validate_ScanWorkflowHelpMessage(t *testing.T) {
475476
476477 _ , outputText := executeCommand (t , args ... )
477478
478- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
479+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
479480 textCapturedForValidation := GetFlagHelpText (normalizedOut )
480481
481482 assert .Equal (t , "The workflow command enables the ability to provide information about a requested scan workflow in Checkmarx One" , textCapturedForValidation , "Incorrect help text found" )
@@ -492,7 +493,7 @@ func TestHelpFlag_Validate_ScanLogsHelpMessage(t *testing.T) {
492493
493494 _ , outputText := executeCommand (t , args ... )
494495
495- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
496+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
496497 textCapturedForValidation := GetFlagHelpText (normalizedOut )
497498
498499 assert .Equal (t , "Accepts a scan-id and scan type (sast, iac-security) and downloads the related scan log" , textCapturedForValidation , "Incorrect help text found" )
@@ -509,7 +510,7 @@ func TestHelpFlag_Validate_ScanScaRealtimeHelpMessage(t *testing.T) {
509510
510511 _ , outputText := executeCommand (t , args ... )
511512
512- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
513+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
513514 textCapturedForValidation := GetFlagHelpText (normalizedOut )
514515
515516 assert .Equal (t , "The sca-realtime command enables the ability to create, run and retrieve results from a sca scan using sca resolver" , textCapturedForValidation , "Incorrect help text found" )
@@ -526,7 +527,7 @@ func TestHelpFlag_Validate_ScanKicsRealtimeHelpMessage(t *testing.T) {
526527
527528 _ , outputText := executeCommand (t , args ... )
528529
529- normalizedOut := Strip_ANSI (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
530+ normalizedOut := StripAnsi (strings .ReplaceAll (outputText .String (), "\r \n " , "\n " ))
530531 textCapturedForValidation := GetFlagHelpText (normalizedOut )
531532
532533 assert .Equal (t , "The kics-realtime command enables the ability to create, run and retrieve results from a kics scan using a docker image" , textCapturedForValidation , "Incorrect help text found" )
0 commit comments