diff --git a/import-export-cli/integration/envSpecific_test.go b/import-export-cli/integration/envSpecific_test.go index 533966958..0e51ed15a 100644 --- a/import-export-cli/integration/envSpecific_test.go +++ b/import-export-cli/integration/envSpecific_test.go @@ -63,6 +63,29 @@ func TestEnvironmentSpecificParamsEndpoint(t *testing.T) { } } +// Try to import an API with the external params file with invalid format (missing the configs key) +func TestInvalidEnvironmentSpecificParamsEndpoint(t *testing.T) { + for _, user := range testCaseUsers { + t.Run(user.Description, func(t *testing.T) { + dev := GetDevClient() + prod := GetProdClient() + + api := testutils.AddAPI(t, dev, user.ApiCreator.Username, user.ApiCreator.Password) + + args := &testutils.ApiImportExportTestArgs{ + ApiProvider: testutils.Credentials{Username: user.ApiCreator.Username, Password: user.ApiCreator.Password}, + CtlUser: testutils.Credentials{Username: user.CtlUser.Username, Password: user.CtlUser.Password}, + Api: api, + SrcAPIM: dev, + DestAPIM: prod, + ParamsFile: testutils.InvalidAPIEndpointParamsFile, + } + + testutils.ValidateAPIImportFailure(t, args) + }) + } +} + // Add an API to one environment, export it and re-import it to another environment by setting // the configs for endpoints using the params file func TestEnvironmentSpecificParamsEndpointConfigs(t *testing.T) { diff --git a/import-export-cli/integration/testdata/EnvParamsFiles/invalid_api_params_endpoint.yaml b/import-export-cli/integration/testdata/EnvParamsFiles/invalid_api_params_endpoint.yaml new file mode 100644 index 000000000..0a25787e4 --- /dev/null +++ b/import-export-cli/integration/testdata/EnvParamsFiles/invalid_api_params_endpoint.yaml @@ -0,0 +1,7 @@ +environments: + - name: production + endpoints: + production: + url: 'https://prod.wso2.com' + sandbox: + url: 'https://sand.wso2.com' diff --git a/import-export-cli/integration/testutils/testConstants.go b/import-export-cli/integration/testutils/testConstants.go index 13f9c424c..9bc39104c 100644 --- a/import-export-cli/integration/testutils/testConstants.go +++ b/import-export-cli/integration/testutils/testConstants.go @@ -18,7 +18,7 @@ package testutils -//Environment management related test constants +// Environment management related test constants const ApictlInitMessage = "apictl is a Command Line Tool for Importing and Exporting APIs and Applications between " + "different environments of WSO2 API Manager" const CustomTestExportDirectory = "CustomExportDirectory" @@ -33,7 +33,7 @@ const TestMigrationDirectorySuffix = "/migration" const DefaultApictlTestAppName = "default-apictl-app" -//Export test cases +// Export test cases const DevFirstDefaultAPIName = "SwaggerPetstoreNew" const DevFirstSwagger2APIName = "PizzaShackAPI" const OpenAPI3DefinitionWithoutEndpointsAPIName = "PizzaShackAPI" @@ -133,6 +133,9 @@ const APIAwsEndpointWithStoredCredentialsParamsFile = EnvParamsFilesDir + "/api_ // APIDynamicEndpointParamsFile : Dynamic Endpoint with stored credentials in api_params.yaml const APIDynamicEndpointParamsFile = EnvParamsFilesDir + "/api_params_dynamic_endpoint.yaml" +// InvalidAPIEndpointParamsFile : Invalid Endpoint URL api_params.yaml +const InvalidAPIEndpointParamsFile = EnvParamsFilesDir + "/invalid_api_params_endpoint.yaml" + // API types const APITypeREST = "HTTP" const APITypeSoap = "SOAP"