Minor changes

This commit is contained in:
Zhong Lufan 2023-01-30 23:54:15 +08:00
parent 92c24f3528
commit 7e24386e51
No known key found for this signature in database
GPG Key ID: BE2B3A1E76AD7D04
3 changed files with 13 additions and 12 deletions

View File

@ -62,7 +62,7 @@ aliapi_rpc() {
_query_str+="Signature=$(_aliapi_urlencode "$_signature")"
local _curl_out _http_url="https://$_http_host/?$_query_str"
_curl_out=$(curl --location --silent --show-error --request "$_http_method" --write-out "%{http_code}" --connect-timeout 3 "$_http_url")
printf "%s" "${_curl_out:0:-3}"
printf %s "${_curl_out:0:-3}"
ALIYUN_SDK_LAST_HTTP_CODE=${_curl_out:${#_curl_out}-3}
[[ $ALIYUN_SDK_LAST_HTTP_CODE -eq 200 ]] && return 0 || return 1
}
@ -82,8 +82,8 @@ _aliapi_signature_rpc() {
local -u _http_method=$1
local _str=$2 _query_str _sign_str
local _newline='
'
local _newline="
"
_str=$(sort <<< "${_str//"&"/"$_newline"}")
_query_str=${_str//"$_newline"/"&"}
_sign_str="$_http_method&$(_aliapi_urlencode "/")&$(_aliapi_urlencode "$_query_str")"
@ -100,7 +100,7 @@ _aliapi_signature_nonce() {
if [[ -f /proc/sys/kernel/random/uuid ]]; then
nonce=$(</proc/sys/kernel/random/uuid)
else
nonce=$(date "+%s%N")
nonce=$(date +%s%N)
fi
echo "$RANDOM${nonce//-/}$RANDOM"
}
@ -117,12 +117,12 @@ _aliapi_urlencode() {
case $char in
[-._~0-9A-Za-z]) printf %c "$char";;
*)
if [[ _ALIYUN_SDK_RUN_ON_MUSL_LIBC -eq 1 ]]; then
if [[ ALIYUN_SDK_RUN_ON_MUSL_LIBC -eq 0 ]]; then
printf %%%02X "'$char"
else
# Hack musl libc for not ASCII chars (incomplete test)
hex=$(printf %02X "'$char")
printf %%%s "${hex:${#hex}-2}"
else
printf %%%02X "'$char"
fi
;;
esac

View File

@ -9,7 +9,7 @@
AliAccessKeyId="<AliAccessKeyId>"
AliAccessKeySecret="<AliAccessKeySecret>"
# shellcheck disable=SC1091
# shellcheck source=AliyunOpenApiSDK.sh
source ../AliyunOpenApiSDK.sh
# acme.sh 执行 renewHook 时导出的环境变量列表

View File

@ -2,6 +2,7 @@
# shellcheck shell=bash disable=SC2154
setup() {
# shellcheck disable=SC1091
[[ -f .env.test ]] && source .env.test
source AliyunOpenApiSDK.sh
}
@ -69,6 +70,10 @@ test_check_vars() { #@test
[[ $status -eq 0 ]]
}
getQueryType() {
echo MetaTag
}
test_rpc_api() { #@test
skip_no_aliaccess
@ -89,10 +94,6 @@ test_rpc_api() { #@test
run grep "user/aliyun-openapi-shell-sdk-test" <<< "$output"
[[ $status -eq 0 ]]
getQueryType() {
echo MetaTag
}
run aliapi_rpc GET tag.aliyuncs.com 2018-08-28 ListTagKeys --RegionId cn-hangzhou --QueryType "getQueryType()"
[[ $status -eq 0 ]]
run grep '"Key":"openapi-shell-sdk-test"' <<< "$output"