Skip to content

Commit

Permalink
Merge pull request #980 from YasasRangika/yasas-4.0.x
Browse files Browse the repository at this point in the history
[CTL-4.0.x] Add URL encoding when exporting an API using the API CTL tool
  • Loading branch information
YasasRangika authored May 19, 2023
2 parents b8a24a6 + ac63500 commit 441e0c1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion import-export-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Command Line tool for importing and exporting APIs/Applications/API Products in
- ### Building
`cd` into `product-apim-tooling/import-export-cli`

Execute `./build.sh -t apictl.go -v 4.0.2 -f` to build for all platforms.
Execute `./build.sh -t apictl.go -v 4.0.3 -f` to build for all platforms.

Created packages will be available at `build/target` directory

Expand Down
9 changes: 5 additions & 4 deletions import-export-cli/impl/exportAPI.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package impl

import (
"fmt"
"net/url"
"path/filepath"
"strconv"

Expand All @@ -45,7 +46,7 @@ func ExportAPIFromEnv(accessToken, name, version, revisionNum, provider, format,
func exportAPI(name, version, revisionNum, provider, format, publisherEndpoint, accessToken string, preserveStatus,
exportLatestRevision bool) (*resty.Response, error) {
publisherEndpoint = utils.AppendSlashToString(publisherEndpoint)
query := "apis/export?name=" + name + "&version=" + version + "&providerName=" + provider +
query := "apis/export?name=" + url.QueryEscape(name) + "&version=" + version + "&providerName=" + provider +
"&preserveStatus=" + strconv.FormatBool(preserveStatus)
if format != "" {
query += "&format=" + format
Expand All @@ -57,13 +58,13 @@ func exportAPI(name, version, revisionNum, provider, format, publisherEndpoint,
query += "&latestRevision=true"
}

url := publisherEndpoint + query
utils.Logln(utils.LogPrefixInfo+"ExportAPI: URL:", url)
requestURL := publisherEndpoint + query
utils.Logln(utils.LogPrefixInfo+"ExportAPI: URL:", requestURL)
headers := make(map[string]string)
headers[utils.HeaderAuthorization] = utils.HeaderValueAuthBearerPrefix + " " + accessToken
headers[utils.HeaderAccept] = utils.HeaderValueApplicationZip

resp, err := utils.InvokeGETRequest(url, headers)
resp, err := utils.InvokeGETRequest(requestURL, headers)

if err != nil {
return nil, err
Expand Down
10 changes: 5 additions & 5 deletions import-export-cli/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ rest-api-version: v2
The version of the apictl that is being integration tested.

```
apictl-version: 4.0.2
apictl-version: 4.0.3
```


Expand Down Expand Up @@ -92,7 +92,7 @@ apictl-version: 4.0.2
```
go test -p 1 -timeout 0 -archive <apictl archive name>
example: go test -p 1 -timeout 0 -archive apictl-4.0.2-linux-x64.tar.gz
example: go test -p 1 -timeout 0 -archive apictl-4.0.3-linux-x64.tar.gz
```
Expand All @@ -101,23 +101,23 @@ example: go test -p 1 -timeout 0 -archive apictl-4.0.2-linux-x64.tar.gz
```
go test -p 1 -timeout 0 -archive <apictl archive name> -run <Test function name or partial name regex>
example: go test -p 1 -timeout 0 -archive apictl-4.0.2-linux-x64.tar.gz -run TestVersion
example: go test -p 1 -timeout 0 -archive apictl-4.0.3-linux-x64.tar.gz -run TestVersion
```

- Print verbose output

```
go test -p 1 -timeout 0 -archive <apictl archive name> -v
example: go test -p 1 -timeout 0 -archive apictl-4.0.2-linux-x64.tar.gz -v
example: go test -p 1 -timeout 0 -archive apictl-4.0.3-linux-x64.tar.gz -v
```

- Print http transport request/responses

```
go test -p 1 -timeout 0 -archive <apictl archive name> -logtransport
example: go test -p 1 -timeout 0 -archive apictl-4.0.2-linux-x64.tar.gz -logtransport
example: go test -p 1 -timeout 0 -archive apictl-4.0.3-linux-x64.tar.gz -logtransport
```

---
Expand Down
2 changes: 1 addition & 1 deletion import-export-cli/integration/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ max-invocation-attempts: 10

dcr-version: v0.17
rest-api-version: v2
apictl-version: 4.0.2
apictl-version: 4.0.3

8 changes: 4 additions & 4 deletions import-export-cli/mi/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
```
go test -archive <apictl archive name>
example: go test -archive apictl-4.0.2-linux-x64.tar.gz
example: go test -archive apictl-4.0.3-linux-x64.tar.gz
```

Expand All @@ -71,21 +71,21 @@ example: go test -archive apictl-4.0.2-linux-x64.tar.gz
```
go test -archive <apictl archive name> -test.run <Test function name or partial name regex>
example: go test -archive apictl-4.0.2-linux-x64.tar.gz -test.run TestGetConnectors
example: go test -archive apictl-4.0.3-linux-x64.tar.gz -test.run TestGetConnectors
```

- Print verbose output

```
go test -archive <apictl archive name> -test.v
example: go test -archive apictl-4.0.2-linux-x64.tar.gz -test.v
example: go test -archive apictl-4.0.3-linux-x64.tar.gz -test.v
```

- Print http transport request/responses

```
go test -archive <apictl archive name> -logtransport
example: go test -archive apictl-4.0.2-linux-x64.tar.gz -logtransport
example: go test -archive apictl-4.0.3-linux-x64.tar.gz -logtransport
```

0 comments on commit 441e0c1

Please sign in to comment.