diff --git a/cmd/abapEnvironmentCreateSystem_test.go b/cmd/abapEnvironmentCreateSystem_test.go index 770eafd59e..667c999c7d 100644 --- a/cmd/abapEnvironmentCreateSystem_test.go +++ b/cmd/abapEnvironmentCreateSystem_test.go @@ -32,7 +32,7 @@ func TestRunAbapEnvironmentCreateSystem(t *testing.T) { err := runAbapEnvironmentCreateSystem(&config, nil, cf, u) if assert.NoError(t, err) { assert.Equal(t, []mock.ExecCall{ - {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "'testUser'", "-p", "'testPassword'"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", config.CfService, config.CfServicePlan, config.CfServiceInstance, "-c", "{\"is_development_allowed\":false}", "--wait"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) @@ -79,7 +79,7 @@ func TestRunAbapEnvironmentCreateSystem(t *testing.T) { err = runAbapEnvironmentCreateSystem(&config, nil, cf, u) if assert.NoError(t, err) { assert.Equal(t, []mock.ExecCall{ - {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "'testUser'", "-p", "'testPassword'"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service-push", "--no-push", "--service-manifest", "customManifest.yml"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) diff --git a/cmd/abapEnvironmentPushATCSystemConfig_test.go b/cmd/abapEnvironmentPushATCSystemConfig_test.go index 66c6c7d65b..d57b626bf3 100644 --- a/cmd/abapEnvironmentPushATCSystemConfig_test.go +++ b/cmd/abapEnvironmentPushATCSystemConfig_test.go @@ -28,8 +28,8 @@ func TestFetchXcsrfTokenFromHead(t *testing.T) { Password: "Test", URL: "https://api.endpoint.com/Entity/", } - token, error := fetchXcsrfTokenFromHead(con, client) - if error == nil { + token, err := fetchXcsrfTokenFromHead(con, client) + if err == nil { assert.Equal(t, tokenExpected, token) } }) @@ -46,8 +46,8 @@ func TestFetchXcsrfTokenFromHead(t *testing.T) { Password: "Test", URL: "https://api.endpoint.com/Entity/", } - token, error := fetchXcsrfTokenFromHead(con, client) - if error == nil { + token, err := fetchXcsrfTokenFromHead(con, client) + if err == nil { assert.Equal(t, tokenExpected, token) } }) @@ -77,39 +77,39 @@ func TestHandleHttpResponse(t *testing.T) { --B772E21DAA42B9571C778276B829D6C20 Content-Type: multipart/mixed; boundary=B772E21DAA42B9571C778276B829D6C21 Content-Length: 1973 - + --B772E21DAA42B9571C778276B829D6C21 Content-Type: application/http Content-Length: 646 content-transfer-encoding: binary content-id: 1 - + HTTP/1.1 200 OK Content-Type: application/json;odata.metadata=minimal;charset=utf-8 Content-Length: 465 odata-version: 4.0 cache-control: no-cache, no-store, must-revalidate - + {"@odata.context":"$metadata#configuration/$entity","@odata.metadataEtag":"W/\"20220211135922\"","root_id":"1","conf_id":"aef8f52b-fe16-1edc-a3fe-27a1e0226c7b","conf_name":"Z_CONFIG_VIA_PIPELINE_STEP","checkvariant":"ABAP_CLOUD_DEVELOPMENT_DEFAULT","pseudo_comment_policy":"SP","last_changed_by":"CC0000000017","last_changed_at":"2022-03-02T11:16:51.336172Z","block_findings":"0","inform_findings":"1","transport_check_policy":"C","check_tasks":true,"check_requests":false,"check_tocs":true,"is_default":false,"is_proxy_variant":false,"SAP__Messages":[]} --B772E21DAA42B9571C778276B829D6C21 Content-Type: application/http Content-Length: 428 content-transfer-encoding: binary content-id: 2 - + HTTP/1.1 200 OK Content-Type: application/json;odata.metadata=minimal;charset=utf-8 Content-Length: 247 odata-version: 4.0 cache-control: no-cache, no-store, must-revalidate - + {"@odata.context":"$metadata#priority/$entity","@odata.metadataEtag":"W/\"20220211135922\"","root_id":"1","conf_id":"aef8f52b-fe16-1edc-a3fe-27a1e0226c7b","test":"CL_CI_ARS_COMPATIBILITY_CHECK","message_id":"010","default_priority":1,"priority":2} --B772E21DAA42B9571C778276B829D6C21 Content-Type: application/http Content-Length: 428 content-transfer-encoding: binary content-id: 3 - + HTTP/1.1 4** OK Content-Type: application/json;odata.metadata=minimal;charset=utf-8 Content-Length: 247 @@ -118,7 +118,7 @@ cache-control: no-cache, no-store, must-revalidate {"Some Error Messages possible in here!"} --B772E21DAA42B9571C778276B829D6C21-- - + --B772E21DAA42B9571C778276B829D6C20--` client := &abaputils.ClientMock{ @@ -150,39 +150,39 @@ cache-control: no-cache, no-store, must-revalidate --B772E21DAA42B9571C778276B829D6C20 Content-Type: multipart/mixed; boundary=B772E21DAA42B9571C778276B829D6C21 Content-Length: 1973 - + --B772E21DAA42B9571C778276B829D6C21 Content-Type: application/http Content-Length: 646 content-transfer-encoding: binary content-id: 1 - + HTTP/1.1 200 OK Content-Type: application/json;odata.metadata=minimal;charset=utf-8 Content-Length: 465 odata-version: 4.0 cache-control: no-cache, no-store, must-revalidate - + {"@odata.context":"$metadata#configuration/$entity","@odata.metadataEtag":"W/\"20220211135922\"","root_id":"1","conf_id":"aef8f52b-fe16-1edc-a3fe-27a1e0226c7b","conf_name":"Z_CONFIG_VIA_PIPELINE_STEP","checkvariant":"ABAP_CLOUD_DEVELOPMENT_DEFAULT","pseudo_comment_policy":"SP","last_changed_by":"CC0000000017","last_changed_at":"2022-03-02T11:16:51.336172Z","block_findings":"0","inform_findings":"1","transport_check_policy":"C","check_tasks":true,"check_requests":false,"check_tocs":true,"is_default":false,"is_proxy_variant":false,"SAP__Messages":[]} --B772E21DAA42B9571C778276B829D6C21 Content-Type: application/http Content-Length: 428 content-transfer-encoding: binary content-id: 2 - + HTTP/1.1 200 OK Content-Type: application/json;odata.metadata=minimal;charset=utf-8 Content-Length: 247 odata-version: 4.0 cache-control: no-cache, no-store, must-revalidate - + {"@odata.context":"$metadata#priority/$entity","@odata.metadataEtag":"W/\"20220211135922\"","root_id":"1","conf_id":"aef8f52b-fe16-1edc-a3fe-27a1e0226c7b","test":"CL_CI_ARS_COMPATIBILITY_CHECK","message_id":"010","default_priority":1,"priority":2} --B772E21DAA42B9571C778276B829D6C21 Content-Type: application/http Content-Length: 428 content-transfer-encoding: binary content-id: 3 - + HTTP/1.1 200 OK Content-Type: application/json;odata.metadata=minimal;charset=utf-8 Content-Length: 247 @@ -191,7 +191,7 @@ cache-control: no-cache, no-store, must-revalidate {"@odata.context":"$metadata#priority/$entity","@odata.metadataEtag":"W/\"20220211135922\"","root_id":"1","conf_id":"aef8f52b-fe16-1edc-a3fe-27a1e0226c7b","test":"CL_CI_ARS_COMPATIBILITY_CHECK","message_id":"011","default_priority":2,"priority":1} --B772E21DAA42B9571C778276B829D6C21-- - + --B772E21DAA42B9571C778276B829D6C20--` client := &abaputils.ClientMock{ @@ -328,7 +328,7 @@ Content-Type: application/json "transport_check_policy": "C", "check_tasks": true, "check_requests": false, - "check_tocs": true, + "check_tocs": true, "_priorities": [ { "test": "CL_CI_TEST_AMDP_HDB_MIGRATION", diff --git a/cmd/abapEnvironmentRunATCCheck_test.go b/cmd/abapEnvironmentRunATCCheck_test.go index ea607c5f32..e0d6104747 100644 --- a/cmd/abapEnvironmentRunATCCheck_test.go +++ b/cmd/abapEnvironmentRunATCCheck_test.go @@ -29,9 +29,9 @@ func TestHostConfig(t *testing.T) { Exec: execRunner, } var con abaputils.ConnectionDetailsHTTP - con, error := autils.GetAbapCommunicationArrangementInfo(options.AbapEnvOptions, "") + con, err := autils.GetAbapCommunicationArrangementInfo(options.AbapEnvOptions, "") - if error == nil { + if err == nil { assert.Equal(t, "testUser", con.User) assert.Equal(t, "testPassword", con.Password) assert.Equal(t, "https://api.endpoint.com", con.URL) @@ -82,8 +82,8 @@ func TestHostConfig(t *testing.T) { Exec: execRunner, } var con abaputils.ConnectionDetailsHTTP - con, error := autils.GetAbapCommunicationArrangementInfo(options.AbapEnvOptions, "") - if error == nil { + con, err := autils.GetAbapCommunicationArrangementInfo(options.AbapEnvOptions, "") + if err == nil { assert.Equal(t, "", con.User) assert.Equal(t, "", con.Password) assert.Equal(t, "", con.URL) @@ -106,8 +106,8 @@ func TestATCTrigger(t *testing.T) { Password: "Test", URL: "https://api.endpoint.com/Entity/", } - resp, error := runATC("GET", con, []byte(client.Body), client) - if error == nil { + resp, err := runATC("GET", con, []byte(client.Body), client) + if err == nil { assert.Equal(t, tokenExpected, resp.Header["X-Csrf-Token"][0]) assert.Equal(t, int64(0), resp.ContentLength) assert.Equal(t, []string([]string(nil)), resp.Header["Location"]) @@ -129,8 +129,8 @@ func TestFetchXcsrfToken(t *testing.T) { Password: "Test", URL: "https://api.endpoint.com/Entity/", } - token, error := fetchXcsrfToken("GET", con, []byte(client.Body), client) - if error == nil { + token, err := fetchXcsrfToken("GET", con, []byte(client.Body), client) + if err == nil { assert.Equal(t, tokenExpected, token) } }) @@ -147,8 +147,8 @@ func TestFetchXcsrfToken(t *testing.T) { Password: "Test", URL: "https://api.endpoint.com/Entity/", } - token, error := fetchXcsrfToken("GET", con, []byte(client.Body), client) - if error == nil { + token, err := fetchXcsrfToken("GET", con, []byte(client.Body), client) + if err == nil { assert.Equal(t, tokenExpected, token) } }) diff --git a/cmd/abapEnvironmentRunAUnitTest_test.go b/cmd/abapEnvironmentRunAUnitTest_test.go index 89c153e124..73f64006e5 100644 --- a/cmd/abapEnvironmentRunAUnitTest_test.go +++ b/cmd/abapEnvironmentRunAUnitTest_test.go @@ -582,8 +582,8 @@ func TestRunAbapEnvironmentRunAUnitTest(t *testing.T) { Password: "Test", URL: "https://api.endpoint.com/Entity/", } - token, error := fetchAUnitXcsrfToken("GET", con, []byte(client.Body), client) - if assert.Equal(t, nil, error) { + token, err := fetchAUnitXcsrfToken("GET", con, []byte(client.Body), client) + if assert.Equal(t, nil, err) { assert.Equal(t, tokenExpected, token) } }) @@ -603,8 +603,8 @@ func TestRunAbapEnvironmentRunAUnitTest(t *testing.T) { Password: "Test", URL: "https://api.endpoint.com/Entity/", } - token, error := fetchAUnitXcsrfToken("GET", con, []byte(client.Body), client) - if assert.Equal(t, nil, error) { + token, err := fetchAUnitXcsrfToken("GET", con, []byte(client.Body), client) + if assert.Equal(t, nil, err) { assert.Equal(t, tokenExpected, token) } }) diff --git a/cmd/abapLandscapePortalUpdateAddOnProduct_test.go b/cmd/abapLandscapePortalUpdateAddOnProduct_test.go index 7c1725db3f..d8d458d93f 100644 --- a/cmd/abapLandscapePortalUpdateAddOnProduct_test.go +++ b/cmd/abapLandscapePortalUpdateAddOnProduct_test.go @@ -1,3 +1,5 @@ +//go:build unit + package cmd import ( diff --git a/cmd/cloudFoundryCreateServiceKey_test.go b/cmd/cloudFoundryCreateServiceKey_test.go index dc886c7332..b2c1172e80 100644 --- a/cmd/cloudFoundryCreateServiceKey_test.go +++ b/cmd/cloudFoundryCreateServiceKey_test.go @@ -1,5 +1,4 @@ //go:build unit -// +build unit package cmd @@ -30,8 +29,8 @@ func TestCloudFoundryCreateServiceKey(t *testing.T) { cfUtilsMock := cloudfoundry.CfUtilsMock{} defer cfUtilsMock.Cleanup() - error := runCloudFoundryCreateServiceKey(&config, &telemetryData, &execRunner, &cfUtilsMock) - if error == nil { + err := runCloudFoundryCreateServiceKey(&config, &telemetryData, &execRunner, &cfUtilsMock) + if err == nil { assert.Equal(t, "cf", execRunner.Calls[0].Exec) assert.Equal(t, []string{"create-service-key", "testInstance", "testKey"}, execRunner.Calls[0].Params) } @@ -52,8 +51,7 @@ func TestCloudFoundryCreateServiceKey(t *testing.T) { cfUtilsMock := cloudfoundry.CfUtilsMock{} defer cfUtilsMock.Cleanup() - error := runCloudFoundryCreateServiceKey(&config, &telemetryData, &execRunner, &cfUtilsMock) - if error == nil { + if err := runCloudFoundryCreateServiceKey(&config, &telemetryData, &execRunner, &cfUtilsMock); err == nil { assert.Equal(t, "cf", execRunner.Calls[0].Exec) assert.Equal(t, []string{"create-service-key", "testInstance", "testKey", "-c", "testconfig.yml"}, execRunner.Calls[0].Params) } @@ -74,8 +72,7 @@ func TestCloudFoundryCreateServiceKey(t *testing.T) { cfUtilsMock := cloudfoundry.CfUtilsMock{} defer cfUtilsMock.Cleanup() - error := runCloudFoundryCreateServiceKey(&config, &telemetryData, &execRunner, &cfUtilsMock) - if error == nil { + if err := runCloudFoundryCreateServiceKey(&config, &telemetryData, &execRunner, &cfUtilsMock); err == nil { assert.Equal(t, "cf", execRunner.Calls[0].Exec) assert.Equal(t, []string{"create-service-key", "testInstance", "testKey", "-c", "{\"scenario_id\":\"SAP_COM_0510\",\"type\":\"basic\"}", cfCliSynchronousRequestFlag}, execRunner.Calls[0].Params) } @@ -103,8 +100,8 @@ func TestCloudFoundryCreateServiceKeyErrorMessages(t *testing.T) { } defer cfUtilsMock.Cleanup() - error := runCloudFoundryCreateServiceKey(&config, &telemetryData, &execRunner, &cfUtilsMock) - assert.Equal(t, error.Error(), "Error while logging in occurred: "+errorMessage, "Wrong error message") + err := runCloudFoundryCreateServiceKey(&config, &telemetryData, &execRunner, &cfUtilsMock) + assert.Equal(t, err.Error(), "Error while logging in occurred: "+errorMessage, "Wrong error message") }) t.Run("CF Logout Error", func(t *testing.T) { @@ -152,7 +149,7 @@ func TestCloudFoundryCreateServiceKeyErrorMessages(t *testing.T) { } defer cfUtilsMock.Cleanup() - error := runCloudFoundryCreateServiceKey(&config, &telemetryData, &execRunner, &cfUtilsMock) - assert.Equal(t, error.Error(), "Failed to Create Service Key: "+errorMessage, "Wrong error message") + err := runCloudFoundryCreateServiceKey(&config, &telemetryData, &execRunner, &cfUtilsMock) + assert.Equal(t, err.Error(), "Failed to Create Service Key: "+errorMessage, "Wrong error message") }) } diff --git a/cmd/cloudFoundryCreateService_test.go b/cmd/cloudFoundryCreateService_test.go index 1af31a4ebd..5ccab894ab 100644 --- a/cmd/cloudFoundryCreateService_test.go +++ b/cmd/cloudFoundryCreateService_test.go @@ -1,5 +1,4 @@ //go:build unit -// +build unit package cmd @@ -38,9 +37,9 @@ func TestCloudFoundryCreateService(t *testing.T) { CfServicePlan: "testPlan", CfAsync: false, } - error := runCloudFoundryCreateService(&config, &telemetryData, cf) - if assert.NoError(t, error) { - assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + err := runCloudFoundryCreateService(&config, &telemetryData, cf) + if assert.NoError(t, err) { + assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "'testUser'", "-p", "'testPassword'"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "--wait"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) @@ -61,9 +60,9 @@ func TestCloudFoundryCreateService(t *testing.T) { CfServiceTags: "testTag, testTag2", CfAsync: true, } - error := runCloudFoundryCreateService(&config, &telemetryData, cf) - if assert.NoError(t, error) { - assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + err := runCloudFoundryCreateService(&config, &telemetryData, cf) + if assert.NoError(t, err) { + assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "'testUser'", "-p", "'testPassword'"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-t", "testTag, testTag2"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) @@ -83,9 +82,9 @@ func TestCloudFoundryCreateService(t *testing.T) { CfServiceBroker: "testBroker", CfAsync: true, } - error := runCloudFoundryCreateService(&config, &telemetryData, cf) - if assert.NoError(t, error) { - assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + err := runCloudFoundryCreateService(&config, &telemetryData, cf) + if assert.NoError(t, err) { + assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "'testUser'", "-p", "'testPassword'"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-b", "testBroker"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) @@ -105,9 +104,9 @@ func TestCloudFoundryCreateService(t *testing.T) { CfCreateServiceConfig: "testConfig.json", CfAsync: true, } - error := runCloudFoundryCreateService(&config, &telemetryData, cf) - if assert.NoError(t, error) { - assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + err := runCloudFoundryCreateService(&config, &telemetryData, cf) + if assert.NoError(t, err) { + assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "'testUser'", "-p", "'testPassword'"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-c", "testConfig.json"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) @@ -117,8 +116,8 @@ func TestCloudFoundryCreateService(t *testing.T) { t.Run("Create service: failure, no config", func(t *testing.T) { defer cfMockCleanup(m) config := cloudFoundryCreateServiceOptions{} - error := runCloudFoundryCreateService(&config, &telemetryData, cf) - assert.EqualError(t, error, "Error while logging in: Failed to login to Cloud Foundry: Parameters missing. Please provide the Cloud Foundry Endpoint, Org, Space, Username and Password") + err := runCloudFoundryCreateService(&config, &telemetryData, cf) + assert.EqualError(t, err, "Error while logging in: Failed to login to Cloud Foundry: Parameters missing. Please provide the Cloud Foundry Endpoint, Org, Space, Username and Password") }) t.Run("Create service: variable substitution in-line", func(t *testing.T) { @@ -163,9 +162,9 @@ func TestCloudFoundryCreateService(t *testing.T) { ManifestVariables: manifestVariables, CfAsync: false, // should be ignored } - error := runCloudFoundryCreateService(&config, &telemetryData, cf) - if assert.NoError(t, error) { - assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + err = runCloudFoundryCreateService(&config, &telemetryData, cf) + if assert.NoError(t, err) { + assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "'testUser'", "-p", "'testPassword'"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service-push", "--no-push", "--service-manifest", "manifestTest.yml", "--var", "name1=Test1", "--var", "name2=Test2"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) @@ -220,9 +219,9 @@ func TestCloudFoundryCreateService(t *testing.T) { ManifestVariablesFiles: manifestVariablesFiles, ManifestVariables: []string{"a=b", "x=y"}, } - error := runCloudFoundryCreateService(&config, &telemetryData, cf) - if assert.NoError(t, error) { - assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + err = runCloudFoundryCreateService(&config, &telemetryData, cf) + if assert.NoError(t, err) { + assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "'testUser'", "-p", "'testPassword'"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service-push", "--no-push", "--service-manifest", "manifestTest.yml", "--vars-file", "varsTest.yml", "--vars-file", "varsTest2.yml", "--var", "a=b", "--var", "x=y"}}, {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) diff --git a/cmd/gcpPublishEvent_test.go b/cmd/gcpPublishEvent_test.go index cf3b43530f..393d93af66 100644 --- a/cmd/gcpPublishEvent_test.go +++ b/cmd/gcpPublishEvent_test.go @@ -1,3 +1,5 @@ +//go:build unit + package cmd import ( diff --git a/cmd/integrationArtifactDeploy_test.go b/cmd/integrationArtifactDeploy_test.go index 2b38a18e81..f52169f47f 100644 --- a/cmd/integrationArtifactDeploy_test.go +++ b/cmd/integrationArtifactDeploy_test.go @@ -1,5 +1,4 @@ //go:build unit -// +build unit package cmd @@ -209,9 +208,9 @@ func (c *httpMockCpis) SendRequest(method string, url string, r io.Reader, heade } if c.CPIFunction == "" { c.CPIFunction = cpi.GetCPIFunctionNameByURLCheck(url, method, c.TestType) - resp, error := cpi.GetCPIFunctionMockResponse(c.CPIFunction, c.TestType) + resp, err := cpi.GetCPIFunctionMockResponse(c.CPIFunction, c.TestType) c.CPIFunction = "" - return resp, error + return resp, err } return cpi.GetCPIFunctionMockResponse(c.CPIFunction, c.TestType) diff --git a/cmd/integrationArtifactTransport.go b/cmd/integrationArtifactTransport.go index d2c67397fd..c285ede348 100644 --- a/cmd/integrationArtifactTransport.go +++ b/cmd/integrationArtifactTransport.go @@ -76,8 +76,7 @@ func CreateIntegrationArtifactTransportRequest(config *integrationArtifactTransp processId := jsonResponse.Path("processId").Data().(string) if processId != "" { - error := pollTransportStatus(processId, retryCount, config, httpClient, apistruct.Host) - return error + return pollTransportStatus(processId, retryCount, config, httpClient, apistruct.Host) } return errors.New("Invalid process id") } diff --git a/cmd/malwareExecuteScan_test.go b/cmd/malwareExecuteScan_test.go index 99f84c9b26..ff87911078 100644 --- a/cmd/malwareExecuteScan_test.go +++ b/cmd/malwareExecuteScan_test.go @@ -77,9 +77,9 @@ func TestMalwareScanWithNoBuildtool(t *testing.T) { SHA256: "96ca802fbd54d31903f1115a1d95590c685160637d9262bd340ab30d0f817e85", } - error := runMalwareScan(&malwareScanConfig, nil, &utils) + err := runMalwareScan(&malwareScanConfig, nil, &utils) - assert.NoError(t, error) + assert.NoError(t, err) }) t.Run("Malware detected in file", func(t *testing.T) { @@ -92,8 +92,8 @@ func TestMalwareScanWithNoBuildtool(t *testing.T) { Finding: "Win.Test.EICAR_HDB-1", } - error := runMalwareScan(&malwareScanConfig, nil, &utils) - assert.EqualError(t, error, "Malware scan failed for file 'target/myFile'. Malware detected: true, encrypted content detected: false, finding: Win.Test.EICAR_HDB-1") + err := runMalwareScan(&malwareScanConfig, nil, &utils) + assert.EqualError(t, err, "Malware scan failed for file 'target/myFile'. Malware detected: true, encrypted content detected: false, finding: Win.Test.EICAR_HDB-1") }) t.Run("Encrypted content detected in file", func(t *testing.T) { @@ -105,8 +105,8 @@ func TestMalwareScanWithNoBuildtool(t *testing.T) { SHA256: "96ca802fbd54d31903f1115a1d95590c685160637d9262bd340ab30d0f817e85", } - error := runMalwareScan(&malwareScanConfig, nil, &utils) - assert.EqualError(t, error, "Malware scan failed for file 'target/myFile'. Malware detected: false, encrypted content detected: true, finding: ") + err := runMalwareScan(&malwareScanConfig, nil, &utils) + assert.EqualError(t, err, "Malware scan failed for file 'target/myFile'. Malware detected: false, encrypted content detected: true, finding: ") }) t.Run("Malware and encrypted content detected in file", func(t *testing.T) { @@ -119,8 +119,8 @@ func TestMalwareScanWithNoBuildtool(t *testing.T) { Finding: "Win.Test.EICAR_HDB-1", } - error := runMalwareScan(&malwareScanConfig, nil, &utils) - assert.EqualError(t, error, "Malware scan failed for file 'target/myFile'. Malware detected: true, encrypted content detected: true, finding: Win.Test.EICAR_HDB-1") + err := runMalwareScan(&malwareScanConfig, nil, &utils) + assert.EqualError(t, err, "Malware scan failed for file 'target/myFile'. Malware detected: true, encrypted content detected: true, finding: Win.Test.EICAR_HDB-1") }) t.Run("No file and no buildtool specified", func(t *testing.T) { @@ -131,8 +131,8 @@ func TestMalwareScanWithNoBuildtool(t *testing.T) { Timeout: "60", } - error := runMalwareScan(&malwareScanConfig, nil, nil) - assert.EqualError(t, error, "Please specify a file to be scanned") + err := runMalwareScan(&malwareScanConfig, nil, nil) + assert.EqualError(t, err, "Please specify a file to be scanned") }) t.Run("File to be scanned, can't be found", func(t *testing.T) { @@ -146,8 +146,8 @@ func TestMalwareScanWithNoBuildtool(t *testing.T) { ScanFile: "target/fileWhichDoesntExist", } - error := runMalwareScan(&malwareScanConfig, nil, &utils) - assert.EqualError(t, error, "the file 'target/fileWhichDoesntExist' does not exist: file does not exist") + err := runMalwareScan(&malwareScanConfig, nil, &utils) + assert.EqualError(t, err, "the file 'target/fileWhichDoesntExist' does not exist: file does not exist") }) } @@ -177,9 +177,9 @@ func TestMalwareScanWithDockerAsBuildtoolTests(t *testing.T) { ScanImage: "dockerimagename:latest", } - error := runMalwareScan(&malwareScanConfig, nil, &utils) + err := runMalwareScan(&malwareScanConfig, nil, &utils) - assert.NoError(t, error) + assert.NoError(t, err) }) t.Run("No file and no buildtool specified", func(t *testing.T) { @@ -190,8 +190,8 @@ func TestMalwareScanWithDockerAsBuildtoolTests(t *testing.T) { Timeout: "60", } - error := runMalwareScan(&malwareScanConfig, nil, &utils) - assert.EqualError(t, error, "Please specify a file to be scanned") + err := runMalwareScan(&malwareScanConfig, nil, &utils) + assert.EqualError(t, err, "Please specify a file to be scanned") }) } @@ -221,9 +221,9 @@ func TestMalwareScanWithOtherBuildtoolTests(t *testing.T) { ScanImage: "dockerimagename:latest", } - error := runMalwareScan(&malwareScanConfig, nil, &utils) + err := runMalwareScan(&malwareScanConfig, nil, &utils) - assert.NoError(t, error) + assert.NoError(t, err) }) } diff --git a/cmd/readPipelineEnv_test.go b/cmd/readPipelineEnv_test.go index 6efcb2ff61..3019d2eb78 100644 --- a/cmd/readPipelineEnv_test.go +++ b/cmd/readPipelineEnv_test.go @@ -1,3 +1,5 @@ +//go:build unit + package cmd import ( diff --git a/pkg/abaputils/abaputils.go b/pkg/abaputils/abaputils.go index fe805037a7..fff862c5de 100644 --- a/pkg/abaputils/abaputils.go +++ b/pkg/abaputils/abaputils.go @@ -38,42 +38,44 @@ type Communication interface { func (abaputils *AbapUtils) GetAbapCommunicationArrangementInfo(options AbapEnvironmentOptions, oDataURL string) (ConnectionDetailsHTTP, error) { c := abaputils.Exec var connectionDetails ConnectionDetailsHTTP - var error error + var err error - if options.Host != "" { - // Host, User and Password are directly provided -> check for host schema (double https) - match, err := regexp.MatchString(`^(https|HTTPS):\/\/.*`, options.Host) - if err != nil { - log.SetErrorCategory(log.ErrorConfiguration) - return connectionDetails, errors.Wrap(err, "Schema validation for host parameter failed. Check for https.") - } - var hostOdataURL = options.Host + oDataURL - if match { - connectionDetails.URL = hostOdataURL - connectionDetails.Host = options.Host - } else { - connectionDetails.URL = "https://" + hostOdataURL - connectionDetails.Host = "https://" + options.Host - } - connectionDetails.User = options.Username - connectionDetails.Password = options.Password - } else { + if options.Host == "" { if options.CfAPIEndpoint == "" || options.CfOrg == "" || options.CfSpace == "" || options.CfServiceInstance == "" || options.CfServiceKeyName == "" { var err = errors.New("Parameters missing. Please provide EITHER the Host of the ABAP server OR the Cloud Foundry API Endpoint, Organization, Space, Service Instance and Service Key") log.SetErrorCategory(log.ErrorConfiguration) return connectionDetails, err } // Url, User and Password should be read from a cf service key - var abapServiceKey, error = ReadServiceKeyAbapEnvironment(options, c) - if error != nil { - return connectionDetails, errors.Wrap(error, "Read service key failed") + var abapServiceKey, err = ReadServiceKeyAbapEnvironment(options, c) + if err != nil { + return connectionDetails, errors.Wrap(err, "Read service key failed") } connectionDetails.Host = abapServiceKey.URL connectionDetails.URL = abapServiceKey.URL + oDataURL connectionDetails.User = abapServiceKey.Abap.Username connectionDetails.Password = abapServiceKey.Abap.Password + return connectionDetails, err + } + + // Host, User and Password are directly provided -> check for host schema (double https) + match, err := regexp.MatchString(`^(https|HTTPS):\/\/.*`, options.Host) + if err != nil { + log.SetErrorCategory(log.ErrorConfiguration) + return connectionDetails, errors.Wrap(err, "Schema validation for host parameter failed. Check for https.") } - return connectionDetails, error + var hostOdataURL = options.Host + oDataURL + if match { + connectionDetails.URL = hostOdataURL + connectionDetails.Host = options.Host + } else { + connectionDetails.URL = "https://" + hostOdataURL + connectionDetails.Host = "https://" + options.Host + } + connectionDetails.User = options.Username + connectionDetails.Password = options.Password + + return connectionDetails, err } // ReadServiceKeyAbapEnvironment from Cloud Foundry and returns it. Depending on user/developer requirements if he wants to perform further Cloud Foundry actions diff --git a/pkg/abaputils/abaputils_test.go b/pkg/abaputils/abaputils_test.go index d9b0cafa2d..6f36fc37a2 100644 --- a/pkg/abaputils/abaputils_test.go +++ b/pkg/abaputils/abaputils_test.go @@ -1,5 +1,4 @@ //go:build unit -// +build unit package abaputils @@ -73,6 +72,7 @@ func TestCloudFoundryGetAbapCommunicationInfo(t *testing.T) { assert.Equal(t, "", connectionDetails.Password) assert.Equal(t, "", connectionDetails.XCsrfToken) + assert.Error(t, err) assert.EqualError(t, err, "Read service key failed: Parsing the service key failed for all supported formats. Service key is empty") }) t.Run("CF GetAbapCommunicationArrangementInfo - Success V8", func(t *testing.T) { diff --git a/pkg/abaputils/sap_com_0510.go b/pkg/abaputils/sap_com_0510.go index 556fc1b74c..ed6e5b3d1b 100644 --- a/pkg/abaputils/sap_com_0510.go +++ b/pkg/abaputils/sap_com_0510.go @@ -396,8 +396,8 @@ func (api *SAP_COM_0510) getLogProtocolQuery(page int) string { // ConvertTime formats an ABAP timestamp string from format /Date(1585576807000+0000)/ into a UNIX timestamp and returns it func (api *SAP_COM_0510) ConvertTime(logTimeStamp string) time.Time { seconds := strings.TrimPrefix(strings.TrimSuffix(logTimeStamp, "000+0000)/"), "/Date(") - n, error := strconv.ParseInt(seconds, 10, 64) - if error != nil { + n, err := strconv.ParseInt(seconds, 10, 64) + if err != nil { return time.Unix(0, 0).UTC() } t := time.Unix(n, 0).UTC() diff --git a/pkg/abaputils/sap_com_0948.go b/pkg/abaputils/sap_com_0948.go index 5d8477c190..d790faa13a 100644 --- a/pkg/abaputils/sap_com_0948.go +++ b/pkg/abaputils/sap_com_0948.go @@ -452,8 +452,8 @@ func (api *SAP_COM_0948) getLogProtocolQuery(page int) string { // ConvertTime formats an ISO 8601 timestamp string from format 2024-05-02T09:25:40Z into a UNIX timestamp and returns it func (api *SAP_COM_0948) ConvertTime(logTimeStamp string) time.Time { - t, error := time.Parse(time.RFC3339, logTimeStamp) - if error != nil { + t, err := time.Parse(time.RFC3339, logTimeStamp) + if err != nil { return time.Unix(0, 0).UTC() } return t diff --git a/pkg/cloudfoundry/Authentication.go b/pkg/cloudfoundry/Authentication.go index 014a829909..0f6f4d8657 100644 --- a/pkg/cloudfoundry/Authentication.go +++ b/pkg/cloudfoundry/Authentication.go @@ -3,6 +3,8 @@ package cloudfoundry import ( "errors" "fmt" + "runtime" + "strings" "github.com/SAP/jenkins-library/pkg/command" "github.com/SAP/jenkins-library/pkg/log" @@ -11,14 +13,13 @@ import ( // LoginCheck checks if user is logged in to Cloud Foundry with the receiver provided // to the function call. func (cf *CFUtils) LoginCheck(options LoginOptions) (bool, error) { + // TODO: options are not used ? return cf.loggedIn, nil } // Login logs user in to Cloud Foundry via cf cli. // Checks if user is logged in first, if not perform 'cf login' command with appropriate parameters func (cf *CFUtils) Login(options LoginOptions) error { - var err error - _c := cf.Exec if _c == nil { @@ -29,31 +30,29 @@ func (cf *CFUtils) Login(options LoginOptions) error { return fmt.Errorf("Failed to login to Cloud Foundry: %w", errors.New("Parameters missing. Please provide the Cloud Foundry Endpoint, Org, Space, Username and Password")) } - var loggedIn bool - - loggedIn, err = cf.LoginCheck(options) - - if loggedIn == true { - return err + if cf.loggedIn { + return nil } - if err == nil { - log.Entry().Info("Logging in to Cloud Foundry") + log.Entry().Info("Logging in to Cloud Foundry") - var cfLoginScript = append([]string{ - "login", - "-a", options.CfAPIEndpoint, - "-o", options.CfOrg, - "-s", options.CfSpace, - "-u", options.Username, - "-p", options.Password, - }, options.CfLoginOpts...) + escapedUsername := escapeValuesForCLI(options.Username, getGOOS) + escapedPassword := escapeValuesForCLI(options.Password, getGOOS) - log.Entry().WithField("cfAPI:", options.CfAPIEndpoint).WithField("cfOrg", options.CfOrg).WithField("space", options.CfSpace).Info("Logging into Cloud Foundry..") - - err = _c.RunExecutable("cf", cfLoginScript...) + cfLoginScript := []string{ + "login", + "-a", options.CfAPIEndpoint, + "-o", options.CfOrg, + "-s", options.CfSpace, + "-u", escapedUsername, + "-p", escapedPassword, } + cfLoginScript = append(cfLoginScript, options.CfLoginOpts...) + + log.Entry().WithField("cfAPI:", options.CfAPIEndpoint).WithField("cfOrg", options.CfOrg).WithField("space", options.CfSpace).Info("Logging into Cloud Foundry..") + + err := _c.RunExecutable("cf", cfLoginScript...) if err != nil { return fmt.Errorf("Failed to login to Cloud Foundry: %w", err) } @@ -62,6 +61,17 @@ func (cf *CFUtils) Login(options LoginOptions) error { return nil } +func escapeValuesForCLI(password string, getGOOS func() string) string { + switch getGOOS() { + case "windows": + return fmt.Sprintf("'%s'", strings.ReplaceAll(password, "'", `''`)) + case "linux", "darwin": + return fmt.Sprintf("'%s'", strings.ReplaceAll(password, "'", `'\''`)) + default: + return fmt.Sprintf("'%s'", strings.ReplaceAll(password, "'", `'\''`)) + } +} + // Logout logs User out of Cloud Foundry // Logout can be perforned via 'cf logout' command regardless if user is logged in or not func (cf *CFUtils) Logout() error { @@ -133,3 +143,7 @@ func (cf *CfUtilsMock) Cleanup() { cf.LoginError = nil cf.LogoutError = nil } + +func getGOOS() string { + return runtime.GOOS +} diff --git a/pkg/cloudfoundry/Authentication_test.go b/pkg/cloudfoundry/Authentication_test.go new file mode 100644 index 0000000000..6d388c1841 --- /dev/null +++ b/pkg/cloudfoundry/Authentication_test.go @@ -0,0 +1,63 @@ +//go:build unit + +package cloudfoundry + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_escapeValuesForCLI(t *testing.T) { + tests := []struct { + name string + os string + input string + expected string + }{ + { + name: "Windows password without quotes", + os: "windows", + input: `mypassword`, + expected: `'mypassword'`, + }, + { + name: "Windows password with quotes", + os: "windows", + input: `my\"password`, + expected: `'my\"password'`, + }, + { + name: "Non-Windows password without single quotes", + os: "linux", + input: "mypassword", + expected: "'mypassword'", + }, + { + name: "Non-Windows password with single quotes", + os: "darwin", + input: `my'password`, + expected: `'my'\''password'`, + }, + { + name: "Linux password with all special characters", + os: "linux", + input: "~!@#$%^&*()_+{`}|:\"<>?-=[]\\;',./", + expected: "'~!@#$%^&*()_+{`}|:\"<>?-=[]\\;'\\'',./'", + }, + { + name: "Windows password with all special characters", + os: "windows", + input: "~!@#$%^&*()_+{`}|:\"<>?-=[]\\;',./", + expected: "'~!@#$%^&*()_+{`}|:\"<>?-=[]\\;'',./'", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := escapeValuesForCLI(tt.input, func() string { return tt.os }) + assert.Equal(t, tt.expected, result, fmt.Sprintf("Failed for OS: %s and password: %s", tt.os, tt.input)) + }) + } +} diff --git a/pkg/cloudfoundry/CloudFoundry_test.go b/pkg/cloudfoundry/CloudFoundry_test.go index 57aaf63629..e480f46e03 100644 --- a/pkg/cloudfoundry/CloudFoundry_test.go +++ b/pkg/cloudfoundry/CloudFoundry_test.go @@ -1,5 +1,4 @@ //go:build unit -// +build unit package cloudfoundry @@ -87,8 +86,8 @@ func TestCloudFoundryLogin(t *testing.T) { "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", - "-u", "testUser", - "-p", "testPassword", + "-u", "'testUser'", + "-p", "'testPassword'", }}, }, m.Calls) } @@ -117,8 +116,8 @@ func TestCloudFoundryLogin(t *testing.T) { "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", - "-u", "testUser", - "-p", "testPassword", + "-u", "'testUser'", + "-p", "'testPassword'", }}, }, m.Calls) } @@ -150,8 +149,8 @@ func TestCloudFoundryLogin(t *testing.T) { "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", - "-u", "testUser", - "-p", "testPassword", + "-u", "'testUser'", + "-p", "'testPassword'", "--skip-ssl-validation", "--origin", "ldap", }}, @@ -184,7 +183,7 @@ func TestCloudFoundryReadServiceKeyAbapEnvironment(t *testing.T) { const password = "test_password" const serviceKey = ` cf comment test \n\n - {"sap.cloud.service":"com.sap.cloud.abap","url": "` + testURL + `" ,"systemid":"H01","abap":{"username":"` + username + `","password":"` + password + `","communication_scenario_id": "SAP_COM_0510","communication_arrangement_id": "SK_I6CBIRFZPPJDKYNATQA32W","communication_system_id": "SK_I6CBIRFZPPJDKYNATQA32W","communication_inbound_user_id": "CC0000000001","communication_inbound_user_auth_mode": "2"},"binding":{"env": "cf","version": "0.0.1.1","type": "basic","id": "i6cBiRfZppJdKynaTqa32W"},"preserve_host_header": true}` + {"sap.cloud.service":"com.sap.cloud.abap","url": "` + testURL + `" ,"systemid":"H01","abap":{"username":"'` + username + `'","password":"'` + password + `'","communication_scenario_id": "SAP_COM_0510","communication_arrangement_id": "SK_I6CBIRFZPPJDKYNATQA32W","communication_system_id": "SK_I6CBIRFZPPJDKYNATQA32W","communication_inbound_user_id": "CC0000000001","communication_inbound_user_auth_mode": "2"},"binding":{"env": "cf","version": "0.0.1.1","type": "basic","id": "i6cBiRfZppJdKynaTqa32W"},"preserve_host_header": true}` m.StdoutReturn = map[string]string{"cf service-key testInstance testServiceKeyName": serviceKey} @@ -213,13 +212,13 @@ func TestCloudFoundryReadServiceKeyAbapEnvironment(t *testing.T) { "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", - "-u", "testUser", - "-p", "testPassword", + "-u", "'testUser'", + "-p", "'testPassword'", }}, {Exec: "cf", Params: []string{"service-key", "testInstance", "testServiceKeyName"}}, {Exec: "cf", Params: []string{"logout"}}, }, m.Calls) } - assert.Equal(t, ` {"sap.cloud.service":"com.sap.cloud.abap","url": "`+testURL+`" ,"systemid":"H01","abap":{"username":"`+username+`","password":"`+password+`","communication_scenario_id": "SAP_COM_0510","communication_arrangement_id": "SK_I6CBIRFZPPJDKYNATQA32W","communication_system_id": "SK_I6CBIRFZPPJDKYNATQA32W","communication_inbound_user_id": "CC0000000001","communication_inbound_user_auth_mode": "2"},"binding":{"env": "cf","version": "0.0.1.1","type": "basic","id": "i6cBiRfZppJdKynaTqa32W"},"preserve_host_header": true}`, abapServiceKey) + assert.Equal(t, ` {"sap.cloud.service":"com.sap.cloud.abap","url": "`+testURL+`" ,"systemid":"H01","abap":{"username":"'`+username+`'","password":"'`+password+`'","communication_scenario_id": "SAP_COM_0510","communication_arrangement_id": "SK_I6CBIRFZPPJDKYNATQA32W","communication_system_id": "SK_I6CBIRFZPPJDKYNATQA32W","communication_inbound_user_id": "CC0000000001","communication_inbound_user_auth_mode": "2"},"binding":{"env": "cf","version": "0.0.1.1","type": "basic","id": "i6cBiRfZppJdKynaTqa32W"},"preserve_host_header": true}`, abapServiceKey) }) } diff --git a/pkg/cloudfoundry/ManifestUtils_test.go b/pkg/cloudfoundry/ManifestUtils_test.go index c7f27d62d3..abe5a58666 100644 --- a/pkg/cloudfoundry/ManifestUtils_test.go +++ b/pkg/cloudfoundry/ManifestUtils_test.go @@ -1,5 +1,4 @@ //go:build unit -// +build unit package cloudfoundry diff --git a/pkg/cloudfoundry/Vars_test.go b/pkg/cloudfoundry/Vars_test.go index 66b74ee751..11d4600c06 100644 --- a/pkg/cloudfoundry/Vars_test.go +++ b/pkg/cloudfoundry/Vars_test.go @@ -1,5 +1,4 @@ //go:build unit -// +build unit package cloudfoundry diff --git a/pkg/cpi/mockingUtils.go b/pkg/cpi/mockingUtils.go index 50f4217ed6..6c0fa13c04 100644 --- a/pkg/cpi/mockingUtils.go +++ b/pkg/cpi/mockingUtils.go @@ -309,9 +309,9 @@ func IntegrationDesigntimeArtifactUpdateMockResponse(testType string) (*http.Res // GetMockResponseByTestTypeAndMockFunctionName - Get mock response by testtype and mock function name func GetMockResponseByTestTypeAndMockFunctionName(mockFuntionName, testType string) (*http.Response, error) { - response, error := GetPositiveCaseResponseByTestType(testType) + response, err := GetPositiveCaseResponseByTestType(testType) - if response == nil && error == nil { + if response == nil && err == nil { switch mockFuntionName { @@ -355,7 +355,7 @@ func GetMockResponseByTestTypeAndMockFunctionName(mockFuntionName, testType stri return &res, errors.New("Unable to get integration artifact deploy error status, Response Status code:400") } } - return response, error + return response, err } // NegtiveResForIntegrationArtifactGenericCommandMockResponse -Nagative Case http response body @@ -377,9 +377,9 @@ func NegtiveResForIntegrationArtifactGenericCommandMockResponse(message string) // UpdateIntegrationDesigntimeArtifactMockResponse -Provide http respose body func UpdateIntegrationDesigntimeArtifactMockResponse(testType string) (*http.Response, error) { - response, error := GetRespBodyHTTPStatusCreated() + response, err := GetRespBodyHTTPStatusCreated() - if response == nil && error == nil { + if response == nil && err == nil { res := http.Response{ StatusCode: 400, @@ -393,7 +393,7 @@ func UpdateIntegrationDesigntimeArtifactMockResponse(testType string) (*http.Res } return &res, errors.New("Unable to get status of integration artifact, Response Status code:400") } - return response, error + return response, err } // IntegrationArtifactDownloadCommandMockResponsePositiveCaseRespBody -Provide http respose body for positive case