Skip to content

Commit

Permalink
Merge pull request #466 from Chamindu36/chamindu_master_fixes
Browse files Browse the repository at this point in the history
Check path differences before assert in changeExportDirectory test-case
  • Loading branch information
uvindra authored Aug 13, 2020
2 parents d779a77 + 0ae5fb5 commit c3d66a8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion import-export-cli/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
1. In order to run the integration tests, two instances of API Manager need to be started. By default integration tests are configured to run against local instances with port offset 0 and 1. If you need to configure the instances differently, it can be done as explained later on in the document. These two instances will act as the APIM environments that will be used for testing exporting and importing scenarios respectively. The integration tests will execute apictl commands, DCR calls, REST API calls and admin service calls against these instances.

2. Before starting the APIM instances update the APIM *deployment.toml* to allow the `@` character as part of the service provider name. This is to support DCR for tenant users since the `@` is part of the username. The updated config should look as follows,

(**If this test suite is running on a Windows machine, make sure to disable security scans and security guards of that machine prior to the test suite starts.)
```
[service_provider]
sp_name_regex = "^[@\\sa-zA-Z0-9._-]*$"
Expand Down
9 changes: 8 additions & 1 deletion import-export-cli/integration/base/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,14 @@ func CreateTempDir(t *testing.T, path string) {
}

func GetExportedPathFromOutput(output string) string {
return strings.ReplaceAll(strings.ReplaceAll(output[strings.Index(output, string(os.PathSeparator)):], "\n", ""), " ", "")
//Check directory path to omit changes due to OS differences
if strings.Contains(output, ":\\") {
arrayOutput := []rune (output)
extractedPath := string(arrayOutput[strings.Index(output, ":\\")-1:])
return strings.ReplaceAll(strings.ReplaceAll(extractedPath, "\n", ""), " ", "")
} else {
return strings.ReplaceAll(strings.ReplaceAll(output[strings.Index(output, string(os.PathSeparator)):], "\n", ""), " ", "")
}
}

//Count number of files in a directory
Expand Down
6 changes: 3 additions & 3 deletions import-export-cli/integration/environmnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ func TestChangeExportDirectory(t *testing.T) {
})

apimClient := apimClients[0]
projectName := "OpenAPI3Project"
apiName := "SwaggerPetstoreNew"
apiVersion := "1.0.0"
projectName := base.GenerateRandomName(16)
apiName := testutils.DevFirstDefaultAPIName
apiVersion := testutils.DevFirstDefaultAPIVersion
username := superAdminUser
password := superAdminPassword

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ func ValidateExportApiPassed(t *testing.T, args *ApiImportExportTestArgs, direct
//Derive exported path from output
exportedPath := filepath.Dir(base.GetExportedPathFromOutput(output))

assert.True(t, strings.HasPrefix(exportedPath, directoryName), "API doesn't seem to exported to the "+
"changed exported location. Expected in "+directoryName+" but it is exported in "+exportedPath)
assert.True(t, strings.HasPrefix(exportedPath, directoryName), "API export path "+exportedPath+" is"+
" not within the expected export location "+directoryName)

assert.True(t, base.IsAPIArchiveExists(t, exportedPath, args.Api.Name, args.Api.Version), "API archive"+
" is not correctly exported to "+directoryName)
Expand Down

0 comments on commit c3d66a8

Please sign in to comment.