From 0f2c727990b4412f8d5d6c9cd44a6c5da894b233 Mon Sep 17 00:00:00 2001 From: Luke McCrone Date: Wed, 20 Nov 2024 14:19:05 +0100 Subject: [PATCH] test: GetBucketPolicy - test w/o policy --- tests/commands/copy_object.sh | 2 +- tests/commands/create_bucket.sh | 2 +- tests/commands/create_presigned_url.sh | 2 +- tests/commands/delete_bucket.sh | 2 +- tests/commands/delete_bucket_policy.sh | 2 +- tests/commands/delete_bucket_tagging.sh | 2 +- tests/commands/delete_object.sh | 2 +- tests/commands/delete_object_tagging.sh | 2 +- tests/commands/get_bucket_acl.sh | 2 +- tests/commands/get_bucket_location.sh | 2 +- tests/commands/get_bucket_policy.sh | 2 +- tests/commands/get_bucket_tagging.sh | 2 +- tests/commands/get_object.sh | 2 +- tests/commands/get_object_tagging.sh | 2 +- tests/commands/head_bucket.sh | 2 +- tests/commands/head_object.sh | 2 +- tests/commands/list_buckets.sh | 2 +- tests/commands/list_objects.sh | 4 +- tests/commands/put_bucket_acl.sh | 2 +- tests/commands/put_bucket_policy.sh | 2 +- tests/commands/put_bucket_tagging.sh | 2 +- tests/commands/put_object.sh | 2 +- tests/commands/put_object_tagging.sh | 2 +- tests/remove_static.sh | 2 +- tests/rest_scripts/get_bucket_policy.sh | 43 +++++ tests/setup.sh | 2 +- tests/setup_static.sh | 2 +- tests/teardown_static.sh | 2 +- tests/test_common.sh | 14 +- tests/test_common_acl.sh | 8 +- tests/test_mc.sh | 6 +- tests/test_rest.sh | 37 ++-- tests/test_s3.sh | 2 +- tests/test_s3_file_count.sh | 2 +- tests/test_s3api_bucket.sh | 50 +++-- tests/test_s3api_multipart.sh | 123 ++++++++++-- tests/test_s3api_object.sh | 71 ++++--- tests/test_s3api_policy.sh | 10 +- tests/test_s3api_policy_bucket.sh | 2 +- ...root_inner.sh => test_s3api_root_inner.sh} | 181 ++---------------- tests/test_s3cmd.sh | 6 +- tests/test_user_aws.sh | 2 +- tests/test_user_common.sh | 34 ++-- tests/{ => util}/util.sh | 20 +- tests/{ => util}/util_acl.sh | 1 + tests/{ => util}/util_attributes.sh | 0 tests/{ => util}/util_aws.sh | 0 tests/{ => util}/util_bucket.sh | 6 +- tests/{ => util}/util_bucket_location.sh | 0 tests/{ => util}/util_config.sh | 0 tests/{ => util}/util_create_bucket.sh | 2 +- tests/{ => util}/util_file.sh | 0 tests/{ => util}/util_get_bucket_acl.sh | 0 .../{ => util}/util_get_object_attributes.sh | 0 tests/{ => util}/util_get_object_retention.sh | 0 tests/{ => util}/util_head_bucket.sh | 0 tests/{ => util}/util_head_object.sh | 0 tests/{ => util}/util_legal_hold.sh | 0 tests/{ => util}/util_list_buckets.sh | 0 tests/{ => util}/util_list_objects.sh | 0 tests/{ => util}/util_list_parts.sh | 0 tests/{ => util}/util_lock_config.sh | 0 tests/{ => util}/util_mc.sh | 0 tests/{ => util}/util_multipart.sh | 0 tests/{ => util}/util_ownership.sh | 0 tests/{ => util}/util_policy.sh | 25 +++ tests/{ => util}/util_presigned_url.sh | 0 tests/{ => util}/util_rest.sh | 0 tests/{ => util}/util_tags.sh | 0 tests/{ => util}/util_time.sh | 0 tests/{ => util}/util_users.sh | 0 tests/{ => util}/util_versioning.sh | 0 tests/versity.sh | 2 +- 73 files changed, 375 insertions(+), 328 deletions(-) create mode 100755 tests/rest_scripts/get_bucket_policy.sh rename tests/{test_aws_root_inner.sh => test_s3api_root_inner.sh} (62%) rename tests/{ => util}/util.sh (97%) rename tests/{ => util}/util_acl.sh (99%) rename tests/{ => util}/util_attributes.sh (100%) rename tests/{ => util}/util_aws.sh (100%) rename tests/{ => util}/util_bucket.sh (98%) rename tests/{ => util}/util_bucket_location.sh (100%) rename tests/{ => util}/util_config.sh (100%) rename tests/{ => util}/util_create_bucket.sh (98%) rename tests/{ => util}/util_file.sh (100%) rename tests/{ => util}/util_get_bucket_acl.sh (100%) rename tests/{ => util}/util_get_object_attributes.sh (100%) rename tests/{ => util}/util_get_object_retention.sh (100%) rename tests/{ => util}/util_head_bucket.sh (100%) rename tests/{ => util}/util_head_object.sh (100%) rename tests/{ => util}/util_legal_hold.sh (100%) rename tests/{ => util}/util_list_buckets.sh (100%) rename tests/{ => util}/util_list_objects.sh (100%) rename tests/{ => util}/util_list_parts.sh (100%) rename tests/{ => util}/util_lock_config.sh (100%) rename tests/{ => util}/util_mc.sh (100%) rename tests/{ => util}/util_multipart.sh (100%) rename tests/{ => util}/util_ownership.sh (100%) rename tests/{ => util}/util_policy.sh (87%) rename tests/{ => util}/util_presigned_url.sh (100%) rename tests/{ => util}/util_rest.sh (100%) rename tests/{ => util}/util_tags.sh (100%) rename tests/{ => util}/util_time.sh (100%) rename tests/{ => util}/util_users.sh (100%) rename tests/{ => util}/util_versioning.sh (100%) diff --git a/tests/commands/copy_object.sh b/tests/commands/copy_object.sh index 57c8a0fb..871cc900 100644 --- a/tests/commands/copy_object.sh +++ b/tests/commands/copy_object.sh @@ -24,7 +24,7 @@ copy_object() { record_command "copy-object" "client:$1" if [[ $1 == 's3' ]]; then error=$(send_command aws --no-verify-ssl s3 cp "$2" s3://"$3/$4" 2>&1) || exit_code=$? - elif [[ $1 == 's3api' ]] || [[ $1 == 'aws' ]]; then + elif [[ $1 == 's3api' ]]; then error=$(send_command aws --no-verify-ssl s3api copy-object --copy-source "$2" --bucket "$3" --key "$4" 2>&1) || exit_code=$? elif [[ $1 == 's3cmd' ]]; then log 5 "s3cmd ${S3CMD_OPTS[*]} --no-check-certificate cp s3://$2 s3://$3/$4" diff --git a/tests/commands/create_bucket.sh b/tests/commands/create_bucket.sh index 46354710..99c173cc 100644 --- a/tests/commands/create_bucket.sh +++ b/tests/commands/create_bucket.sh @@ -31,7 +31,7 @@ create_bucket() { log 6 "create bucket" if [[ $1 == 's3' ]]; then error=$(send_command aws --no-verify-ssl s3 mb s3://"$2" 2>&1) || exit_code=$? - elif [[ $1 == "aws" ]] || [[ $1 == 's3api' ]]; then + elif [[ $1 == 's3api' ]]; then error=$(send_command aws --no-verify-ssl s3api create-bucket --bucket "$2" 2>&1) || exit_code=$? elif [[ $1 == "s3cmd" ]]; then log 5 "s3cmd ${S3CMD_OPTS[*]} --no-check-certificate mb s3://$2" diff --git a/tests/commands/create_presigned_url.sh b/tests/commands/create_presigned_url.sh index c0d0ffd9..3ebab08d 100644 --- a/tests/commands/create_presigned_url.sh +++ b/tests/commands/create_presigned_url.sh @@ -7,7 +7,7 @@ create_presigned_url() { fi local presign_result=0 - if [[ $1 == 'aws' ]]; then + if [[ $1 == 's3api' ]]; then presigned_url=$(send_command aws s3 presign "s3://$2/$3" --expires-in 900) || presign_result=$? elif [[ $1 == 's3cmd' ]]; then presigned_url=$(send_command s3cmd --no-check-certificate "${S3CMD_OPTS[@]}" signurl "s3://$2/$3" "$(echo "$(date +%s)" + 900 | bc)") || presign_result=$? diff --git a/tests/commands/delete_bucket.sh b/tests/commands/delete_bucket.sh index 60374d30..048f89a9 100644 --- a/tests/commands/delete_bucket.sh +++ b/tests/commands/delete_bucket.sh @@ -32,7 +32,7 @@ delete_bucket() { exit_code=0 if [[ $1 == 's3' ]]; then error=$(send_command aws --no-verify-ssl s3 rb s3://"$2") || exit_code=$? - elif [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then + elif [[ $1 == 's3api' ]]; then error=$(send_command aws --no-verify-ssl s3api delete-bucket --bucket "$2" 2>&1) || exit_code=$? elif [[ $1 == 's3cmd' ]]; then error=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate rb s3://"$2" 2>&1) || exit_code=$? diff --git a/tests/commands/delete_bucket_policy.sh b/tests/commands/delete_bucket_policy.sh index 643fef3a..6939910f 100644 --- a/tests/commands/delete_bucket_policy.sh +++ b/tests/commands/delete_bucket_policy.sh @@ -21,7 +21,7 @@ delete_bucket_policy() { return 1 fi local delete_result=0 - if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then + if [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then error=$(send_command aws --no-verify-ssl s3api delete-bucket-policy --bucket "$2" 2>&1) || delete_result=$? elif [[ $1 == 's3cmd' ]]; then error=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate delpolicy "s3://$2" 2>&1) || delete_result=$? diff --git a/tests/commands/delete_bucket_tagging.sh b/tests/commands/delete_bucket_tagging.sh index 7a28622b..b1301eaa 100644 --- a/tests/commands/delete_bucket_tagging.sh +++ b/tests/commands/delete_bucket_tagging.sh @@ -21,7 +21,7 @@ delete_bucket_tagging() { return 1 fi local result - if [[ $1 == 'aws' ]]; then + if [[ $1 == 's3api' ]]; then tags=$(send_command aws --no-verify-ssl s3api delete-bucket-tagging --bucket "$2" 2>&1) || result=$? elif [[ $1 == 'mc' ]]; then tags=$(send_command mc --insecure tag remove "$MC_ALIAS"/"$2" 2>&1) || result=$? diff --git a/tests/commands/delete_object.sh b/tests/commands/delete_object.sh index 5601ad6f..d50aa8d6 100644 --- a/tests/commands/delete_object.sh +++ b/tests/commands/delete_object.sh @@ -25,7 +25,7 @@ delete_object() { local exit_code=0 if [[ $1 == 's3' ]]; then delete_object_error=$(send_command aws --no-verify-ssl s3 rm "s3://$2/$3" 2>&1) || exit_code=$? - elif [[ $1 == 's3api' ]] || [[ $1 == 'aws' ]]; then + elif [[ $1 == 's3api' ]]; then delete_object_error=$(send_command aws --no-verify-ssl s3api delete-object --bucket "$2" --key "$3" 2>&1) || exit_code=$? elif [[ $1 == 's3cmd' ]]; then delete_object_error=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate rm "s3://$2/$3" 2>&1) || exit_code=$? diff --git a/tests/commands/delete_object_tagging.sh b/tests/commands/delete_object_tagging.sh index f59f7109..5473e309 100644 --- a/tests/commands/delete_object_tagging.sh +++ b/tests/commands/delete_object_tagging.sh @@ -21,7 +21,7 @@ delete_object_tagging() { return 1 fi delete_result=0 - if [[ $1 == 'aws' ]]; then + if [[ $1 == 's3api' ]]; then error=$(send_command aws --no-verify-ssl s3api delete-object-tagging --bucket "$2" --key "$3" 2>&1) || delete_result=$? elif [[ $1 == 'mc' ]]; then error=$(send_command mc --insecure tag remove "$MC_ALIAS/$2/$3") || delete_result=$? diff --git a/tests/commands/get_bucket_acl.sh b/tests/commands/get_bucket_acl.sh index 8f86a6e8..4c2e28c9 100644 --- a/tests/commands/get_bucket_acl.sh +++ b/tests/commands/get_bucket_acl.sh @@ -21,7 +21,7 @@ get_bucket_acl() { return 1 fi local exit_code=0 - if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then + if [[ $1 == 's3api' ]]; then acl=$(send_command aws --no-verify-ssl s3api get-bucket-acl --bucket "$2" 2>&1) || exit_code="$?" elif [[ $1 == 's3cmd' ]]; then acl=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate info "s3://$2" 2>&1) || exit_code="$?" diff --git a/tests/commands/get_bucket_location.sh b/tests/commands/get_bucket_location.sh index cff0e672..c106284d 100644 --- a/tests/commands/get_bucket_location.sh +++ b/tests/commands/get_bucket_location.sh @@ -21,7 +21,7 @@ get_bucket_location() { return 1 fi get_result=0 - if [[ $1 == 'aws' ]]; then + if [[ $1 == 's3api' ]]; then get_bucket_location_aws "$2" || get_result=$? elif [[ $1 == 's3cmd' ]]; then get_bucket_location_s3cmd "$2" || get_result=$? diff --git a/tests/commands/get_bucket_policy.sh b/tests/commands/get_bucket_policy.sh index 42aebf8c..fc122bc6 100644 --- a/tests/commands/get_bucket_policy.sh +++ b/tests/commands/get_bucket_policy.sh @@ -21,7 +21,7 @@ get_bucket_policy() { return 1 fi local get_bucket_policy_result=0 - if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then + if [[ $1 == 's3api' ]]; then get_bucket_policy_aws "$2" || get_bucket_policy_result=$? elif [[ $1 == 's3cmd' ]]; then get_bucket_policy_s3cmd "$2" || get_bucket_policy_result=$? diff --git a/tests/commands/get_bucket_tagging.sh b/tests/commands/get_bucket_tagging.sh index ae55b1e1..eda69afb 100644 --- a/tests/commands/get_bucket_tagging.sh +++ b/tests/commands/get_bucket_tagging.sh @@ -21,7 +21,7 @@ get_bucket_tagging() { assert [ $# -eq 2 ] record_command "get-bucket-tagging" "client:$1" local result - if [[ $1 == 'aws' ]]; then + if [[ $1 == 's3api' ]]; then tags=$(send_command aws --no-verify-ssl s3api get-bucket-tagging --bucket "$2" 2>&1) || result=$? elif [[ $1 == 'mc' ]]; then tags=$(send_command mc --insecure tag list "$MC_ALIAS"/"$2" 2>&1) || result=$? diff --git a/tests/commands/get_object.sh b/tests/commands/get_object.sh index ae6be41f..9eb12ceb 100644 --- a/tests/commands/get_object.sh +++ b/tests/commands/get_object.sh @@ -24,7 +24,7 @@ get_object() { local exit_code=0 if [[ $1 == 's3' ]]; then get_object_error=$(send_command aws --no-verify-ssl s3 mv "s3://$2/$3" "$4" 2>&1) || exit_code=$? - elif [[ $1 == 's3api' ]] || [[ $1 == 'aws' ]]; then + elif [[ $1 == 's3api' ]]; then get_object_error=$(send_command aws --no-verify-ssl s3api get-object --bucket "$2" --key "$3" "$4" 2>&1) || exit_code=$? elif [[ $1 == 's3cmd' ]]; then get_object_error=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate get "s3://$2/$3" "$4" 2>&1) || exit_code=$? diff --git a/tests/commands/get_object_tagging.sh b/tests/commands/get_object_tagging.sh index 5c6e41ca..3df51ec5 100644 --- a/tests/commands/get_object_tagging.sh +++ b/tests/commands/get_object_tagging.sh @@ -21,7 +21,7 @@ get_object_tagging() { return 1 fi local result - if [[ "$1" == 'aws' ]] || [[ $1 == 's3api' ]]; then + if [[ $1 == 's3api' ]]; then tags=$(send_command aws --no-verify-ssl s3api get-object-tagging --bucket "$2" --key "$3" 2>&1) || result=$? elif [[ "$1" == 'mc' ]]; then tags=$(send_command mc --insecure tag list "$MC_ALIAS"/"$2"/"$3" 2>&1) || result=$? diff --git a/tests/commands/head_bucket.sh b/tests/commands/head_bucket.sh index 0531f2ab..c231483e 100644 --- a/tests/commands/head_bucket.sh +++ b/tests/commands/head_bucket.sh @@ -29,7 +29,7 @@ head_bucket() { return 1 fi local exit_code=0 - if [[ $1 == "aws" ]] || [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then + if [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then bucket_info=$(send_command aws --no-verify-ssl s3api head-bucket --bucket "$2" 2>&1) || exit_code=$? elif [[ $1 == "s3cmd" ]]; then bucket_info=$(send_command s3cmd --no-check-certificate info "s3://$2" 2>&1) || exit_code=$? diff --git a/tests/commands/head_object.sh b/tests/commands/head_object.sh index 16a9bf6b..2a797429 100644 --- a/tests/commands/head_object.sh +++ b/tests/commands/head_object.sh @@ -21,7 +21,7 @@ head_object() { return 2 fi local exit_code=0 - if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then + if [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then metadata=$(send_command aws --no-verify-ssl s3api head-object --bucket "$2" --key "$3" 2>&1) || exit_code="$?" elif [[ $1 == 's3cmd' ]]; then metadata=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate info s3://"$2/$3" 2>&1) || exit_code="$?" diff --git a/tests/commands/list_buckets.sh b/tests/commands/list_buckets.sh index 9c57ac94..d94957c1 100644 --- a/tests/commands/list_buckets.sh +++ b/tests/commands/list_buckets.sh @@ -25,7 +25,7 @@ list_buckets() { local exit_code=0 if [[ $1 == 's3' ]]; then buckets=$(send_command aws --no-verify-ssl s3 ls 2>&1 s3://) || exit_code=$? - elif [[ $1 == 's3api' ]] || [[ $1 == 'aws' ]]; then + elif [[ $1 == 's3api' ]]; then list_buckets_s3api "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" || exit_code=$? elif [[ $1 == 's3cmd' ]]; then buckets=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate ls s3:// 2>&1) || exit_code=$? diff --git a/tests/commands/list_objects.sh b/tests/commands/list_objects.sh index 61ffe570..3b09f90b 100644 --- a/tests/commands/list_objects.sh +++ b/tests/commands/list_objects.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -source ./tests/util_list_objects.sh +source ./tests/util/util_list_objects.sh source ./tests/commands/command.sh # Copyright 2024 Versity Software @@ -29,7 +29,7 @@ list_objects() { local output local result=0 - if [[ $1 == "aws" ]] || [[ $1 == 's3' ]]; then + if [[ $1 == 's3' ]]; then output=$(send_command aws --no-verify-ssl s3 ls s3://"$2" 2>&1) || result=$? elif [[ $1 == 's3api' ]]; then list_objects_s3api "$2" || result=$? diff --git a/tests/commands/put_bucket_acl.sh b/tests/commands/put_bucket_acl.sh index ba303c7a..d26ecbf8 100644 --- a/tests/commands/put_bucket_acl.sh +++ b/tests/commands/put_bucket_acl.sh @@ -14,7 +14,7 @@ # specific language governing permissions and limitations # under the License. -source ./tests/util_file.sh +source ./tests/util/util_file.sh source ./tests/commands/command.sh put_bucket_acl_s3api() { diff --git a/tests/commands/put_bucket_policy.sh b/tests/commands/put_bucket_policy.sh index 457b1612..593f5681 100644 --- a/tests/commands/put_bucket_policy.sh +++ b/tests/commands/put_bucket_policy.sh @@ -21,7 +21,7 @@ put_bucket_policy() { return 1 fi local put_policy_result=0 - if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then + if [[ $1 == 's3api' ]]; then policy=$(send_command aws --no-verify-ssl s3api put-bucket-policy --bucket "$2" --policy "file://$3" 2>&1) || put_policy_result=$? elif [[ $1 == 's3cmd' ]]; then policy=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate setpolicy "$3" "s3://$2" 2>&1) || put_policy_result=$? diff --git a/tests/commands/put_bucket_tagging.sh b/tests/commands/put_bucket_tagging.sh index a5e31cf6..95581812 100644 --- a/tests/commands/put_bucket_tagging.sh +++ b/tests/commands/put_bucket_tagging.sh @@ -23,7 +23,7 @@ put_bucket_tagging() { local error local result=0 record_command "put-bucket-tagging" "client:$1" - if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then + if [[ $1 == 's3api' ]]; then error=$(send_command aws --no-verify-ssl s3api put-bucket-tagging --bucket "$2" --tagging "TagSet=[{Key=$3,Value=$4}]") || result=$? elif [[ $1 == 'mc' ]]; then error=$(send_command mc --insecure tag set "$MC_ALIAS"/"$2" "$3=$4" 2>&1) || result=$? diff --git a/tests/commands/put_object.sh b/tests/commands/put_object.sh index bc3f54da..4c939d62 100644 --- a/tests/commands/put_object.sh +++ b/tests/commands/put_object.sh @@ -27,7 +27,7 @@ put_object() { local error if [[ $1 == 's3' ]]; then error=$(send_command aws --no-verify-ssl s3 mv "$2" s3://"$3/$4" 2>&1) || exit_code=$? - elif [[ $1 == 's3api' ]] || [[ $1 == 'aws' ]]; then + elif [[ $1 == 's3api' ]]; then error=$(send_command aws --no-verify-ssl s3api put-object --body "$2" --bucket "$3" --key "$4" 2>&1) || exit_code=$? elif [[ $1 == 's3cmd' ]]; then error=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate put "$2" s3://"$3/$4" 2>&1) || exit_code=$? diff --git a/tests/commands/put_object_tagging.sh b/tests/commands/put_object_tagging.sh index 80217d84..859a6b99 100644 --- a/tests/commands/put_object_tagging.sh +++ b/tests/commands/put_object_tagging.sh @@ -22,7 +22,7 @@ put_object_tagging() { local error local result record_command "put-object-tagging" "client:$1" - if [[ $1 == 'aws' ]]; then + if [[ $1 == 's3api' ]]; then error=$(send_command aws --no-verify-ssl s3api put-object-tagging --bucket "$2" --key "$3" --tagging "TagSet=[{Key=$4,Value=$5}]" 2>&1) || result=$? elif [[ $1 == 'mc' ]]; then error=$(send_command mc --insecure tag set "$MC_ALIAS"/"$2"/"$3" "$4=$5" 2>&1) || result=$? diff --git a/tests/remove_static.sh b/tests/remove_static.sh index 0a77255d..78d1f60e 100755 --- a/tests/remove_static.sh +++ b/tests/remove_static.sh @@ -15,7 +15,7 @@ # under the License. source ./tests/setup.sh -source ./tests/util.sh +source ./tests/util/util.sh delete_bucket_if_exists() { if [[ $# -ne 2 ]]; then diff --git a/tests/rest_scripts/get_bucket_policy.sh b/tests/rest_scripts/get_bucket_policy.sh new file mode 100755 index 00000000..185627e2 --- /dev/null +++ b/tests/rest_scripts/get_bucket_policy.sh @@ -0,0 +1,43 @@ +#!/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" + +current_date_time=$(date -u +"%Y%m%dT%H%M%SZ") + +canonical_request="GET +/$bucket_name +policy= +host:$host +x-amz-content-sha256:UNSIGNED-PAYLOAD +x-amz-date:$current_date_time + +host;x-amz-content-sha256;x-amz-date +UNSIGNED-PAYLOAD" + +create_canonical_hash_sts_and_signature + +curl_command+=(curl -ks -w "\"%{http_code}\"" "$AWS_ENDPOINT_URL/$bucket_name?policy=" +-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") +# shellcheck disable=SC2154 +eval "${curl_command[*]}" 2>&1 \ No newline at end of file diff --git a/tests/setup.sh b/tests/setup.sh index 83666e7a..4bccb727 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -20,7 +20,7 @@ load ./bats-assert/load source ./tests/env.sh source ./tests/report.sh source ./tests/setup_mc.sh -source ./tests/util.sh +source ./tests/util/util.sh source ./tests/versity.sh # bats setup function diff --git a/tests/setup_static.sh b/tests/setup_static.sh index 615f3f5a..64f65013 100755 --- a/tests/setup_static.sh +++ b/tests/setup_static.sh @@ -15,7 +15,7 @@ # under the License. source ./tests/env.sh -source ./tests/util.sh +source ./tests/util/util.sh source ./tests/commands/create_bucket.sh create_bucket_if_not_exists() { diff --git a/tests/teardown_static.sh b/tests/teardown_static.sh index 89981ff6..bef762e5 100755 --- a/tests/teardown_static.sh +++ b/tests/teardown_static.sh @@ -15,7 +15,7 @@ # under the License. source ./tests/setup.sh -source ./tests/util.sh +source ./tests/util/util.sh if ! base_setup; then log 2 "error starting versity to set up static buckets" diff --git a/tests/test_common.sh b/tests/test_common.sh index 1a3391f2..b5ce1cc3 100644 --- a/tests/test_common.sh +++ b/tests/test_common.sh @@ -15,13 +15,13 @@ # under the License. source ./tests/setup.sh -source ./tests/util.sh -source ./tests/util_acl.sh -source ./tests/util_bucket_location.sh -source ./tests/util_file.sh -source ./tests/util_list_buckets.sh -source ./tests/util_policy.sh -source ./tests/util_presigned_url.sh +source ./tests/util/util.sh +source ./tests/util/util_acl.sh +source ./tests/util/util_bucket_location.sh +source ./tests/util/util_file.sh +source ./tests/util/util_list_buckets.sh +source ./tests/util/util_policy.sh +source ./tests/util/util_presigned_url.sh source ./tests/commands/copy_object.sh source ./tests/commands/delete_bucket_tagging.sh source ./tests/commands/delete_object_tagging.sh diff --git a/tests/test_common_acl.sh b/tests/test_common_acl.sh index 7efa65c3..40741822 100644 --- a/tests/test_common_acl.sh +++ b/tests/test_common_acl.sh @@ -15,13 +15,11 @@ # under the License. test_put_bucket_acl_s3cmd() { - if [[ $DIRECT != "true" ]]; then - skip "https://github.com/versity/versitygw/issues/695" + if [ "$DIRECT" != "true" ]; then + skip "https://github.com/versity/versitygw/issues/963" fi - run setup_bucket "s3cmd" "$BUCKET_ONE_NAME" - assert_success - run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred" + run setup_bucket "s3cmd" "$BUCKET_ONE_NAME" assert_success username=$USERNAME_ONE diff --git a/tests/test_mc.sh b/tests/test_mc.sh index fb022e04..54a7fb63 100755 --- a/tests/test_mc.sh +++ b/tests/test_mc.sh @@ -16,9 +16,9 @@ source ./tests/test_common.sh source ./tests/setup.sh -source ./tests/util_create_bucket.sh -source ./tests/util_head_bucket.sh -source ./tests/util_tags.sh +source ./tests/util/util_create_bucket.sh +source ./tests/util/util_head_bucket.sh +source ./tests/util/util_tags.sh source ./tests/commands/delete_bucket_policy.sh source ./tests/commands/get_bucket_policy.sh source ./tests/commands/put_bucket_policy.sh diff --git a/tests/test_rest.sh b/tests/test_rest.sh index ddf7ba41..d2640280 100755 --- a/tests/test_rest.sh +++ b/tests/test_rest.sh @@ -28,18 +28,19 @@ source ./tests/commands/put_object_retention.sh source ./tests/commands/put_object_tagging.sh source ./tests/logger.sh source ./tests/setup.sh -source ./tests/util.sh -source ./tests/util_attributes.sh -source ./tests/util_legal_hold.sh -source ./tests/util_list_buckets.sh -source ./tests/util_list_objects.sh -source ./tests/util_list_parts.sh -source ./tests/util_lock_config.sh -source ./tests/util_ownership.sh -source ./tests/util_rest.sh -source ./tests/util_tags.sh -source ./tests/util_time.sh -source ./tests/util_versioning.sh +source ./tests/util/util.sh +source ./tests/util/util_attributes.sh +source ./tests/util/util_legal_hold.sh +source ./tests/util/util_list_buckets.sh +source ./tests/util/util_list_objects.sh +source ./tests/util/util_list_parts.sh +source ./tests/util/util_lock_config.sh +source ./tests/util/util_ownership.sh +source ./tests/util/util_policy.sh +source ./tests/util/util_rest.sh +source ./tests/util/util_tags.sh +source ./tests/util/util_time.sh +source ./tests/util/util_versioning.sh @test "test_rest_list_objects" { run setup_bucket "s3api" "$BUCKET_ONE_NAME" @@ -409,4 +410,16 @@ source ./tests/util_versioning.sh run get_and_check_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred" assert_success +} + +@test "REST - get policy w/o policy" { + if [ "$DIRECT" != "true" ]; then + skip "https://github.com/versity/versitygw/issues/959" + fi + + run setup_bucket "s3api" "$BUCKET_ONE_NAME" + assert_success + + run get_and_check_no_policy_error "$BUCKET_ONE_NAME" + assert_success } \ No newline at end of file diff --git a/tests/test_s3.sh b/tests/test_s3.sh index c4e4f380..ae34a064 100755 --- a/tests/test_s3.sh +++ b/tests/test_s3.sh @@ -15,7 +15,7 @@ # under the License. source ./tests/test_common.sh -source ./tests/util_file.sh +source ./tests/util/util_file.sh # complete-multipart-upload @test "test_complete_multipart_upload" { diff --git a/tests/test_s3_file_count.sh b/tests/test_s3_file_count.sh index 811daa88..ef88d26c 100755 --- a/tests/test_s3_file_count.sh +++ b/tests/test_s3_file_count.sh @@ -15,7 +15,7 @@ # under the License. source ./tests/test_common.sh -source ./tests/util_file.sh +source ./tests/util/util_file.sh @test "test_list_objects_file_count" { test_common_list_objects_file_count "s3" diff --git a/tests/test_s3api_bucket.sh b/tests/test_s3api_bucket.sh index d1c7072c..d0768697 100755 --- a/tests/test_s3api_bucket.sh +++ b/tests/test_s3api_bucket.sh @@ -15,14 +15,13 @@ # under the License. source ./tests/setup.sh -source ./tests/util.sh -source ./tests/util_aws.sh -source ./tests/util_create_bucket.sh -source ./tests/util_file.sh -source ./tests/util_lock_config.sh -source ./tests/util_tags.sh -source ./tests/util_users.sh -source ./tests/test_aws_root_inner.sh +source ./tests/util/util.sh +source ./tests/util/util_create_bucket.sh +source ./tests/util/util_file.sh +source ./tests/util/util_lock_config.sh +source ./tests/util/util_tags.sh +source ./tests/util/util_users.sh +source ./tests/test_s3api_root_inner.sh source ./tests/test_common.sh source ./tests/test_common_acl.sh source ./tests/commands/copy_object.sh @@ -51,33 +50,42 @@ source ./tests/commands/select_object_content.sh export RUN_USERS=true @test "test_create_bucket_invalid_name" { - test_create_bucket_invalid_name_aws_root + if [[ $RECREATE_BUCKETS != "true" ]]; then + return + fi + + run create_and_check_bucket_invalid_name "s3api" + assert_success } # create-bucket -@test "test_create_delete_bucket_aws" { - test_common_create_delete_bucket "aws" +@test "test_create_delete_bucket_s3api" { + test_common_create_delete_bucket "s3api" } -# delete-bucket - test_create_delete_bucket_aws +# delete-bucket - test_create_delete_bucket_s3api # delete-bucket-policy @test "test_get_put_delete_bucket_policy" { if [[ -n $SKIP_POLICY ]]; then skip "will not test policy actions with SKIP_POLICY set" fi - test_common_get_put_delete_bucket_policy "aws" + test_common_get_put_delete_bucket_policy "s3api" } # get-bucket-acl @test "test_get_bucket_acl" { - test_get_bucket_acl_aws_root + run setup_bucket "s3api" "$BUCKET_ONE_NAME" + assert_success + + run get_bucket_acl_and_check_owner "s3api" "$BUCKET_ONE_NAME" + assert_success } # get-bucket-location @test "test_get_bucket_location" { - test_common_get_bucket_location "aws" + test_common_get_bucket_location "s3api" } # get-bucket-policy - test_get_put_delete_bucket_policy @@ -85,7 +93,7 @@ export RUN_USERS=true # get-bucket-tagging - test_set_get_delete_bucket_tags @test "test_head_bucket" { - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success run check_for_empty_region "$BUCKET_ONE_NAME" @@ -93,17 +101,17 @@ export RUN_USERS=true } @test "test_head_bucket_doesnt_exist" { - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success - head_bucket "aws" "$BUCKET_ONE_NAME"a || local info_result=$? + head_bucket "s3api" "$BUCKET_ONE_NAME"a || local info_result=$? [[ $info_result -eq 1 ]] || fail "bucket info for non-existent bucket returned" [[ $bucket_info == *"404"* ]] || fail "404 not returned for non-existent bucket info" - bucket_cleanup "aws" "$BUCKET_ONE_NAME" + bucket_cleanup "s3api" "$BUCKET_ONE_NAME" } @test "test_head_bucket_invalid_name" { - if head_bucket "aws" ""; then + if head_bucket "s3api" ""; then fail "able to get bucket info for invalid name" fi } @@ -119,5 +127,5 @@ export RUN_USERS=true # delete-bucket-tagging @test "test-set-get-delete-bucket-tags" { - test_common_set_get_delete_bucket_tags "aws" + test_common_set_get_delete_bucket_tags "s3api" } diff --git a/tests/test_s3api_multipart.sh b/tests/test_s3api_multipart.sh index 3e21814f..67d776b9 100755 --- a/tests/test_s3api_multipart.sh +++ b/tests/test_s3api_multipart.sh @@ -15,27 +15,112 @@ # under the License. source ./tests/setup.sh -source ./tests/test_aws_root_inner.sh -source ./tests/util_file.sh -source ./tests/util_multipart.sh -source ./tests/util_tags.sh +source ./tests/test_s3api_root_inner.sh +source ./tests/util/util_file.sh +source ./tests/util/util_multipart.sh +source ./tests/util/util_tags.sh source ./tests/commands/get_object.sh source ./tests/commands/put_object.sh source ./tests/commands/list_multipart_uploads.sh # abort-multipart-upload @test "test_abort_multipart_upload" { - test_abort_multipart_upload_aws_root + local bucket_file="bucket-file" + + run create_test_file "$bucket_file" + assert_success + # shellcheck disable=SC2154 + run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1 + assert_success + + run setup_bucket "s3api" "$BUCKET_ONE_NAME" + assert_success + + run run_then_abort_multipart_upload "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4 + assert_success + + run object_exists "s3api" "$BUCKET_ONE_NAME" "$bucket_file" + assert_failure 1 } # complete-multipart-upload @test "test_complete_multipart_upload" { - test_complete_multipart_upload_aws_root + local bucket_file="bucket-file" + run create_test_files "$bucket_file" + assert_success + + run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1 + assert_success + + run setup_bucket "s3api" "$BUCKET_ONE_NAME" + assert_success + + run multipart_upload "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4 + assert_success + + run download_and_compare_file "s3api" "$TEST_FILE_FOLDER/$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file-copy" + assert_success } # create-multipart-upload @test "test_create_multipart_upload_properties" { - test_create_multipart_upload_properties_aws_root + local bucket_file="bucket-file" + + local expected_content_type="application/zip" + local expected_meta_key="testKey" + local expected_meta_val="testValue" + local expected_hold_status="ON" + local expected_retention_mode="GOVERNANCE" + local expected_tag_key="TestTag" + local expected_tag_val="TestTagVal" + + os_name="$(uname)" + if [[ "$os_name" == "Darwin" ]]; then + now=$(date -u +"%Y-%m-%dT%H:%M:%S") + later=$(date -j -v +15S -f "%Y-%m-%dT%H:%M:%S" "$now" +"%Y-%m-%dT%H:%M:%S") + else + now=$(date +"%Y-%m-%dT%H:%M:%S") + later=$(date -d "$now 15 seconds" +"%Y-%m-%dT%H:%M:%S") + fi + + run create_test_files "$bucket_file" + assert_success + + run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1 + assert_success + + run bucket_cleanup_if_bucket_exists "s3api" "$BUCKET_ONE_NAME" + assert_success + # in static bucket config, bucket will still exist + if ! bucket_exists "s3api" "$BUCKET_ONE_NAME"; then + run create_bucket_object_lock_enabled "$BUCKET_ONE_NAME" + assert_success + fi + + run multipart_upload_with_params "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4 \ + "$expected_content_type" \ + "{\"$expected_meta_key\": \"$expected_meta_val\"}" \ + "$expected_hold_status" \ + "$expected_retention_mode" \ + "$later" \ + "$expected_tag_key=$expected_tag_val" + assert_success + + run get_and_verify_metadata "$bucket_file" "$expected_content_type" "$expected_meta_key" "$expected_meta_val" \ + "$expected_hold_status" "$expected_retention_mode" "$later" + assert_success + + run check_verify_object_tags "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "$expected_tag_key" "$expected_tag_val" + assert_success + + run put_object_legal_hold "$BUCKET_ONE_NAME" "$bucket_file" "OFF" + assert_success + + run get_and_check_legal_hold "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "OFF" + assert_success + + run download_and_compare_file "s3api" "$TEST_FILE_FOLDER/$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file-copy" || fail "error getting object" + assert_success } @test "test-multipart-upload-from-bucket" { @@ -47,7 +132,7 @@ source ./tests/commands/list_multipart_uploads.sh run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1 assert_success - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success run multipart_upload_from_bucket "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4 @@ -65,7 +150,7 @@ source ./tests/commands/list_multipart_uploads.sh run create_large_file "$bucket_file" assert_success - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success run multipart_upload_range_too_large "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" @@ -77,7 +162,7 @@ source ./tests/commands/list_multipart_uploads.sh run create_large_file "$bucket_file" assert_success - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success run run_and_verify_multipart_upload_with_valid_range "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file" @@ -86,7 +171,21 @@ source ./tests/commands/list_multipart_uploads.sh # test multi-part upload list parts command @test "test-multipart-upload-list-parts" { - test_multipart_upload_list_parts_aws_root + local bucket_file="bucket-file" + + run create_test_file "$bucket_file" 0 + assert_success + run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1 + assert_success + + run setup_bucket "s3api" "$BUCKET_ONE_NAME" + assert_success + + run start_multipart_upload_list_check_parts "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" + assert_success + + run run_then_abort_multipart_upload "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file" 4 + assert_success } # test listing of active uploads @@ -102,7 +201,7 @@ source ./tests/commands/list_multipart_uploads.sh run create_test_files "$bucket_file_one" "$bucket_file_two" assert_success - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success run create_list_check_multipart_uploads "$BUCKET_ONE_NAME" "$bucket_file_one" "$bucket_file_two" diff --git a/tests/test_s3api_object.sh b/tests/test_s3api_object.sh index 8ae3e48b..74db6516 100755 --- a/tests/test_s3api_object.sh +++ b/tests/test_s3api_object.sh @@ -15,14 +15,13 @@ # under the License. source ./tests/setup.sh -source ./tests/util.sh -source ./tests/util_aws.sh -source ./tests/util_create_bucket.sh -source ./tests/util_file.sh -source ./tests/util_lock_config.sh -source ./tests/util_tags.sh -source ./tests/util_users.sh -source ./tests/test_aws_root_inner.sh +source ./tests/util/util.sh +source ./tests/util/util_create_bucket.sh +source ./tests/util/util_file.sh +source ./tests/util/util_lock_config.sh +source ./tests/util/util_tags.sh +source ./tests/util/util_users.sh +source ./tests/test_s3api_root_inner.sh source ./tests/test_common.sh source ./tests/test_common_acl.sh source ./tests/commands/copy_object.sh @@ -63,7 +62,7 @@ export RUN_USERS=true # delete-object-tagging @test "test_delete_object_tagging" { - test_common_delete_object_tagging "aws" + test_common_delete_object_tagging "s3api" } # delete-objects @@ -71,34 +70,34 @@ export RUN_USERS=true if [ "$RECREATE_BUCKETS" == "false" ]; then skip "https://github.com/versity/versitygw/issues/888" fi - test_delete_objects_aws_root + test_delete_objects_s3api_root } # get-object @test "test_get_object_full_range" { - test_get_object_full_range_aws_root + test_get_object_full_range_s3api_root } @test "test_get_object_invalid_range" { - test_get_object_invalid_range_aws_root + test_get_object_invalid_range_s3api_root } # get-object-attributes @test "test_get_object_attributes" { - test_get_object_attributes_aws_root + test_get_object_attributes_s3api_root } @test "test_get_put_object_legal_hold" { - test_get_put_object_legal_hold_aws_root + test_get_put_object_legal_hold_s3api_root } @test "test_get_put_object_retention" { - test_get_put_object_retention_aws_root + test_get_put_object_retention_s3api_root } # test listing a bucket's objects on versitygw @test "test_list_objects" { - test_common_list_objects "aws" + test_common_list_objects "s3api" } @test "test-list-objects-delimiter" { @@ -111,10 +110,10 @@ export RUN_USERS=true run create_test_file "$folder_name"/"$object_name" assert_success - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success - run put_object "aws" "$TEST_FILE_FOLDER/$folder_name/$object_name" "$BUCKET_ONE_NAME" "$folder_name/$object_name" + run put_object "s3api" "$TEST_FILE_FOLDER/$folder_name/$object_name" "$BUCKET_ONE_NAME" "$folder_name/$object_name" assert_success run check_object_listing_with_prefixes "$BUCKET_ONE_NAME" "$folder_name" "$object_name" @@ -122,7 +121,7 @@ export RUN_USERS=true } @test "test_put_object" { - test_put_object_aws_root + test_put_object_s3api_root } # test adding and removing an object on versitygw @@ -130,18 +129,18 @@ export RUN_USERS=true if [ "$RECREATE_BUCKETS" == "false" ]; then skip "https://github.com/versity/versitygw/issues/888" fi - test_common_put_object_with_data "aws" + test_common_put_object_with_data "s3api" } @test "test_put_object_no_data" { if [ "$RECREATE_BUCKETS" == "false" ]; then skip "https://github.com/versity/versitygw/issues/888" fi - test_common_put_object_no_data "aws" + test_common_put_object_no_data "s3api" } @test "test-presigned-url-utf8-chars" { - test_common_presigned_url_utf8_chars "aws" + test_common_presigned_url_utf8_chars "s3api" } @test "test_put_object_lock_configuration" { @@ -162,7 +161,7 @@ export RUN_USERS=true run get_and_check_object_lock_config "$bucket_name" "$enabled" "$governance" "$days" assert_success "error getting and checking object lock config" - bucket_cleanup "aws" "$bucket_name" + bucket_cleanup "s3api" "$bucket_name" } @test "test_put_object_metadata" { @@ -173,50 +172,50 @@ export RUN_USERS=true run create_test_files "$object_one" assert_success - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success object="$TEST_FILE_FOLDER"/"$object_one" - put_object_with_metadata "aws" "$object" "$BUCKET_ONE_NAME" "$object_one" "$test_key" "$test_value" || fail "failed to add object to bucket" - object_exists "aws" "$BUCKET_ONE_NAME" "$object_one" || fail "object not found after being added to bucket" + put_object_with_metadata "s3api" "$object" "$BUCKET_ONE_NAME" "$object_one" "$test_key" "$test_value" || fail "failed to add object to bucket" + object_exists "s3api" "$BUCKET_ONE_NAME" "$object_one" || fail "object not found after being added to bucket" - get_object_metadata "aws" "$BUCKET_ONE_NAME" "$object_one" || fail "error getting object metadata" + get_object_metadata "s3api" "$BUCKET_ONE_NAME" "$object_one" || fail "error getting object metadata" key=$(echo "$metadata" | jq -r 'keys[]' 2>&1) || fail "error getting key from metadata: $key" value=$(echo "$metadata" | jq -r '.[]' 2>&1) || fail "error getting value from metadata: $value" [[ $key == "$test_key" ]] || fail "keys doesn't match (expected $key, actual \"$test_key\")" [[ $value == "$test_value" ]] || fail "values doesn't match (expected $value, actual \"$test_value\")" - bucket_cleanup "aws" "$BUCKET_ONE_NAME" + bucket_cleanup "s3api" "$BUCKET_ONE_NAME" delete_test_files "$object_one" } @test "test_retention_bypass" { - test_retention_bypass_aws_root + test_retention_bypass_s3api_root } # test v1 s3api list objects command @test "test-s3api-list-objects-v1" { - test_s3api_list_objects_v1_aws_root + test_s3api_list_objects_v1_s3api_root } # test v2 s3api list objects command @test "test-s3api-list-objects-v2" { - test_s3api_list_objects_v2_aws_root + test_s3api_list_objects_v2_s3api_root } # test abilty to set and retrieve object tags @test "test-set-get-object-tags" { - test_common_set_get_object_tags "aws" + test_common_set_get_object_tags "s3api" } # ensure that lists of files greater than a size of 1000 (pagination) are returned properly #@test "test_list_objects_file_count" { -# test_common_list_objects_file_count "aws" +# test_common_list_objects_file_count "s3api" #} # ensure that lists of files greater than a size of 1000 (pagination) are returned properly #@test "test_list_objects_file_count" { -# test_common_list_objects_file_count "aws" +# test_common_list_objects_file_count "s3api" #} #@test "test_filename_length" { @@ -226,10 +225,10 @@ export RUN_USERS=true # create_test_files "$file_name" || created=$? # [[ $created -eq 0 ]] || fail "error creating file" -# setup_bucket "aws" "$BUCKET_ONE_NAME" || local setup_result=$? +# setup_bucket "s3api" "$BUCKET_ONE_NAME" || local setup_result=$? # [[ $setup_result -eq 0 ]] || fail "error setting up bucket" -# put_object "aws" "$TEST_FILE_FOLDER"/"$file_name" "$BUCKET_ONE_NAME"/"$file_name" || local put_object=$? +# put_object "s3api" "$TEST_FILE_FOLDER"/"$file_name" "$BUCKET_ONE_NAME"/"$file_name" || local put_object=$? # [[ $put_object -eq 0 ]] || fail "Failed to add object to bucket" #} diff --git a/tests/test_s3api_policy.sh b/tests/test_s3api_policy.sh index d8c1ecbd..a7df18ed 100755 --- a/tests/test_s3api_policy.sh +++ b/tests/test_s3api_policy.sh @@ -19,11 +19,11 @@ source ./tests/setup.sh source ./tests/test_s3api_policy_bucket.sh source ./tests/test_s3api_policy_multipart.sh source ./tests/test_s3api_policy_object.sh -source ./tests/util_multipart.sh -source ./tests/util_file.sh -source ./tests/util_policy.sh -source ./tests/util_tags.sh -source ./tests/util_users.sh +source ./tests/util/util_multipart.sh +source ./tests/util/util_file.sh +source ./tests/util/util_policy.sh +source ./tests/util/util_tags.sh +source ./tests/util/util_users.sh source ./tests/commands/get_bucket_policy.sh source ./tests/commands/get_bucket_tagging.sh source ./tests/commands/get_object.sh diff --git a/tests/test_s3api_policy_bucket.sh b/tests/test_s3api_policy_bucket.sh index 95302042..3c23b100 100644 --- a/tests/test_s3api_policy_bucket.sh +++ b/tests/test_s3api_policy_bucket.sh @@ -14,7 +14,7 @@ # specific language governing permissions and limitations # under the License. -source ./tests/util_acl.sh +source ./tests/util/util_acl.sh test_s3api_policy_delete_bucket_policy() { policy_file="policy_file" diff --git a/tests/test_aws_root_inner.sh b/tests/test_s3api_root_inner.sh similarity index 62% rename from tests/test_aws_root_inner.sh rename to tests/test_s3api_root_inner.sh index 87af7f50..52bcaba4 100755 --- a/tests/test_aws_root_inner.sh +++ b/tests/test_s3api_root_inner.sh @@ -17,111 +17,14 @@ source ./tests/commands/delete_objects.sh source ./tests/commands/list_objects_v2.sh source ./tests/commands/list_parts.sh -source ./tests/util_get_bucket_acl.sh -source ./tests/util_get_object_attributes.sh -source ./tests/util_get_object_retention.sh -source ./tests/util_head_object.sh -source ./tests/util_legal_hold.sh -source ./tests/util_list_objects.sh +source ./tests/util/util_get_bucket_acl.sh +source ./tests/util/util_get_object_attributes.sh +source ./tests/util/util_get_object_retention.sh +source ./tests/util/util_head_object.sh +source ./tests/util/util_legal_hold.sh +source ./tests/util/util_list_objects.sh -test_abort_multipart_upload_aws_root() { - local bucket_file="bucket-file" - - run create_test_file "$bucket_file" - assert_success - # shellcheck disable=SC2154 - run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1 - assert_success - - run setup_bucket "aws" "$BUCKET_ONE_NAME" - assert_success - - run run_then_abort_multipart_upload "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4 - assert_success - - run object_exists "aws" "$BUCKET_ONE_NAME" "$bucket_file" - assert_failure 1 -} - -test_complete_multipart_upload_aws_root() { - local bucket_file="bucket-file" - run create_test_files "$bucket_file" - assert_success - - run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1 - assert_success - - run setup_bucket "aws" "$BUCKET_ONE_NAME" - assert_success - - run multipart_upload "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4 - assert_success - - run download_and_compare_file "s3api" "$TEST_FILE_FOLDER/$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file-copy" - assert_success -} - -test_create_multipart_upload_properties_aws_root() { - local bucket_file="bucket-file" - - local expected_content_type="application/zip" - local expected_meta_key="testKey" - local expected_meta_val="testValue" - local expected_hold_status="ON" - local expected_retention_mode="GOVERNANCE" - local expected_tag_key="TestTag" - local expected_tag_val="TestTagVal" - - os_name="$(uname)" - if [[ "$os_name" == "Darwin" ]]; then - now=$(date -u +"%Y-%m-%dT%H:%M:%S") - later=$(date -j -v +15S -f "%Y-%m-%dT%H:%M:%S" "$now" +"%Y-%m-%dT%H:%M:%S") - else - now=$(date +"%Y-%m-%dT%H:%M:%S") - later=$(date -d "$now 15 seconds" +"%Y-%m-%dT%H:%M:%S") - fi - - run create_test_files "$bucket_file" - assert_success - - run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1 - assert_success - - run bucket_cleanup_if_bucket_exists "s3api" "$BUCKET_ONE_NAME" - assert_success - # in static bucket config, bucket will still exist - if ! bucket_exists "s3api" "$BUCKET_ONE_NAME"; then - run create_bucket_object_lock_enabled "$BUCKET_ONE_NAME" - assert_success - fi - - run multipart_upload_with_params "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4 \ - "$expected_content_type" \ - "{\"$expected_meta_key\": \"$expected_meta_val\"}" \ - "$expected_hold_status" \ - "$expected_retention_mode" \ - "$later" \ - "$expected_tag_key=$expected_tag_val" - assert_success - - run get_and_verify_metadata "$bucket_file" "$expected_content_type" "$expected_meta_key" "$expected_meta_val" \ - "$expected_hold_status" "$expected_retention_mode" "$later" - assert_success - - run check_verify_object_tags "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "$expected_tag_key" "$expected_tag_val" - assert_success - - run put_object_legal_hold "$BUCKET_ONE_NAME" "$bucket_file" "OFF" - assert_success - - run get_and_check_legal_hold "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "OFF" - assert_success - - run download_and_compare_file "s3api" "$TEST_FILE_FOLDER/$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file-copy" || fail "error getting object" - assert_success -} - -test_delete_objects_aws_root() { +test_delete_objects_s3api_root() { local object_one="test-file-one" local object_two="test-file-two" @@ -147,19 +50,7 @@ test_delete_objects_aws_root() { assert_failure 1 } -test_get_bucket_acl_aws_root() { - # TODO remove when able to assign bucket ownership back to root - if [[ $RECREATE_BUCKETS == "false" ]]; then - skip - fi - run setup_bucket "aws" "$BUCKET_ONE_NAME" - assert_success - - run get_bucket_acl_and_check_owner "s3api" "$BUCKET_ONE_NAME" - assert_success -} - -test_get_object_full_range_aws_root() { +test_get_object_full_range_s3api_root() { bucket_file="bucket_file" run create_test_files "$bucket_file" 0 @@ -178,7 +69,7 @@ test_get_object_full_range_aws_root() { assert [ "$(cat "$TEST_FILE_FOLDER/$bucket_file-range")" == "9" ] } -test_get_object_invalid_range_aws_root() { +test_get_object_invalid_range_s3api_root() { bucket_file="bucket_file" run create_test_files "$bucket_file" assert_success @@ -193,7 +84,7 @@ test_get_object_invalid_range_aws_root() { assert_success } -test_put_object_aws_root() { +test_put_object_s3api_root() { bucket_file="bucket_file" run create_test_files "$bucket_file" @@ -212,16 +103,7 @@ test_put_object_aws_root() { assert_success } -test_create_bucket_invalid_name_aws_root() { - if [[ $RECREATE_BUCKETS != "true" ]]; then - return - fi - - run create_and_check_bucket_invalid_name "aws" - assert_success -} - -test_get_object_attributes_aws_root() { +test_get_object_attributes_s3api_root() { bucket_file="bucket_file" run create_test_file "$bucket_file" assert_success @@ -236,10 +118,9 @@ test_get_object_attributes_aws_root() { assert_success } -test_get_put_object_legal_hold_aws_root() { +test_get_put_object_legal_hold_s3api_root() { if [[ $RECREATE_BUCKETS == "false" ]]; then - # https://github.com/versity/versitygw/issues/716 - skip + skip "https://github.com/versity/versitygw/issues/716" fi bucket_file="bucket_file" @@ -276,14 +157,13 @@ test_get_put_object_legal_hold_aws_root() { assert_success } -test_get_put_object_retention_aws_root() { +test_get_put_object_retention_s3api_root() { bucket_file="bucket_file" username=$USERNAME_ONE secret_key=$PASSWORD_ONE if [[ $RECREATE_BUCKETS == "false" ]]; then - # https://github.com/versity/versitygw/issues/716 - skip + skip "https://github.com/versity/versitygw/issues/716" fi run legal_hold_retention_setup "$username" "$secret_key" "$bucket_file" @@ -317,10 +197,9 @@ test_get_put_object_retention_aws_root() { assert_output --partial "Object is WORM protected and cannot be overwritten" } -test_retention_bypass_aws_root() { +test_retention_bypass_s3api_root() { if [[ $RECREATE_BUCKETS == "false" ]]; then - # https://github.com/versity/versitygw/issues/716 - skip + skip "https://github.com/versity/versitygw/issues/716" fi bucket_file="bucket_file" username=$USERNAME_ONE @@ -382,14 +261,14 @@ legal_hold_retention_setup() { assert_success } -test_s3api_list_objects_v1_aws_root() { +test_s3api_list_objects_v1_s3api_root() { local object_one="test-file-one" local object_two="test-file-two" run create_test_files "$object_one" "$object_two" assert_success - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success run put_object "s3api" "$TEST_FILE_FOLDER"/"$object_one" "$BUCKET_ONE_NAME" "$object_one" @@ -402,14 +281,14 @@ test_s3api_list_objects_v1_aws_root() { assert_success } -test_s3api_list_objects_v2_aws_root() { +test_s3api_list_objects_v2_s3api_root() { local object_one="test-file-one" local object_two="test-file-two" run create_test_files "$object_one" "$object_two" assert_success - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success run put_object "s3api" "$TEST_FILE_FOLDER"/"$object_one" "$BUCKET_ONE_NAME" "$object_one" @@ -421,21 +300,3 @@ test_s3api_list_objects_v2_aws_root() { run list_check_objects_v2 "$BUCKET_ONE_NAME" "$object_one" 10 "$object_two" 10 assert_success } - -test_multipart_upload_list_parts_aws_root() { - local bucket_file="bucket-file" - - run create_test_file "$bucket_file" 0 - assert_success - run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1 - assert_success - - run setup_bucket "aws" "$BUCKET_ONE_NAME" - assert_success - - run start_multipart_upload_list_check_parts "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" - assert_success - - run run_then_abort_multipart_upload "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file" 4 - assert_success -} diff --git a/tests/test_s3cmd.sh b/tests/test_s3cmd.sh index 19a2ae6e..0a6f32df 100755 --- a/tests/test_s3cmd.sh +++ b/tests/test_s3cmd.sh @@ -17,9 +17,9 @@ source ./tests/setup.sh source ./tests/test_common.sh source ./tests/test_common_acl.sh -source ./tests/util.sh -source ./tests/util_create_bucket.sh -source ./tests/util_users.sh +source ./tests/util/util.sh +source ./tests/util/util_create_bucket.sh +source ./tests/util/util_users.sh source ./tests/commands/delete_bucket_policy.sh source ./tests/commands/get_bucket_policy.sh source ./tests/commands/put_bucket_policy.sh diff --git a/tests/test_user_aws.sh b/tests/test_user_aws.sh index 2ad3e268..bad8824a 100755 --- a/tests/test_user_aws.sh +++ b/tests/test_user_aws.sh @@ -15,7 +15,7 @@ # under the License. source ./tests/test_user_common.sh -source ./tests/util_users.sh +source ./tests/util/util_users.sh source ./tests/commands/get_object.sh source ./tests/commands/put_object.sh diff --git a/tests/test_user_common.sh b/tests/test_user_common.sh index ee7c7f24..04d9b6a7 100755 --- a/tests/test_user_common.sh +++ b/tests/test_user_common.sh @@ -15,10 +15,10 @@ # under the License. source ./tests/setup.sh -source ./tests/util_users.sh -source ./tests/util.sh -source ./tests/util_create_bucket.sh -source ./tests/util_list_buckets.sh +source ./tests/util/util.sh +source ./tests/util/util_create_bucket.sh +source ./tests/util/util_list_buckets.sh +source ./tests/util/util_users.sh source ./tests/commands/list_buckets.sh test_admin_user() { @@ -41,7 +41,7 @@ test_admin_user() { run create_user_with_user "$admin_username" "$admin_password" "$user_username" "$user_password" "user" assert_success - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success if [ "$RECREATE_BUCKETS" == "true" ]; then @@ -52,7 +52,7 @@ test_admin_user() { assert_success fi - run list_and_check_buckets_with_user "aws" "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME" "$admin_username" "$admin_password" + run list_and_check_buckets_with_user "s3api" "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME" "$admin_username" "$admin_password" assert_success run change_bucket_owner "$admin_username" "$admin_password" "$BUCKET_TWO_NAME" "$user_username" @@ -89,25 +89,25 @@ test_user_user() { password="$PASSWORD_ONE" setup_user "$username" "$password" "user" || fail "error setting up user" - bucket_cleanup_if_bucket_exists "aws" "versity-gwtest-user-bucket" + bucket_cleanup_if_bucket_exists "s3api" "versity-gwtest-user-bucket" - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success - if create_bucket_with_user "aws" "versity-gwtest-user-bucket" "$username" "$password"; then + if create_bucket_with_user "s3api" "versity-gwtest-user-bucket" "$username" "$password"; then fail "creating bucket with 'user' account failed to return error" fi # shellcheck disable=SC2154 [[ $error == *"Access Denied"* ]] || fail "error message '$error' doesn't contain 'Access Denied'" - create_bucket "aws" "versity-gwtest-user-bucket" || fail "error creating bucket" + create_bucket "s3api" "versity-gwtest-user-bucket" || fail "error creating bucket" change_bucket_owner "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "versity-gwtest-user-bucket" "$username" || fail "error changing bucket owner" if change_bucket_owner "$username" "$password" "versity-gwtest-user-bucket" "admin"; then fail "user shouldn't be able to change bucket owner" fi - list_buckets_with_user "aws" "$username" "$password" || fail "error listing buckets with user '$username'" + list_buckets_with_user "s3api" "$username" "$password" || fail "error listing buckets with user '$username'" bucket_found=false for bucket in "${bucket_array[@]}"; do if [ "$bucket" == "$BUCKET_ONE_NAME" ]; then @@ -120,7 +120,7 @@ test_user_user() { fail "user-owned bucket not found in user list" fi - run delete_bucket "aws" "versity-gwtest-user-bucket" + run delete_bucket "s3api" "versity-gwtest-user-bucket" assert_success "failed to delete bucket" delete_user "$username" } @@ -133,15 +133,15 @@ test_userplus_operation() { username="$USERNAME_ONE" password="$PASSWORD_ONE" - bucket_cleanup_if_bucket_exists "aws" "versity-gwtest-userplus-bucket" + bucket_cleanup_if_bucket_exists "s3api" "versity-gwtest-userplus-bucket" setup_user "$username" "$password" "userplus" || fail "error creating user '$username'" - run setup_bucket "aws" "$BUCKET_ONE_NAME" + run setup_bucket "s3api" "$BUCKET_ONE_NAME" assert_success - create_bucket_with_user "aws" "versity-gwtest-userplus-bucket" "$username" "$password" || fail "error creating bucket with user '$username'" + create_bucket_with_user "s3api" "versity-gwtest-userplus-bucket" "$username" "$password" || fail "error creating bucket with user '$username'" - list_buckets_with_user "aws" "$username" "$password" || fail "error listing buckets with user '$username'" + list_buckets_with_user "s3api" "$username" "$password" || fail "error listing buckets with user '$username'" bucket_found=false for bucket in "${bucket_array[@]}"; do if [ "$bucket" == "$BUCKET_ONE_NAME" ]; then @@ -158,7 +158,7 @@ test_userplus_operation() { fail "userplus shouldn't be able to change bucket owner" fi - run delete_bucket "aws" "versity-gwtest-admin-bucket" + run delete_bucket "s3api" "versity-gwtest-admin-bucket" assert_success "failed to delete bucket" delete_user "$username" } \ No newline at end of file diff --git a/tests/util.sh b/tests/util/util.sh similarity index 97% rename from tests/util.sh rename to tests/util/util.sh index d8edf98c..a984c3fa 100644 --- a/tests/util.sh +++ b/tests/util/util.sh @@ -14,11 +14,11 @@ # specific language governing permissions and limitations # under the License. -source ./tests/util_bucket.sh -source ./tests/util_create_bucket.sh -source ./tests/util_mc.sh -source ./tests/util_multipart.sh -source ./tests/util_versioning.sh +source ./tests/util/util_bucket.sh +source ./tests/util/util_create_bucket.sh +source ./tests/util/util_mc.sh +source ./tests/util/util_multipart.sh +source ./tests/util/util_versioning.sh source ./tests/logger.sh source ./tests/commands/abort_multipart_upload.sh source ./tests/commands/complete_multipart_upload.sh @@ -45,7 +45,7 @@ source ./tests/commands/put_object_legal_hold.sh source ./tests/commands/put_object_lock_configuration.sh source ./tests/commands/upload_part_copy.sh source ./tests/commands/upload_part.sh -source ./tests/util_users.sh +source ./tests/util/util_users.sh # params: bucket name # return 0 for success, 1 for error @@ -275,7 +275,7 @@ put_object_with_metadata() { local exit_code=0 local error - if [[ $1 == 'aws' ]]; then + if [[ $1 == 's3api' ]]; then error=$(aws --no-verify-ssl s3api put-object --body "$2" --bucket "$3" --key "$4" --metadata "{\"$5\":\"$6\"}") || exit_code=$? else log 2 "invalid command type $1" @@ -296,7 +296,7 @@ get_object_metadata() { fi local exit_code=0 - if [[ $1 == 'aws' ]]; then + if [[ $1 == 's3api' ]]; then metadata_struct=$(aws --no-verify-ssl s3api head-object --bucket "$2" --key "$3") || exit_code=$? else log 2 "invalid command type $1" @@ -320,7 +320,7 @@ put_object_multiple() { fi local exit_code=0 local error - if [[ $1 == 'aws' ]] || [[ $1 == 's3' ]]; then + if [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then # shellcheck disable=SC2086 error=$(aws --no-verify-ssl s3 cp "$(dirname "$2")" s3://"$3" --recursive --exclude="*" --include="$2" 2>&1) || exit_code=$? elif [[ $1 == 's3cmd' ]]; then @@ -350,7 +350,7 @@ check_and_put_object() { log 2 "check and put object function requires source, bucket, destination" return 1 fi - object_exists "aws" "$2" "$3" || local exists_result=$? + object_exists "s3api" "$2" "$3" || local exists_result=$? if [ "$exists_result" -eq 2 ]; then log 2 "error checking if object exists" return 1 diff --git a/tests/util_acl.sh b/tests/util/util_acl.sh similarity index 99% rename from tests/util_acl.sh rename to tests/util/util_acl.sh index d285ed9c..42c4acfb 100644 --- a/tests/util_acl.sh +++ b/tests/util/util_acl.sh @@ -44,6 +44,7 @@ get_check_post_change_acl_s3cmd() { log 5 "ACL after read put: $acl" acl_lines=$(echo "$acl" | grep "ACL") log 5 "ACL lines: $acl_lines" + lines=() while IFS= read -r line; do lines+=("$line") done <<< "$acl_lines" diff --git a/tests/util_attributes.sh b/tests/util/util_attributes.sh similarity index 100% rename from tests/util_attributes.sh rename to tests/util/util_attributes.sh diff --git a/tests/util_aws.sh b/tests/util/util_aws.sh similarity index 100% rename from tests/util_aws.sh rename to tests/util/util_aws.sh diff --git a/tests/util_bucket.sh b/tests/util/util_bucket.sh similarity index 98% rename from tests/util_bucket.sh rename to tests/util/util_bucket.sh index 7ba81a1b..ebc52080 100644 --- a/tests/util_bucket.sh +++ b/tests/util/util_bucket.sh @@ -14,7 +14,7 @@ delete_bucket_recursive() { local error if [[ $1 == 's3' ]]; then error=$(aws --no-verify-ssl s3 rb s3://"$2" --force 2>&1) || exit_code="$?" - elif [[ $1 == "aws" ]] || [[ $1 == 's3api' ]]; then + elif [[ $1 == 's3api' ]]; then if ! delete_bucket_recursive_s3api "$2"; then log 2 "error deleting bucket recursively (s3api)" return 1 @@ -123,7 +123,7 @@ delete_bucket_contents() { local exit_code=0 local error - if [[ $1 == "aws" ]] || [[ $1 == 's3api' ]]; then + if [[ $1 == 's3api' ]]; then if ! clear_bucket_s3api "$2"; then log 2 "error clearing bucket (s3api)" return 1 @@ -308,7 +308,7 @@ check_for_empty_region() { log 2 "'check_for_empty_region' requires bucket name" return 1 fi - if ! head_bucket "aws" "$BUCKET_ONE_NAME"; then + if ! head_bucket "s3api" "$BUCKET_ONE_NAME"; then log 2 "error getting bucket info" return 1 fi diff --git a/tests/util_bucket_location.sh b/tests/util/util_bucket_location.sh similarity index 100% rename from tests/util_bucket_location.sh rename to tests/util/util_bucket_location.sh diff --git a/tests/util_config.sh b/tests/util/util_config.sh similarity index 100% rename from tests/util_config.sh rename to tests/util/util_config.sh diff --git a/tests/util_create_bucket.sh b/tests/util/util_create_bucket.sh similarity index 98% rename from tests/util_create_bucket.sh rename to tests/util/util_create_bucket.sh index fee03f16..7bd87b37 100644 --- a/tests/util_create_bucket.sh +++ b/tests/util/util_create_bucket.sh @@ -14,7 +14,7 @@ # specific language governing permissions and limitations # under the License. -source ./tests/util_mc.sh +source ./tests/util/util_mc.sh source ./tests/logger.sh create_bucket_invalid_name() { diff --git a/tests/util_file.sh b/tests/util/util_file.sh similarity index 100% rename from tests/util_file.sh rename to tests/util/util_file.sh diff --git a/tests/util_get_bucket_acl.sh b/tests/util/util_get_bucket_acl.sh similarity index 100% rename from tests/util_get_bucket_acl.sh rename to tests/util/util_get_bucket_acl.sh diff --git a/tests/util_get_object_attributes.sh b/tests/util/util_get_object_attributes.sh similarity index 100% rename from tests/util_get_object_attributes.sh rename to tests/util/util_get_object_attributes.sh diff --git a/tests/util_get_object_retention.sh b/tests/util/util_get_object_retention.sh similarity index 100% rename from tests/util_get_object_retention.sh rename to tests/util/util_get_object_retention.sh diff --git a/tests/util_head_bucket.sh b/tests/util/util_head_bucket.sh similarity index 100% rename from tests/util_head_bucket.sh rename to tests/util/util_head_bucket.sh diff --git a/tests/util_head_object.sh b/tests/util/util_head_object.sh similarity index 100% rename from tests/util_head_object.sh rename to tests/util/util_head_object.sh diff --git a/tests/util_legal_hold.sh b/tests/util/util_legal_hold.sh similarity index 100% rename from tests/util_legal_hold.sh rename to tests/util/util_legal_hold.sh diff --git a/tests/util_list_buckets.sh b/tests/util/util_list_buckets.sh similarity index 100% rename from tests/util_list_buckets.sh rename to tests/util/util_list_buckets.sh diff --git a/tests/util_list_objects.sh b/tests/util/util_list_objects.sh similarity index 100% rename from tests/util_list_objects.sh rename to tests/util/util_list_objects.sh diff --git a/tests/util_list_parts.sh b/tests/util/util_list_parts.sh similarity index 100% rename from tests/util_list_parts.sh rename to tests/util/util_list_parts.sh diff --git a/tests/util_lock_config.sh b/tests/util/util_lock_config.sh similarity index 100% rename from tests/util_lock_config.sh rename to tests/util/util_lock_config.sh diff --git a/tests/util_mc.sh b/tests/util/util_mc.sh similarity index 100% rename from tests/util_mc.sh rename to tests/util/util_mc.sh diff --git a/tests/util_multipart.sh b/tests/util/util_multipart.sh similarity index 100% rename from tests/util_multipart.sh rename to tests/util/util_multipart.sh diff --git a/tests/util_ownership.sh b/tests/util/util_ownership.sh similarity index 100% rename from tests/util_ownership.sh rename to tests/util/util_ownership.sh diff --git a/tests/util_policy.sh b/tests/util/util_policy.sh similarity index 87% rename from tests/util_policy.sh rename to tests/util/util_policy.sh index 9aa2ae19..7d9d834c 100644 --- a/tests/util_policy.sh +++ b/tests/util/util_policy.sh @@ -223,6 +223,31 @@ put_and_check_for_malformed_policy() { return 0 } +get_and_check_no_policy_error() { + if [ $# -ne 1 ]; then + log 2 "'get_and_check_no_policy_error' requires bucket name" + return 1 + fi + if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OUTPUT_FILE="$TEST_FILE_FOLDER/response.txt" ./tests/rest_scripts/get_bucket_policy.sh); then + log 2 "error attempting to get bucket policy response: $result" + return 1 + fi + if [ "$result" != "404" ]; then + log 2 "GetBucketOwnershipControls returned unexpected response code: $result, reply: $(cat "$TEST_FILE_FOLDER/response.txt")" + return 1 + fi + log 5 "response: $(cat "$TEST_FILE_FOLDER/response.txt")" + if ! bucket_name=$(xmllint --xpath '//*[local-name()="BucketName"]/text()' "$TEST_FILE_FOLDER/response.txt" 2>&1); then + log 2 "error getting bucket name: $bucket_name" + return 1 + fi + if [ "$bucket_name" != "$1" ]; then + log 2 "rule mismatch (expected '$1', actual '$bucket_name')" + return 1 + fi + return 0 +} + get_and_compare_policy_with_file() { if [ $# -ne 4 ]; then log 2 "'get_and_compare_policies' reuires bucket, username, password, filename" diff --git a/tests/util_presigned_url.sh b/tests/util/util_presigned_url.sh similarity index 100% rename from tests/util_presigned_url.sh rename to tests/util/util_presigned_url.sh diff --git a/tests/util_rest.sh b/tests/util/util_rest.sh similarity index 100% rename from tests/util_rest.sh rename to tests/util/util_rest.sh diff --git a/tests/util_tags.sh b/tests/util/util_tags.sh similarity index 100% rename from tests/util_tags.sh rename to tests/util/util_tags.sh diff --git a/tests/util_time.sh b/tests/util/util_time.sh similarity index 100% rename from tests/util_time.sh rename to tests/util/util_time.sh diff --git a/tests/util_users.sh b/tests/util/util_users.sh similarity index 100% rename from tests/util_users.sh rename to tests/util/util_users.sh diff --git a/tests/util_versioning.sh b/tests/util/util_versioning.sh similarity index 100% rename from tests/util_versioning.sh rename to tests/util/util_versioning.sh diff --git a/tests/versity.sh b/tests/versity.sh index f5ddf6f7..526293e7 100644 --- a/tests/versity.sh +++ b/tests/versity.sh @@ -14,7 +14,7 @@ # specific language governing permissions and limitations # under the License. -source ./tests/util_file.sh +source ./tests/util/util_file.sh start_versity_process() { if [[ $# -ne 1 ]]; then