test: parameters, PutObjectLegalHold tests

This commit is contained in:
Luke McCrone
2025-06-12 16:07:31 -03:00
parent 7e5695f63b
commit 97dd0a92bc
12 changed files with 95 additions and 43 deletions
+4 -4
View File
@@ -28,11 +28,10 @@ version_id="$VERSION_ID"
current_date_time=$(date -u +"%Y%m%dT%H%M%SZ")
canonical_request_data=("GET" "/$bucket_name/$key")
queries=""
queries="legal-hold="
if [ "$version_id" != "" ]; then
queries=$(add_parameter "$queries" "versionId=$version_id")
fi
queries=$(add_parameter "$queries" "legal-hold=")
canonical_request_data+=("$queries" "host:$host")
canonical_request_data+=("x-amz-content-sha256:UNSIGNED-PAYLOAD" "x-amz-date:$current_date_time")
if ! build_canonical_request "${canonical_request_data[@]}"; then
@@ -42,9 +41,10 @@ fi
# shellcheck disable=SC2119
create_canonical_hash_sts_and_signature
log_rest 5 "cr data: $canonical_request"
curl_command+=(curl -ks -w "\"%{http_code}\"" "\"$AWS_ENDPOINT_URL/$bucket_name/$key?$queries\""
-H "\"Authorization: AWS4-HMAC-SHA256 Credential=$aws_access_key_id/$year_month_day/$aws_region/s3/aws4_request,SignedHeaders=$param_list,Signature=$signature\"")
curl_command+=(curl -ks -w "\"%{http_code}\"" "\"$AWS_ENDPOINT_URL/$bucket_name/$key?$queries\"")
curl_command+=(-H "\"Authorization: AWS4-HMAC-SHA256 Credential=$aws_access_key_id/$year_month_day/$aws_region/s3/aws4_request,SignedHeaders=$param_list,Signature=$signature\"")
curl_command+=("${header_fields[@]}")
curl_command+=(-o "$OUTPUT_FILE")
# shellcheck disable=SC2154
+10 -17
View File
@@ -31,11 +31,7 @@ fi
current_date_time=$(date -u +"%Y%m%dT%H%M%SZ")
#x-amz-object-attributes:ETag
canonical_request="GET
/$bucket_name
"
canonical_request_data=("GET" "/$bucket_name")
queries=""
if [ "$MARKER" != "" ]; then
queries=$(add_parameter "$queries" "marker=$marker")
@@ -49,14 +45,12 @@ fi
if [ "$max_keys" -ne 0 ]; then
queries=$(add_parameter "$queries" "max-keys=$max_keys")
fi
canonical_request+="
host:$host
x-amz-content-sha256:UNSIGNED-PAYLOAD
x-amz-date:$current_date_time
host;x-amz-content-sha256;x-amz-date
UNSIGNED-PAYLOAD"
canonical_request_data+=("$queries" "host:$host")
canonical_request_data+=("x-amz-content-sha256:UNSIGNED-PAYLOAD" "x-amz-date:$current_date_time")
if ! build_canonical_request "${canonical_request_data[@]}"; then
log_rest 2 "error building request"
exit 1
fi
# shellcheck disable=SC2119
create_canonical_hash_sts_and_signature
@@ -68,9 +62,8 @@ if [ "$queries" != "" ]; then
fi
url+="'"
curl_command+=("$url")
curl_command+=(-H "\"Authorization: AWS4-HMAC-SHA256 Credential=$aws_access_key_id/$year_month_day/$aws_region/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=$signature\""
-H "\"x-amz-content-sha256: UNSIGNED-PAYLOAD\""
-H "\"x-amz-date: $current_date_time\""
-o "$OUTPUT_FILE")
curl_command+=(-H "\"Authorization: AWS4-HMAC-SHA256 Credential=$aws_access_key_id/$year_month_day/$aws_region/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=$signature\"")
curl_command+=("${header_fields[@]}")
curl_command+=(-o "$OUTPUT_FILE")
# shellcheck disable=SC2154
eval "${curl_command[*]}" 2>&1
+12 -4
View File
@@ -28,6 +28,8 @@ status="$STATUS"
omit_payload="${OMIT_PAYLOAD:=false}"
# shellcheck disable=SC2153
version_id="$VERSION_ID"
# shellcheck disable=SC2153
omit_content_md5="${OMIT_CONTENT_MD5:=false}"
if [ "$omit_payload" == "false" ]; then
payload="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
@@ -39,15 +41,21 @@ else
fi
payload_hash="$(echo -n "$payload" | sha256sum | awk '{print $1}')"
if [ "$omit_content_md5" == "false" ]; then
content_md5=$(echo -n "$payload" | openssl dgst -binary -md5 | openssl base64)
fi
current_date_time=$(date -u +"%Y%m%dT%H%M%SZ")
canonical_request_data=("PUT" "/$bucket_name/$key")
queries=""
queries="legal-hold="
if [ "$version_id" != "" ]; then
queries=$(add_parameter "$queries" "versionId=$version_id")
fi
queries=$(add_parameter "$queries" "legal-hold=")
canonical_request_data+=("$queries" "host:$host")
canonical_request_data+=("$queries")
if [ "$omit_content_md5" == "false" ]; then
canonical_request_data+=("content-md5:$content_md5")
fi
canonical_request_data+=("host:$host")
canonical_request_data+=("x-amz-content-sha256:$payload_hash" "x-amz-date:$current_date_time")
if ! build_canonical_request "${canonical_request_data[@]}"; then
log_rest 2 "error building request"
@@ -57,7 +65,7 @@ fi
# shellcheck disable=SC2119
create_canonical_hash_sts_and_signature
curl_command+=(curl -ks -w "\"%{http_code}\"" -X PUT "$AWS_ENDPOINT_URL/$bucket_name/$key?$queries"
curl_command+=(curl -ks -w "\"%{http_code}\"" -X PUT "\"$AWS_ENDPOINT_URL/$bucket_name/$key?$queries\""
-H "\"Authorization: AWS4-HMAC-SHA256 Credential=$aws_access_key_id/$year_month_day/$aws_region/s3/aws4_request,SignedHeaders=$param_list,Signature=$signature\"")
curl_command+=("${header_fields[@]}")
if [ "$omit_payload" == "false" ]; then