@@ -193,8 +193,9 @@ func TestScanCreate_ApplicationNameIsNotExactMatch_FailedToCreateScan(t *testing
193193 assert .Assert (t , err .Error () == errorConstants .ApplicationDoesntExistOrNoPermission )
194194}
195195
196- func TestScanCreate_ExistingProjectAndApplicationWithNoPermission_ShouldCreateScan (t * testing.T ) {
197- execCmdNilAssertion (t , "scan" , "create" , "--project-name" , "MOCK" , "--application-name" , mock .ApplicationDoesntExist , "-s" , dummyRepo , "-b" , "dummy_branch" )
196+ func TestScanCreate_ExistingProjectAndApplicationWithNoPermission_ShouldFailScan (t * testing.T ) {
197+ err := execCmdNotNilAssertion (t , "scan" , "create" , "--project-name" , "MOCK" , "--application-name" , mock .NoPermissionApp , "-s" , dummyRepo , "-b" , "dummy_branch" )
198+ assert .Assert (t , strings .Contains (err .Error (), errorConstants .FailedToGetApplication ), err .Error ())
198199}
199200
200201func TestScanCreate_ExistingApplicationWithNoPermission_FailedToCreateScan (t * testing.T ) {
@@ -712,18 +713,13 @@ func TestCreateScan_WhenProjectExists_ShouldIgnoreGroups(t *testing.T) {
712713 assert .Equal (t , strings .Contains (stdoutString , noUpdatesForExistingProject ), true , "Expected output: %s" , noUpdatesForExistingProject )
713714}
714715
715- func TestCreateScan_WhenProjectExists_ShouldIgnoreApplication (t * testing.T ) {
716- file := createOutputFile (t , outputFileName )
717- defer deleteOutputFile (file )
718- defer logger .SetOutput (os .Stdout )
716+ // Now as we give the ability to assign existing projects to applications , there is validation if application exists
717+
718+ func TestCreateScan_WhenProjectExists_GetApplication_Fails500Err_Failed (t * testing.T ) {
719719 baseArgs := []string {scanCommand , "create" , "--project-name" , "MOCK" , "-s" , dummyRepo , "-b" , "dummy_branch" ,
720- "--debug" , "--application-name" , "anyApplication" }
721- execCmdNilAssertion (t , baseArgs ... )
722- stdoutString , err := util .ReadFileAsString (file .Name ())
723- if err != nil {
724- t .Fatalf ("Failed to read log file: %v" , err )
725- }
726- assert .Equal (t , strings .Contains (stdoutString , noUpdatesForExistingProject ), true , "Expected output: %s" , noUpdatesForExistingProject )
720+ "--debug" , "--application-name" , mock .FakeInternalServerError500 }
721+ err := execCmdNotNilAssertion (t , baseArgs ... )
722+ assert .ErrorContains (t , err , errorConstants .FailedToGetApplication , err .Error ())
727723}
728724func TestScanCreateLastSastScanTimeWithInvalidValue (t * testing.T ) {
729725 baseArgs := []string {"scan" , "create" , "--project-name" , "MOCK" , "-s" , dummyRepo , "-b" , "dummy_branch" , "--sca-exploitable-path" , "true" , "--sca-last-sast-scan-time" , "notaniteger" }
@@ -3664,5 +3660,6 @@ func Test_CreateScanWithExistingProjectAndAssign_FailedApplication_DoesNot_Exist
36643660 t ,
36653661 baseArgs ... ,
36663662 )
3667- assert .Error (t , err , "Failed to get Application NoPermissionApp: provided application does not exist or user has no permission to the application" , err .Error ())
3663+ assert .ErrorContains (t , err , errorConstants .FailedToGetApplication , err .Error ())
3664+
36683665}
0 commit comments