diff --git a/tests/drivers/delete_object/delete_object_rest.sh b/tests/drivers/delete_object/delete_object_rest.sh index c57eee84..2cf4c78e 100644 --- a/tests/drivers/delete_object/delete_object_rest.sh +++ b/tests/drivers/delete_object/delete_object_rest.sh @@ -17,7 +17,7 @@ source ./tests/commands/list_objects_v2.sh source ./tests/drivers/list_object_versions/list_object_versions_rest.sh source ./tests/drivers/xml.sh -source ./tests/util/util_legal_hold.sh +source ./tests/drivers/get_object_legal_hold/get_object_legal_hold_rest.sh list_and_delete_objects() { log 6 "list_and_delete_objects: '$1'" diff --git a/tests/drivers/get_bucket_acl/get_bucket_acl.sh b/tests/drivers/get_bucket_acl/get_bucket_acl.sh index 7da45dc7..1f01fab8 100644 --- a/tests/drivers/get_bucket_acl/get_bucket_acl.sh +++ b/tests/drivers/get_bucket_acl/get_bucket_acl.sh @@ -101,3 +101,22 @@ get_check_acl_after_second_put() { fi return 0 } + +get_bucket_acl_and_check_owner() { + if ! check_param_count_v2 "client, bucket name" 2 $#; then + return 1 + fi + if ! get_bucket_acl "$1" "$2"; then + log 2 "error getting bucket acl" + return 1 + fi + + # shellcheck disable=SC2154 + log 5 "ACL: $acl" + id=$(echo "$acl" | jq -r '.Owner.ID') + if [[ "$id" != "$AWS_ACCESS_KEY_ID" ]]; then + log 2 "Acl mismatch" + return 1 + fi + return 0 +} diff --git a/tests/util/util_get_object_attributes.sh b/tests/drivers/get_object_attributes/get_object_attributes_s3api.sh similarity index 98% rename from tests/util/util_get_object_attributes.sh rename to tests/drivers/get_object_attributes/get_object_attributes_s3api.sh index 1910e402..375a1b37 100644 --- a/tests/util/util_get_object_attributes.sh +++ b/tests/drivers/get_object_attributes/get_object_attributes_s3api.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright 2024 Versity Software +# Copyright 2026 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 diff --git a/tests/drivers/get_object_legal_hold/get_object_legal_hold.sh b/tests/drivers/get_object_legal_hold/get_object_legal_hold.sh new file mode 100644 index 00000000..9d30c277 --- /dev/null +++ b/tests/drivers/get_object_legal_hold/get_object_legal_hold.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# Copyright 2026 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. + +get_and_check_legal_hold() { + if ! check_param_count_v2 "client, bucket, key, expected status" 4 $#; then + return 1 + fi + if ! head_object "$1" "$2" "$3"; then + log 2 "error getting object metadata" + return 1 + fi + # shellcheck disable=SC2154 + raw_metadata=$(echo "$metadata" | grep -v "InsecureRequestWarning") + log 5 "raw metadata: $raw_metadata" + if ! hold_status=$(echo "$raw_metadata" | jq -r ".ObjectLockLegalHoldStatus // empty" 2>&1); then + log 2 "error retrieving hold status: $hold_status" + return 1 + fi + modified_hold_status="${hold_status:-OFF}" + if [[ "$modified_hold_status" != "$4" ]]; then + log 2 "hold status mismatch (expected '$4', actual '$modified_hold_status')" + return 1 + fi + return 0 +} diff --git a/tests/util/util_legal_hold.sh b/tests/drivers/get_object_legal_hold/get_object_legal_hold_rest.sh similarity index 86% rename from tests/util/util_legal_hold.sh rename to tests/drivers/get_object_legal_hold/get_object_legal_hold_rest.sh index f8681bcb..b960524c 100644 --- a/tests/util/util_legal_hold.sh +++ b/tests/drivers/get_object_legal_hold/get_object_legal_hold_rest.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright 2024 Versity Software +# Copyright 2026 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 @@ -14,28 +14,6 @@ # specific language governing permissions and limitations # under the License. -get_and_check_legal_hold() { - if ! check_param_count "get_and_check_legal_hold" "client, bucket, key, expected status" 4 $#; then - return 1 - fi - if ! head_object "$1" "$2" "$3"; then - log 2 "error getting object metadata" - return 1 - fi - # shellcheck disable=SC2154 - raw_metadata=$(echo "$metadata" | grep -v "InsecureRequestWarning") - log 5 "raw metadata: $raw_metadata" - if ! hold_status=$(echo "$raw_metadata" | jq -r ".ObjectLockLegalHoldStatus" 2>&1); then - log 2 "error retrieving hold status: $hold_status" - return 1 - fi - if [[ "$hold_status" != "$4" ]]; then - log 2 "hold status mismatch ($hold_status, $4)" - return 1 - fi - return 0 -} - check_legal_hold_without_lock_enabled() { if ! check_param_count_v2 "bucket, key, expected error" 3 $#; then return 1 diff --git a/tests/util/util_get_object_retention.sh b/tests/drivers/get_object_retention/get_object_retention_s3api.sh similarity index 97% rename from tests/util/util_get_object_retention.sh rename to tests/drivers/get_object_retention/get_object_retention_s3api.sh index 53137914..254cb102 100644 --- a/tests/util/util_get_object_retention.sh +++ b/tests/drivers/get_object_retention/get_object_retention_s3api.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright 2024 Versity Software +# Copyright 2026 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 diff --git a/tests/util/util_get_bucket_acl.sh b/tests/drivers/head_bucket/head_bucket_mc.sh similarity index 64% rename from tests/util/util_get_bucket_acl.sh rename to tests/drivers/head_bucket/head_bucket_mc.sh index a54506a2..71bc8421 100644 --- a/tests/util/util_get_bucket_acl.sh +++ b/tests/drivers/head_bucket/head_bucket_mc.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright 2024 Versity Software +# Copyright 2026 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 @@ -14,18 +14,18 @@ # specific language governing permissions and limitations # under the License. -get_bucket_acl_and_check_owner() { - if [ $# -ne 2 ]; then - log 2 "'get_acl_and_check_owner' requires client, bucket name" +bucket_info_contains_bucket() { + if ! check_param_count_v2 "client, bucket" 2 $#; then return 1 fi - if ! get_bucket_acl "$1" "$2"; then - log 2 "error getting bucket acl" + if ! head_bucket "mc" "$BUCKET_ONE_NAME"; then + log 2 "error getting bucket info" return 1 fi # shellcheck disable=SC2154 - log 5 "ACL: $acl" - id=$(echo "$acl" | jq -r '.Owner.ID') - [[ $id == "$AWS_ACCESS_KEY_ID" ]] || fail "Acl mismatch" -} \ No newline at end of file + if [[ "$bucket_info" != *"$BUCKET_ONE_NAME"* ]]; then + return 1 + fi + return 0 +} diff --git a/tests/drivers/head_bucket/head_bucket_s3api.sh b/tests/drivers/head_bucket/head_bucket_s3api.sh index a91085cc..5f817320 100644 --- a/tests/drivers/head_bucket/head_bucket_s3api.sh +++ b/tests/drivers/head_bucket/head_bucket_s3api.sh @@ -51,3 +51,15 @@ check_for_empty_region() { fi return 0 } + +bucket_info_without_bucket() { + if head_bucket "s3api" "$BUCKET_ONE_NAME"; then + log 2 "able to get bucket info for non-existent bucket" + return 1 + fi + if [[ $bucket_info != *"404"* ]]; then + log 2 "404 not returned for non-existent bucket info" + return 1 + fi + return 0 +} diff --git a/tests/test_mc.sh b/tests/test_mc.sh index 0f13c852..38e2fe84 100755 --- a/tests/test_mc.sh +++ b/tests/test_mc.sh @@ -29,7 +29,6 @@ source ./tests/drivers/get_bucket_tagging/get_bucket_tagging.sh source ./tests/drivers/get_bucket_tagging/get_bucket_tagging_rest.sh source ./tests/drivers/get_object_tagging/get_object_tagging.sh source ./tests/drivers/put_bucket_ownership_controls/put_bucket_ownership_controls_rest.sh -source ./tests/util/util_head_bucket.sh export RUN_MC=true diff --git a/tests/test_s3api_bucket.sh b/tests/test_s3api_bucket.sh index c4101c32..f1f2f3a0 100755 --- a/tests/test_s3api_bucket.sh +++ b/tests/test_s3api_bucket.sh @@ -53,7 +53,6 @@ source ./tests/drivers/get_bucket_tagging/get_bucket_tagging_rest.sh source ./tests/drivers/head_bucket/head_bucket_rest.sh source ./tests/drivers/head_bucket/head_bucket_s3api.sh source ./tests/drivers/put_bucket_ownership_controls/put_bucket_ownership_controls_rest.sh -source ./tests/util/util_head_bucket.sh source ./tests/util/util_lock_config.sh source ./tests/util/util_object.sh diff --git a/tests/test_s3api_multipart.sh b/tests/test_s3api_multipart.sh index e915925c..2dcd61ee 100755 --- a/tests/test_s3api_multipart.sh +++ b/tests/test_s3api_multipart.sh @@ -25,6 +25,7 @@ source ./tests/commands/put_object.sh source ./tests/drivers/file.sh source ./tests/drivers/head_object/head_object_s3api.sh source ./tests/drivers/create_bucket/create_bucket_rest.sh +source ./tests/drivers/get_object_legal_hold/get_object_legal_hold.sh source ./tests/drivers/get_object_tagging/get_object_tagging.sh source ./tests/drivers/put_bucket_ownership_controls/put_bucket_ownership_controls_rest.sh source ./tests/util/util_multipart.sh diff --git a/tests/test_s3api_object.sh b/tests/test_s3api_object.sh index 2f1e633a..d1ee336d 100755 --- a/tests/test_s3api_object.sh +++ b/tests/test_s3api_object.sh @@ -43,6 +43,9 @@ source ./tests/commands/put_object_retention.sh source ./tests/commands/put_public_access_block.sh source ./tests/commands/select_object_content.sh source ./tests/drivers/copy_object/copy_object_rest.sh +source ./tests/drivers/get_object_attributes/get_object_attributes_s3api.sh +source ./tests/drivers/get_object_legal_hold/get_object_legal_hold.sh +source ./tests/drivers/get_object_retention/get_object_retention_s3api.sh source ./tests/drivers/get_object_tagging/get_object_tagging.sh source ./tests/drivers/list_buckets/list_buckets_rest.sh source ./tests/drivers/put_bucket_ownership_controls/put_bucket_ownership_controls_rest.sh diff --git a/tests/test_s3api_root_inner.sh b/tests/test_s3api_root_inner.sh index 464efeff..3075c726 100755 --- a/tests/test_s3api_root_inner.sh +++ b/tests/test_s3api_root_inner.sh @@ -18,10 +18,6 @@ source ./tests/commands/delete_objects.sh source ./tests/commands/list_objects_v2.sh source ./tests/commands/list_parts.sh source ./tests/drivers/put_object/put_object.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_legal_hold.sh source ./tests/util/util_list_objects.sh test_delete_objects_s3api_root() { diff --git a/tests/util/util_head_bucket.sh b/tests/util/util_head_bucket.sh deleted file mode 100644 index c6ee28d3..00000000 --- a/tests/util/util_head_bucket.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -bucket_info_contains_bucket() { - if [ $# -ne 2 ]; then - log 2 "'bucket_info_contains_bucket' requires client, bucket" - return 1 - fi - if ! head_bucket "mc" "$BUCKET_ONE_NAME"; then - log 2 "error getting bucket info" - return 1 - fi - - # shellcheck disable=SC2154 - if [[ "$bucket_info" != *"$BUCKET_ONE_NAME"* ]]; then - return 1 - fi - return 0 -} - -bucket_info_without_bucket() { - if head_bucket "s3api" "$BUCKET_ONE_NAME"; then - log 2 "able to get bucket info for non-existent bucket" - return 1 - fi - if [[ $bucket_info != *"404"* ]]; then - log 2 "404 not returned for non-existent bucket info" - return 1 - fi - return 0 -} \ No newline at end of file