mirror of
https://github.com/versity/versitygw.git
synced 2026-09-03 22:56:55 +00:00
test: expires header test
This commit is contained in:
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2024 Versity Software
|
||||
# This file is licensed under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http:#www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
source ./tests/rest_scripts/rest.sh
|
||||
|
||||
# Fields
|
||||
|
||||
# shellcheck disable=SC2153
|
||||
bucket_name="$BUCKET_NAME"
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
current_date_time=$(date -u +"%Y%m%dT%H%M%SZ")
|
||||
|
||||
canonical_request_data=("HEAD" "/$bucket_name" "" "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
|
||||
|
||||
curl_command+=(curl -ksI -w "\"%{http_code}\"" "$AWS_ENDPOINT_URL/$bucket_name"
|
||||
-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
|
||||
eval "${curl_command[*]}" 2>&1
|
||||
@@ -28,6 +28,8 @@ key="$OBJECT_KEY"
|
||||
checksum_type="$CHECKSUM_TYPE"
|
||||
# shellcheck disable=SC2153
|
||||
payload="$PAYLOAD"
|
||||
# shellcheck disable=SC2153
|
||||
expires="$EXPIRES"
|
||||
|
||||
# use this parameter to check incorrect checksums
|
||||
# shellcheck disable=SC2153,SC2154
|
||||
@@ -40,7 +42,11 @@ else
|
||||
payload_hash="$payload"
|
||||
fi
|
||||
|
||||
cr_data=("PUT" "/$bucket_name/$key" "" "host:$host")
|
||||
cr_data=("PUT" "/$bucket_name/$key" "")
|
||||
if [ -n "$expires" ]; then
|
||||
cr_data+=("expires:$expires")
|
||||
fi
|
||||
cr_data+=("host:$host")
|
||||
if [ "$checksum_type" == "sha256" ]; then
|
||||
if [ -z "$checksum_hash" ]; then
|
||||
checksum_hash="$(sha256sum "$data_file" | awk '{print $1}' | xxd -r -p | base64)"
|
||||
|
||||
Reference in New Issue
Block a user