test: PutObject/ListObjects/GetObject/HeadObject encodings

This commit is contained in:
Luke McCrone
2025-07-01 17:52:19 -03:00
parent 8e5b7ead92
commit 1c08eaadcd
27 changed files with 495 additions and 343 deletions
+4 -3
View File
@@ -21,7 +21,7 @@ source ./tests/rest_scripts/rest.sh
# shellcheck disable=SC2153
bucket_name="$BUCKET_NAME"
# shellcheck disable=SC2153
key="$OBJECT_KEY"
key="$(echo -n "$OBJECT_KEY" | jq -sRr 'split("/") | map(@uri) | join("/")')"
# shellcheck disable=SC2153
checksum_mode="${CHECKSUM_MODE:=false}"
# shellcheck disable=SC2153
@@ -44,9 +44,10 @@ build_canonical_request "${canonical_request_data[@]}"
# shellcheck disable=SC2119
create_canonical_hash_sts_and_signature
curl_command+=(curl -ks -w "\"%{http_code}\"" "$AWS_ENDPOINT_URL/$bucket_name/$key"
output_file_esc="$(echo -n "$OUTPUT_FILE" | sed -e 's/[][`"$^]/\\&/g')"
curl_command+=(curl -ks -w "\"%{http_code}\"" "\"$AWS_ENDPOINT_URL/$bucket_name/$key\""
-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")
curl_command+=(-o "\"$output_file_esc\"")
# shellcheck disable=SC2154
eval "${curl_command[*]}" 2>&1
+1 -1
View File
@@ -21,7 +21,7 @@ source ./tests/rest_scripts/rest.sh
# shellcheck disable=SC2153
bucket_name="$BUCKET_NAME"
# shellcheck disable=SC2154
key="$OBJECT_KEY"
key="$(echo -n "$OBJECT_KEY" | jq -sRr 'split("/") | map(@uri) | join("/")')"
# shellcheck disable=SC2153
version_id="$VERSION_ID"
+8 -4
View File
@@ -23,7 +23,7 @@ data_file="$DATA_FILE"
# shellcheck disable=SC2153
bucket_name="$BUCKET_NAME"
# shellcheck disable=SC2153
key="$OBJECT_KEY"
key="$(echo -n "$OBJECT_KEY" | jq -sRr 'split("/") | map(@uri) | join("/")')"
# shellcheck disable=SC2153,SC2154
checksum_type="$CHECKSUM_TYPE"
# shellcheck disable=SC2153
@@ -38,8 +38,10 @@ checksum_hash="$CHECKSUM"
fake_signature="$SIGNATURE"
current_date_time=$(date -u +"%Y%m%dT%H%M%SZ")
data_file_esc="$(echo -n "$data_file" | sed -e 's/[][`"$^{}]/\\&/g')"
log_rest 5 "sha256sum: $(sha256sum "$data_file")"
if [ "$payload" == "" ]; then
payload_hash="$(sha256sum "$data_file" | awk '{print $1}')"
payload_hash="$(sha256sum "$data_file" | awk '{print $1}' | sed 's/\\//g' )"
else
payload_hash="$payload"
fi
@@ -66,9 +68,11 @@ if [ "$fake_signature" != "" ]; then
signature="$fake_signature"
fi
curl_command+=(curl -ks -w "\"%{http_code}\"" -X PUT "$AWS_ENDPOINT_URL/$bucket_name/$key")
curl_command+=(curl -ks -w "\"%{http_code}\"" -X PUT "\"$AWS_ENDPOINT_URL/$bucket_name/$key\"")
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+=(-T "$data_file" -o "$OUTPUT_FILE")
curl_command+=(-T "\"$data_file_esc\"" -o "$OUTPUT_FILE")
# shellcheck disable=SC2154
log_rest 5 "curl command: ${curl_command[*]}"
eval "${curl_command[*]}" 2>&1
@@ -55,6 +55,8 @@ load_parameters() {
trailer="$TRAILER"
# shellcheck disable=SC2153
checksum="$CHECKSUM"
# shellcheck disable=SC2153
invalid_checksum_type="${INVALID_CHECKSUM_TYPE:=false}"
fi
readonly initial_sts_data="AWS4-HMAC-SHA256-PAYLOAD
@@ -152,7 +154,7 @@ get_file_size_and_content_length() {
calculate_checksum() {
checksum_type="${trailer/x-amz-checksum-/}"
log_rest 5 "checksum type: $checksum_type"
if [ "$CHECKSUM" == "" ]; then
if [ "$CHECKSUM" == "" ] && [ "$invalid_checksum_type" != "true" ]; then
if ! checksum=$(DATA_FILE="$data_file" CHECKSUM_TYPE="$checksum_type" ./tests/rest_scripts/calculate_checksum.sh 2>&1); then
log_rest 2 "error getting checksum: $checksum"
return 1