To execute as script need to add '--rpc' parameter
This commit is contained in:
parent
3c2942b31c
commit
33494ce4b7
|
@ -116,8 +116,18 @@ _aliapi_urlencode() {
|
|||
if [[ ${#BASH_SOURCE[@]} -eq 1 ]]; then
|
||||
set -euf -o pipefail
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "$0 <http_method> <host> <api_version> <api_action> [<--key> <value>...]" >&2
|
||||
echo "$(basename "$0") <--rpc> <http_method> <host> <api_version> <api_action> [<--key> <value>...]" >&2
|
||||
exit 2
|
||||
fi
|
||||
aliapi_rpc "$@"
|
||||
|
||||
case $1 in
|
||||
--rpc)
|
||||
shift
|
||||
aliapi_rpc "$@"
|
||||
;;
|
||||
*)
|
||||
echo "Aliyun OpenAPI SDK: '$1' is unknown parameter" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
aliapi_rpc <http_method> <host> <api_version> <api_action> [<--key> <value>...]
|
||||
```
|
||||
|
||||
PS: `AliyunOpenApiSDK.sh` 支持作为脚本独立执行,脚本参数与函数参数一致,作为脚本运行时,`AliAccessKeyId` 和 `AliAccessKeySecret` 变量需要导出。
|
||||
PS: `AliyunOpenApiSDK.sh` 可以作为脚本执行,脚本第一个参数为 `--rpc`,剩余参数为 `aliapi_rpc` 可接受参数。作为脚本运行时,`AliAccessKeyId` 和 `AliAccessKeySecret` 变量需要导出。
|
||||
|
||||
**示例:**
|
||||
|
||||
|
|
19
test.bats.sh
19
test.bats.sh
|
@ -99,3 +99,22 @@ test_rpc_api() { #@test
|
|||
run grep '"Key":"openapi-shell-sdk-test"' <<< "$output"
|
||||
[[ $status -eq 0 ]]
|
||||
}
|
||||
|
||||
test_cli() { #@test
|
||||
skip_no_aliaccess
|
||||
|
||||
export AliAccessKeyId AliAccessKeySecret
|
||||
|
||||
run ./AliyunOpenApiSDK.sh
|
||||
[[ $status -eq 2 ]]
|
||||
[[ $output == "AliyunOpenApiSDK.sh <--rpc> <http_method> <host> <api_version> <api_action> [<--key> <value>...]" ]]
|
||||
|
||||
run ./AliyunOpenApiSDK.sh --cpr
|
||||
[[ $status -eq 2 ]]
|
||||
[[ $output == "Aliyun OpenAPI SDK: '--cpr' is unknown parameter" ]]
|
||||
|
||||
run ./AliyunOpenApiSDK.sh --rpc GET sts.aliyuncs.com 2015-04-01 GetCallerIdentity
|
||||
[[ $status -eq 0 ]]
|
||||
run grep "user/aliyun-openapi-shell-sdk-test" <<< "$output"
|
||||
[[ $status -eq 0 ]]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue