Skip to content

Commit

Permalink
Merge pull request #1052 from HeshanSudarshana/4.1.x-apictl-param-for…
Browse files Browse the repository at this point in the history
…mat-issue-test

[4.1.x] Add test case for API import with an invalid params file
  • Loading branch information
npamudika authored Jan 24, 2024
2 parents 72c9feb + cbc7639 commit f8374fd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
23 changes: 23 additions & 0 deletions import-export-cli/integration/envSpecific_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
environments:
- name: production
endpoints:
production:
url: 'https://prod.wso2.com'
sandbox:
url: 'https://sand.wso2.com'
7 changes: 5 additions & 2 deletions import-export-cli/integration/testutils/testConstants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit f8374fd

Please sign in to comment.