From 5e1b4d801186105984518bee3e65e5cf916f8463 Mon Sep 17 00:00:00 2001 From: Luke McCrone Date: Thu, 2 Oct 2025 20:27:24 -0300 Subject: [PATCH] test: more test conversions/direct checks --- tests/commands/put_bucket_acl.sh | 2 +- tests/drivers/copy_object/copy_object_rest.sh | 2 +- .../create_bucket/create_bucket_rest.sh | 8 +- .../delete_bucket/delete_bucket_rest.sh | 21 ++ tests/drivers/file.sh | 124 +++++++++ .../drivers/get_bucket_acl/get_bucket_acl.sh | 11 - .../get_bucket_acl/get_bucket_acl_rest.sh | 11 + .../get_object_attributes_rest.sh} | 44 +-- tests/drivers/user.sh | 2 +- tests/test_rest.sh | 259 ++++++++++++------ tests/test_rest_acl.sh | 91 +++--- tests/test_rest_bucket.sh | 122 ++++++--- tests/test_rest_checksum.sh | 50 +++- tests/test_rest_chunked.sh | 84 ++++-- tests/test_rest_create_bucket.sh | 28 +- tests/test_rest_delete_bucket.sh | 65 +++-- ...t_rest_delete_bucket_ownership_controls.sh | 41 ++- tests/util/util_bucket.sh | 24 -- tests/util/util_chunked_upload.sh | 59 ++-- tests/util/util_object.sh | 30 +- tests/util/util_setup.sh | 87 ------ tests/util/util_tags.sh | 2 +- 22 files changed, 762 insertions(+), 405 deletions(-) create mode 100644 tests/drivers/file.sh rename tests/{util/util_attributes.sh => drivers/get_object_attributes/get_object_attributes_rest.sh} (65%) diff --git a/tests/commands/put_bucket_acl.sh b/tests/commands/put_bucket_acl.sh index 365097c..0ebfad0 100644 --- a/tests/commands/put_bucket_acl.sh +++ b/tests/commands/put_bucket_acl.sh @@ -69,7 +69,7 @@ reset_bucket_acl() { log 2 "error resetting direct ACL" return 1 fi - if ! put_bucket_acl_rest "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER/$acl_file"; then + if ! put_bucket_acl_rest "$1" "$TEST_FILE_FOLDER/$acl_file"; then log 2 "error putting bucket acl (s3api)" return 1 fi diff --git a/tests/drivers/copy_object/copy_object_rest.sh b/tests/drivers/copy_object/copy_object_rest.sh index 0db4e56..040bdd3 100644 --- a/tests/drivers/copy_object/copy_object_rest.sh +++ b/tests/drivers/copy_object/copy_object_rest.sh @@ -39,7 +39,7 @@ copy_object_invalid_copy_source() { log 2 "'copy_object_invalid_copy_source' requires bucket name" return 1 fi - if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$BUCKET_ONE_NAME" OBJECT_KEY="dummy-copy" COPY_SOURCE="dummy" OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" ./tests/rest_scripts/copy_object.sh); then + if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OBJECT_KEY="dummy-copy" COPY_SOURCE="dummy" OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" ./tests/rest_scripts/copy_object.sh); then log 2 "error copying object: $result" return 1 fi diff --git a/tests/drivers/create_bucket/create_bucket_rest.sh b/tests/drivers/create_bucket/create_bucket_rest.sh index df97ea0..8ad9786 100644 --- a/tests/drivers/create_bucket/create_bucket_rest.sh +++ b/tests/drivers/create_bucket/create_bucket_rest.sh @@ -48,8 +48,14 @@ setup_and_create_bucket_and_check_acl() { log 5 "username=$username, password=$password" envs="$1=$id OBJECT_OWNERSHIP=BucketOwnerPreferred" log 5 "envs: $envs" + + if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then + log 2 "error retrieving bucket name: $bucket_name" + return 1 + fi + # shellcheck disable=SC2154 - if ! create_bucket_and_check_acl "$BUCKET_ONE_NAME" "$envs" "$username" "$password" "$user_canonical_id" "$owner_canonical_id"; then + if ! create_bucket_and_check_acl "$bucket_name" "$envs" "$username" "$password" "$user_canonical_id" "$owner_canonical_id"; then log 2 "error creating bucket and checking ACL" return 1 fi diff --git a/tests/drivers/delete_bucket/delete_bucket_rest.sh b/tests/drivers/delete_bucket/delete_bucket_rest.sh index 7ca6bd7..d16146c 100644 --- a/tests/drivers/delete_bucket/delete_bucket_rest.sh +++ b/tests/drivers/delete_bucket/delete_bucket_rest.sh @@ -15,6 +15,7 @@ # under the License. source ./tests/commands/list_buckets.sh +source ./tests/drivers/list_buckets/list_buckets_rest.sh delete_buckets_with_prefix() { if ! check_param_count_v2 "bucket prefix" 1 $#; then @@ -119,3 +120,23 @@ bucket_cleanup_if_bucket_exists_v2() { fi return 0 } + +# params: bucket name +# return 0 if able to delete recursively, 1 if not +delete_bucket_recursive() { + log 6 "delete_bucket_recursive '$1'" + if ! check_param_count "delete_bucket_recursive_s3api" "bucket" 1 $#; then + return 1 + fi + + if ! reset_bucket "$1"; then + log 2 "error clearing bucket (s3api)" + return 1 + fi + + if ! delete_bucket_rest "$1"; then + log 2 "error deleting bucket" + return 1 + fi + return 0 +} diff --git a/tests/drivers/file.sh b/tests/drivers/file.sh new file mode 100644 index 0000000..e0155f4 --- /dev/null +++ b/tests/drivers/file.sh @@ -0,0 +1,124 @@ +#!/usr/bin/env bats + +# 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/drivers/params.sh + +setup_bucket_and_file() { + if ! check_param_count_v2 "bucket, file name" 2 $#; then + return 1 + fi + if ! setup_bucket_and_file_base "$1" "setup_bucket_and_files" "$2"; then + log 2 "error setting up bucket and file" + return 1 + fi + return 0 +} + +setup_bucket_and_file_v2() { + if ! check_param_count_v2 "bucket, file name" 2 $#; then + return 1 + fi + if ! setup_bucket_and_file_base "$1" "setup_bucket_and_files_v2" "$2"; then + log 2 "error setting up bucket and files" + return 1 + fi + return 0 +} + +setup_bucket_and_file_base() { + if ! check_param_count_v2 "bucket, function, file name" 3 $#; then + return 1 + fi + if ! "$2" "$1" "$3"; then + log 2 "error setting up bucket and file" + return 1 + fi + return 0 +} + +setup_bucket_and_files() { + if ! check_param_count_gt "bucket, file name" 2 $#; then + return 1 + fi + if ! setup_bucket_and_files_base "$1" "setup_bucket" "${@:2}"; then + log 2 "error setting up bucket and files" + return 1 + fi + return 0 +} + +setup_bucket_and_files_v2() { + if ! check_param_count_gt "bucket, file name" 2 $#; then + return 1 + fi + if ! setup_bucket_and_files_base "$1" "setup_bucket_v2" "${@:2}"; then + log 2 "error setting up bucket and files" + return 1 + fi + return 0 +} + +setup_bucket_and_files_base() { + if ! check_param_count_gt "bucket, setup bucket function, file name" 3 $#; then + return 1 + fi + if ! "$2" "$1"; then + log 2 "error setting up bucket" + return 1 + fi + if ! create_test_files "${@:3}"; then + log 2 "error creating test files" + return 1 + fi + return 0 +} + +setup_bucket_and_large_file_base() { + if ! check_param_count "setup_bucket_and_large_file" "bucket, file name, function" 3 $#; then + return 1 + fi + if ! "$3" "$1"; then + log 2 "error setting up bucket" + return 1 + fi + if ! create_large_file "$2"; then + log 2 "error creating large file" + return 1 + fi + return 0 +} + +setup_bucket_and_large_file() { + if ! check_param_count "setup_bucket_and_large_file" "bucket, file name" 2 $#; then + return 1 + fi + if ! setup_bucket_and_large_file "$1" "$2" "setup_bucket"; then + log 2 "error setting up bucket and large file" + return 1 + fi + return 0 +} + +setup_bucket_and_large_file_v2() { + if ! check_param_count "setup_bucket_and_large_file" "bucket, file name" 2 $#; then + return 1 + fi + if ! setup_bucket_and_large_file_base "$1" "$2" "setup_bucket_v2"; then + log 2 "error setting up bucket and large file" + return 1 + fi + return 0 +} diff --git a/tests/drivers/get_bucket_acl/get_bucket_acl.sh b/tests/drivers/get_bucket_acl/get_bucket_acl.sh index 96349da..b11e5b9 100644 --- a/tests/drivers/get_bucket_acl/get_bucket_acl.sh +++ b/tests/drivers/get_bucket_acl/get_bucket_acl.sh @@ -100,14 +100,3 @@ get_check_acl_after_second_put() { fi return 0 } - -check_direct_display_name() { - if ! display_name=$(echo "$owner" | xmllint --xpath '//*[local-name()="DisplayName"]/text()' - 2>&1); then - log 2 "error getting display name: $display_name" - return 1 - fi - if [ "$display_name" != "$DIRECT_DISPLAY_NAME" ]; then - log 2 "display name mismatch (expected '$DIRECT_DISPLAY_NAME', actual '$display_name')" - return 1 - fi -} diff --git a/tests/drivers/get_bucket_acl/get_bucket_acl_rest.sh b/tests/drivers/get_bucket_acl/get_bucket_acl_rest.sh index d6b3977..a0222ad 100644 --- a/tests/drivers/get_bucket_acl/get_bucket_acl_rest.sh +++ b/tests/drivers/get_bucket_acl/get_bucket_acl_rest.sh @@ -116,3 +116,14 @@ get_and_check_acl_rest() { fi return 0 } + +check_direct_display_name() { + if ! display_name=$(echo "$owner" | xmllint --xpath '//*[local-name()="DisplayName"]/text()' - 2>&1); then + log 2 "error getting display name: $display_name" + return 1 + fi + if [ "$display_name" != "$DIRECT_DISPLAY_NAME" ]; then + log 2 "display name mismatch (expected '$DIRECT_DISPLAY_NAME', actual '$display_name')" + return 1 + fi +} diff --git a/tests/util/util_attributes.sh b/tests/drivers/get_object_attributes/get_object_attributes_rest.sh similarity index 65% rename from tests/util/util_attributes.sh rename to tests/drivers/get_object_attributes/get_object_attributes_rest.sh index 6005327..6b2f1d2 100644 --- a/tests/util/util_attributes.sh +++ b/tests/drivers/get_object_attributes/get_object_attributes_rest.sh @@ -1,23 +1,37 @@ #!/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. + upload_and_check_attributes() { - if [ $# -ne 2 ]; then - log 2 "'upload_and_check_attributes' requires test file, file size" + if ! check_param_count_v2 "bucket, test file, file size" 3 $#; then return 1 fi - if ! perform_multipart_upload_rest "$BUCKET_ONE_NAME" "$1" "$TEST_FILE_FOLDER/$1-0" "$TEST_FILE_FOLDER/$1-1" \ - "$TEST_FILE_FOLDER/$1-2" "$TEST_FILE_FOLDER/$1-3"; then + if ! perform_multipart_upload_rest "$1" "$2" "$TEST_FILE_FOLDER/$2-0" "$TEST_FILE_FOLDER/$2-1" \ + "$TEST_FILE_FOLDER/$2-2" "$TEST_FILE_FOLDER/$2-3"; then log 2 "error uploading and checking parts" return 1 fi - if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$BUCKET_ONE_NAME" OBJECT_KEY="$1" ATTRIBUTES="ETag,StorageClass,ObjectParts,ObjectSize" OUTPUT_FILE="$TEST_FILE_FOLDER/attributes.txt" ./tests/rest_scripts/get_object_attributes.sh); then + if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OBJECT_KEY="$2" ATTRIBUTES="ETag,StorageClass,ObjectParts,ObjectSize" OUTPUT_FILE="$TEST_FILE_FOLDER/attributes.txt" ./tests/rest_scripts/get_object_attributes.sh); then log 2 "error listing object attributes: $result" return 1 fi - if ! check_attributes_after_upload "$2"; then + if ! check_attributes_after_upload "$3"; then log 2 "error checking attributes after upload" return 1 fi + return 0 } check_attributes_after_upload() { @@ -59,11 +73,10 @@ check_attributes_after_upload() { } check_attributes_invalid_param() { - if [ $# -ne 1 ]; then - log 2 "'check_attributes_invalid_param' requires test file" + if ! check_param_count_v2 "bucket name, test file" 2 $#; then return 1 fi - if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$BUCKET_ONE_NAME" OBJECT_KEY="$1" ATTRIBUTES="ETags" OUTPUT_FILE="$TEST_FILE_FOLDER/attributes.txt" ./tests/rest_scripts/get_object_attributes.sh); then + if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OBJECT_KEY="$2" ATTRIBUTES="ETags" OUTPUT_FILE="$TEST_FILE_FOLDER/attributes.txt" ./tests/rest_scripts/get_object_attributes.sh); then log 2 "error listing object attributes: $result" return 1 fi @@ -83,24 +96,23 @@ check_attributes_invalid_param() { } add_and_check_checksum() { - if [ $# -ne 2 ]; then - log 2 "'add_and_check_checksum' requires data file, key" + if ! check_param_count_v2 "data file, bucket, key" 3 $#; then return 1 fi - if ! result=$(COMMAND_LOG="$COMMAND_LOG" DATA_FILE="$1" BUCKET_NAME="$BUCKET_ONE_NAME" OBJECT_KEY="$2" CHECKSUM_TYPE="sha256" OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" ./tests/rest_scripts/put_object.sh); then + if ! result=$(COMMAND_LOG="$COMMAND_LOG" DATA_FILE="$1" BUCKET_NAME="$2" OBJECT_KEY="$3" CHECKSUM_TYPE="sha256" OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" ./tests/rest_scripts/put_object.sh); then log 2 "error sending object file: $result" return 1 fi if [ "$result" != "200" ]; then - log 2 "expected response code of '200', was '$result' (output: $(cat "$TEST_FILE_FOLDER/result.txt")" + log 2 "expected response code of '200', was '$result' (output: $(cat "$TEST_FILE_FOLDER/result.txt"))" return 1 fi - if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$BUCKET_ONE_NAME" OBJECT_KEY="$2" ATTRIBUTES="Checksum" OUTPUT_FILE="$TEST_FILE_FOLDER/attributes.txt" ./tests/rest_scripts/get_object_attributes.sh); then + if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$2" OBJECT_KEY="$3" ATTRIBUTES="Checksum" OUTPUT_FILE="$TEST_FILE_FOLDER/attributes.txt" ./tests/rest_scripts/get_object_attributes.sh); then log 2 "error listing object attributes: $result (output: $(cat "$TEST_FILE_FOLDER/attributes.txt")" return 1 fi if [ "$result" != "200" ]; then - log 2 "expected response code of '200', was '$result'" + log 2 "expected response code of '200', was '$result' ($(cat "$TEST_FILE_FOLDER/attributes.txt"))" return 1 fi log 5 "attributes: $(cat "$TEST_FILE_FOLDER/attributes.txt")" @@ -129,4 +141,4 @@ get_etag_attribute_rest() { return 1 fi return 0 -} \ No newline at end of file +} diff --git a/tests/drivers/user.sh b/tests/drivers/user.sh index a931a73..5a16514 100644 --- a/tests/drivers/user.sh +++ b/tests/drivers/user.sh @@ -68,7 +68,7 @@ setup_bucket_and_user_v2() { if ! check_param_count_v2 "bucket, username, password" 3 $#; then return 1 fi - if ! setup_bucket "$1"; then + if ! setup_bucket_v2 "$1"; then log 2 "error setting up bucket" return 1 fi diff --git a/tests/test_rest.sh b/tests/test_rest.sh index 2f3bb42..9ec973c 100755 --- a/tests/test_rest.sh +++ b/tests/test_rest.sh @@ -31,12 +31,13 @@ source ./tests/commands/put_object_retention.sh source ./tests/commands/put_object_tagging.sh source ./tests/drivers/create_bucket/create_bucket_rest.sh source ./tests/drivers/copy_object/copy_object_rest.sh +source ./tests/drivers/get_object_attributes/get_object_attributes_rest.sh source ./tests/drivers/get_bucket_ownership_controls/get_bucket_ownership_controls_rest.sh source ./tests/drivers/head_object/head_object_rest.sh +source ./tests/drivers/file.sh source ./tests/drivers/xml.sh source ./tests/logger.sh source ./tests/setup.sh -source ./tests/util/util_attributes.sh source ./tests/util/util_chunked_upload.sh source ./tests/util/util_delete_object.sh source ./tests/util/util_legal_hold.sh @@ -58,30 +59,38 @@ export RUN_USERS=true test_file="test_file" @test "test_rest_list_objects" { - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run list_check_objects_rest "$BUCKET_ONE_NAME" + run list_check_objects_rest "$bucket_name" assert_success } @test "test_rest_delete_object" { - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" + run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" assert_success - run delete_object "rest" "$BUCKET_ONE_NAME" "$test_file" + run delete_object "rest" "$bucket_name" "$test_file" assert_success - run get_object "rest" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" + run get_object "rest" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" assert_failure } @@ -89,22 +98,26 @@ test_file="test_file" test_key="TestKey" test_value="TestValue" - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run put_object_tagging "rest" "$BUCKET_ONE_NAME" "$test_file" "$test_key" "$test_value" + run put_object_tagging "rest" "$bucket_name" "$test_file" "$test_key" "$test_value" assert_success - run check_verify_object_tags "rest" "$BUCKET_ONE_NAME" "$test_file" "$test_key" "$test_value" + run check_verify_object_tags "rest" "$bucket_name" "$test_file" "$test_key" "$test_value" assert_success - run delete_object_tagging "rest" "$BUCKET_ONE_NAME" "$test_file" + run delete_object_tagging "rest" "$bucket_name" "$test_file" assert_success - run verify_no_object_tags "rest" "$BUCKET_ONE_NAME" "$test_file" + run verify_no_object_tags "rest" "$bucket_name" "$test_file" assert_success } @@ -112,13 +125,17 @@ test_file="test_file" test_key="TestKey" test_value="TestValue" - run setup_bucket_object_lock_enabled "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_object_lock_enabled_v2 "$bucket_name" assert_success run create_test_files "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success if ! five_seconds_later=$(get_time_seconds_in_future 5 "%z"); then @@ -126,7 +143,7 @@ test_file="test_file" return 1 fi log 5 "later: $five_seconds_later" - run put_object_retention_rest "$BUCKET_ONE_NAME" "$test_file" "GOVERNANCE" "$five_seconds_later" + run put_object_retention_rest "$bucket_name" "$test_file" "GOVERNANCE" "$five_seconds_later" assert_success } @@ -134,27 +151,35 @@ test_file="test_file" if [ "$RECREATE_BUCKETS" == "false" ]; then skip "test requires object lock not to be enabled" fi - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run check_legal_hold_without_lock_enabled "$BUCKET_ONE_NAME" "$test_file" "InvalidRequest" + run check_legal_hold_without_lock_enabled "$bucket_name" "$test_file" "InvalidRequest" assert_success } @test "REST - legal hold, object lock enabled w/o specific object lock set" { - run setup_bucket_object_lock_enabled "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_object_lock_enabled_v2 "$bucket_name" assert_success run create_test_file "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run check_legal_hold_without_lock_enabled "$BUCKET_ONE_NAME" "$test_file" "NoSuchObjectLockConfiguration" + run check_legal_hold_without_lock_enabled "$bucket_name" "$test_file" "NoSuchObjectLockConfiguration" assert_success } @@ -162,7 +187,11 @@ test_file="test_file" if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1001" fi - run setup_bucket_and_large_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_large_file_v2 "$bucket_name" "$test_file" assert_success # shellcheck disable=SC2034 @@ -171,7 +200,7 @@ test_file="test_file" run split_file "$TEST_FILE_FOLDER/$test_file" 4 assert_success - run upload_and_check_attributes "$test_file" "$file_size" + run upload_and_check_attributes "$bucket_name" "$test_file" "$file_size" assert_success } @@ -179,21 +208,29 @@ test_file="test_file" if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1001" fi - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run check_attributes_invalid_param "$test_file" + run check_attributes_invalid_param "$bucket_name" "$test_file" assert_success } @test "REST - attributes - checksum" { - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run add_and_check_checksum "$TEST_FILE_FOLDER/$test_file" "$test_file" + run add_and_check_checksum "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success } @@ -201,26 +238,30 @@ test_file="test_file" if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/993" fi + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + test_file_two="test_file_2" test_file_three="test_file_3" - run setup_bucket_and_files "$BUCKET_ONE_NAME" "$test_file" "$test_file_two" "$test_file_three" + run setup_bucket_and_files_v2 "$bucket_name" "$test_file" "$test_file_two" "$test_file_three" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file_two" "$BUCKET_ONE_NAME" "$test_file_two" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file_two" "$bucket_name" "$test_file_two" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file_three" "$BUCKET_ONE_NAME" "$test_file_three" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file_three" "$bucket_name" "$test_file_three" assert_success - run list_objects_check_params_get_token "$BUCKET_ONE_NAME" "$test_file" "$test_file_two" "TRUE" + run list_objects_check_params_get_token "$bucket_name" "$test_file" "$test_file_two" "TRUE" assert_success continuation_token=$output # interestingly, AWS appears to accept continuation tokens that are a few characters off, so have to remove three chars - run list_objects_check_continuation_error "$BUCKET_ONE_NAME" "${continuation_token:0:${#continuation_token}-3}" + run list_objects_check_continuation_error "$bucket_name" "${continuation_token:0:${#continuation_token}-3}" assert_success } @@ -228,32 +269,40 @@ test_file="test_file" if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/999" fi + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + test_file_two="test_file_2" - run setup_bucket_and_files "$BUCKET_ONE_NAME" "$test_file" "$test_file_two" + run setup_bucket_and_files_v2 "$bucket_name" "$test_file" "$test_file_two" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file_two" "$BUCKET_ONE_NAME" "$test_file_two" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file_two" "$bucket_name" "$test_file_two" assert_success - run list_objects_v1_check_nextmarker_empty "$BUCKET_ONE_NAME" + run list_objects_v1_check_nextmarker_empty "$bucket_name" assert_success } @test "REST - head object" { - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run get_etag_rest "$BUCKET_ONE_NAME" "$test_file" + run get_etag_rest "$bucket_name" "$test_file" assert_success expected_etag=$output - run get_etag_attribute_rest "$BUCKET_ONE_NAME" "$test_file" "$expected_etag" + run get_etag_attribute_rest "$bucket_name" "$test_file" "$expected_etag" assert_success } @@ -261,51 +310,63 @@ test_file="test_file" if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1040" fi - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run delete_objects_no_content_md5_header "$BUCKET_ONE_NAME" + run delete_objects_no_content_md5_header "$bucket_name" assert_success } @test "REST - delete objects command" { + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + test_file_two="test_file_two" - run setup_bucket_and_files "$BUCKET_ONE_NAME" "$test_file" "$test_file_two" + run setup_bucket_and_files_v2 "$bucket_name" "$test_file" "$test_file_two" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file_two" "$BUCKET_ONE_NAME" "$test_file_two" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file_two" "$bucket_name" "$test_file_two" assert_success - run verify_object_exists "$BUCKET_ONE_NAME" "$test_file" + run verify_object_exists "$bucket_name" "$test_file" assert_success - run verify_object_exists "$BUCKET_ONE_NAME" "$test_file_two" + run verify_object_exists "$bucket_name" "$test_file_two" assert_success - run delete_objects_verify_success "$BUCKET_ONE_NAME" "$test_file" "$test_file_two" + run delete_objects_verify_success "$bucket_name" "$test_file" "$test_file_two" assert_success - run verify_object_not_found "$BUCKET_ONE_NAME" "$test_file" + run verify_object_not_found "$bucket_name" "$test_file" assert_success - run verify_object_not_found "$BUCKET_ONE_NAME" "$test_file_two" + run verify_object_not_found "$bucket_name" "$test_file_two" assert_success } @test "REST - PutObjectRetention - w/o request body" { - run setup_bucket_object_lock_enabled "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_object_lock_enabled_v2 "$bucket_name" assert_success run create_test_file "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run retention_rest_without_request_body "$BUCKET_ONE_NAME" "$test_file" + run retention_rest_without_request_body "$bucket_name" "$test_file" assert_success } @@ -313,55 +374,71 @@ test_file="test_file" if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1311" fi - run setup_bucket_object_lock_enabled "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_object_lock_enabled_v2 "$bucket_name" assert_success run create_test_file "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run check_legal_hold_without_content_md5 "$BUCKET_ONE_NAME" "$test_file" + run check_legal_hold_without_content_md5 "$bucket_name" "$test_file" assert_success } @test "REST - PutObjectLegalHold w/o payload" { - run setup_bucket_object_lock_enabled "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_object_lock_enabled_v2 "$bucket_name" assert_success run create_test_file "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run check_legal_hold_without_payload "$BUCKET_ONE_NAME" "$test_file" + run check_legal_hold_without_payload "$bucket_name" "$test_file" assert_success } @test "REST - PutObjectLegalHold - success" { - run setup_bucket_object_lock_enabled "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_object_lock_enabled_v2 "$bucket_name" assert_success run create_test_file "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run rest_check_legal_hold "$BUCKET_ONE_NAME" "$test_file" + run rest_check_legal_hold "$bucket_name" "$test_file" assert_success } @test "REST - copy object w/invalid copy source" { - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run copy_object_invalid_copy_source "$BUCKET_ONE_NAME" + run copy_object_invalid_copy_source "$bucket_name" assert_success } @@ -369,52 +446,68 @@ test_file="test_file" if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1242" fi - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run copy_object_copy_source_and_payload "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file" + run copy_object_copy_source_and_payload "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file" assert_success } @test "REST - range download and compare" { - run setup_bucket_and_large_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_large_file_v2 "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" 2000000 + run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" 2000000 assert_success } @test "REST - put, get object, encoded name" { + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + file_name=" \"<>\\^\`{}|+&?%" - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$file_name" + run setup_bucket_and_file_v2 "$bucket_name" "$file_name" assert_success - run put_object_rest_special_chars "$TEST_FILE_FOLDER/$file_name" "$BUCKET_ONE_NAME" "$file_name/$file_name" + run put_object_rest_special_chars "$TEST_FILE_FOLDER/$file_name" "$bucket_name" "$file_name/$file_name" assert_success - run list_check_single_object "$BUCKET_ONE_NAME" "$file_name/$file_name" + run list_check_single_object "$bucket_name" "$file_name/$file_name" assert_success - run get_object_rest_special_chars "$BUCKET_ONE_NAME" "$file_name/$file_name" "$TEST_FILE_FOLDER/${file_name}-copy" + run get_object_rest_special_chars "$bucket_name" "$file_name/$file_name" "$TEST_FILE_FOLDER/${file_name}-copy" assert_success run compare_files "$TEST_FILE_FOLDER/$file_name" "$TEST_FILE_FOLDER/${file_name}-copy" assert_success - run delete_object_rest "$BUCKET_ONE_NAME" "$file_name/$file_name" + run delete_object_rest "$bucket_name" "$file_name/$file_name" assert_success } @test "REST - GetObject w/STREAMING-AWS4-HMAC-SHA256-PAYLOAD type" { - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run get_object_rest_with_invalid_streaming_type "$BUCKET_ONE_NAME" "$test_file" + run get_object_rest_with_invalid_streaming_type "$bucket_name" "$test_file" assert_success } diff --git a/tests/test_rest_acl.sh b/tests/test_rest_acl.sh index 4753a4a..15df0cd 100755 --- a/tests/test_rest_acl.sh +++ b/tests/test_rest_acl.sh @@ -18,6 +18,7 @@ load ./bats-support/load load ./bats-assert/load source ./tests/commands/put_object.sh +source ./tests/drivers/file.sh source ./tests/drivers/create_bucket/create_bucket_rest.sh source ./tests/drivers/get_bucket_acl/get_bucket_acl_rest.sh source ./tests/logger.sh @@ -34,22 +35,30 @@ if [ "$SKIP_ACL_TESTING" == "true" ] || [ "$SKIP_USERS_TESTS" == "true" ]; then fi @test "REST - get ACL" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run get_and_check_acl_rest "$BUCKET_ONE_NAME" + run get_and_check_acl_rest "$bucket_name" assert_success } @test "REST - put ACL" { + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + test_file="test_file" - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred" + run put_bucket_ownership_controls "$bucket_name" "BucketOwnerPreferred" assert_success - run put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE" @@ -62,29 +71,33 @@ fi run setup_acl "$TEST_FILE_FOLDER/acl-file.txt" "CanonicalUser" "$user_canonical_id" "READ" "$canonical_id" assert_success - run list_objects_with_user_rest_verify_access_denied "$BUCKET_ONE_NAME" "$username" "$password" + run list_objects_with_user_rest_verify_access_denied "$bucket_name" "$username" "$password" assert_success - run put_bucket_acl_rest "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER/acl-file.txt" + run put_bucket_acl_rest "$bucket_name" "$TEST_FILE_FOLDER/acl-file.txt" assert_success if [ "$DIRECT" == "true" ]; then sleep 5 fi - run list_objects_with_user_rest_verify_success "$BUCKET_ONE_NAME" "$username" "$password" "$test_file" + run list_objects_with_user_rest_verify_success "$bucket_name" "$username" "$password" "$test_file" assert_success } @test "REST - put public-read canned acl" { + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + test_file="test_file" - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred" + run put_bucket_ownership_controls "$bucket_name" "BucketOwnerPreferred" assert_success - run put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE" @@ -94,25 +107,29 @@ fi username=${lines[2]} password=${lines[3]} - run list_objects_with_user_rest_verify_access_denied "$BUCKET_ONE_NAME" "$username" "$password" + run list_objects_with_user_rest_verify_access_denied "$bucket_name" "$username" "$password" assert_success if [ "$DIRECT" == "true" ]; then - run allow_public_access "$BUCKET_ONE_NAME" + run allow_public_access "$bucket_name" assert_success fi - run put_canned_acl_rest "$BUCKET_ONE_NAME" "public-read" + run put_canned_acl_rest "$bucket_name" "public-read" assert_success - run list_objects_with_user_rest_verify_success "$BUCKET_ONE_NAME" "$username" "$password" "$test_file" + run list_objects_with_user_rest_verify_success "$bucket_name" "$username" "$password" "$test_file" assert_success } @test "REST - put invalid ACL" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred" + run put_bucket_ownership_controls "$bucket_name" "BucketOwnerPreferred" assert_success run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE" @@ -126,19 +143,23 @@ fi assert_success if [ "$DIRECT" == "true" ]; then - run allow_public_access "$BUCKET_ONE_NAME" + run allow_public_access "$bucket_name" assert_success fi - run put_invalid_acl_rest_verify_failure "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER/acl-file.txt" + run put_invalid_acl_rest_verify_failure "$bucket_name" "$TEST_FILE_FOLDER/acl-file.txt" assert_success } @test "REST - put public-read-write canned acl" { + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + test_file="test_file" - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred" + run put_bucket_ownership_controls "$bucket_name" "BucketOwnerPreferred" assert_success run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE" @@ -148,17 +169,17 @@ fi username=${lines[2]} password=${lines[3]} - run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$username" "$password" + run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$username" "$password" assert_failure if [ "$DIRECT" == "true" ]; then - run allow_public_access "$BUCKET_ONE_NAME" + run allow_public_access "$bucket_name" assert_success fi - run put_canned_acl_rest "$BUCKET_ONE_NAME" "public-read-write" + run put_canned_acl_rest "$bucket_name" "public-read-write" assert_success - run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$username" "$password" + run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$username" "$password" assert_success } @@ -166,14 +187,18 @@ fi if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1367" fi + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + test_file="test_file" - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred" + run put_bucket_ownership_controls "$bucket_name" "BucketOwnerPreferred" assert_success - run put_bucket_acl_rest_canned_invalid "$BUCKET_ONE_NAME" "privatee" + run put_bucket_acl_rest_canned_invalid "$bucket_name" "privatee" assert_success } @@ -181,6 +206,10 @@ fi if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1407" fi + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE" assert_success canonical_id=${lines[0]} @@ -188,7 +217,7 @@ fi username=${lines[2]} password=${lines[3]} - run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME" + run bucket_cleanup_if_bucket_exists "$bucket_name" assert_success if [ "$DIRECT" == "true" ]; then id="id=$user_canonical_id" @@ -197,9 +226,9 @@ fi fi envs="GRANT_READ_ACP=$id OBJECT_OWNERSHIP=BucketOwnerPreferred" - run create_bucket_rest_expect_success "$BUCKET_ONE_NAME" "$envs" + run create_bucket_rest_expect_success "$bucket_name" "$envs" assert_success - run get_bucket_acl_rest "$BUCKET_ONE_NAME" "" "check_that_acl_xml_does_not_have_owner_permission" + run get_bucket_acl_rest "$bucket_name" "" "check_that_acl_xml_does_not_have_owner_permission" assert_success } diff --git a/tests/test_rest_bucket.sh b/tests/test_rest_bucket.sh index 06ebfd4..9982ad9 100755 --- a/tests/test_rest_bucket.sh +++ b/tests/test_rest_bucket.sh @@ -43,7 +43,6 @@ export RUN_USERS=true run setup_bucket_v2 "$bucket_name" assert_success - bucket_name="${lines[${#lines[@]} - 1]}" run head_bucket_rest "$bucket_name" assert_success @@ -55,10 +54,14 @@ export RUN_USERS=true } @test "REST - bucket tagging - no tags" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run verify_no_bucket_tags_rest "$BUCKET_ONE_NAME" + run verify_no_bucket_tags_rest "$bucket_name" assert_success } @@ -66,38 +69,52 @@ export RUN_USERS=true test_key="testKey" test_value="testValue" - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run add_verify_bucket_tags_rest "$BUCKET_ONE_NAME" "$test_key" "$test_value" + run add_verify_bucket_tags_rest "$bucket_name" "$test_key" "$test_value" assert_success } @test "REST - get, put bucket ownership controls" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run get_and_check_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerEnforced" + run get_and_check_ownership_controls "$bucket_name" "BucketOwnerEnforced" assert_success - run put_bucket_ownership_controls_rest "$BUCKET_ONE_NAME" "BucketOwnerPreferred" + run put_bucket_ownership_controls_rest "$bucket_name" "BucketOwnerPreferred" assert_success - run get_and_check_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred" + run get_and_check_ownership_controls "$bucket_name" "BucketOwnerPreferred" assert_success } @test "test_rest_set_get_lock_config" { - run setup_bucket_v2 "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - bucket_name="${lines[${#lines[@]} - 1]}" run check_no_object_lock_config_rest "$bucket_name" assert_success - run setup_bucket_object_lock_enabled_v2 "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_two_name="$output" + + run setup_bucket_object_lock_enabled_v2 "$bucket_two_name" assert_success - bucket_two_name="${lines[${#lines[@]} - 1]}" run check_object_lock_config_enabled_rest "$bucket_two_name" assert_success @@ -107,14 +124,18 @@ export RUN_USERS=true if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1300" fi - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run put_bucket_versioning_rest "$BUCKET_ONE_NAME" "Enabled" + run put_bucket_versioning_rest "$bucket_name" "Enabled" assert_success # this enables object lock without a specific retention policy - run remove_retention_policy_rest "$BUCKET_ONE_NAME" + run remove_retention_policy_rest "$bucket_name" assert_success } @@ -122,21 +143,15 @@ export RUN_USERS=true if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1301" fi - run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_object_lock_enabled_v2 "$bucket_name" assert_success - # in static bucket config, bucket will still exist - if ! bucket_exists "$BUCKET_ONE_NAME"; then - run create_bucket_object_lock_enabled "$BUCKET_ONE_NAME" - assert_success - fi - - if [ "$DIRECT" == "true" ]; then - sleep 5 - fi - # this enables object lock without a specific retention policy - run put_object_lock_config_without_content_md5 "$BUCKET_ONE_NAME" + run put_object_lock_config_without_content_md5 "$bucket_name" assert_success } @@ -144,11 +159,14 @@ export RUN_USERS=true if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/959" fi + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" - run setup_bucket "$BUCKET_ONE_NAME" + run setup_bucket_v2 "$bucket_name" assert_success - run get_and_check_no_policy_error "$BUCKET_ONE_NAME" + run get_and_check_no_policy_error "$bucket_name" assert_success } @@ -156,20 +174,24 @@ export RUN_USERS=true if [ "$SKIP_USERS_TESTS" == "true" ]; then skip fi - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run setup_user_versitygw_or_direct "$USERNAME_ONE" "$PASSWORD_ONE" "user" "$BUCKET_ONE_NAME" + run setup_user_versitygw_or_direct "$USERNAME_ONE" "$PASSWORD_ONE" "user" "$bucket_name" assert_success log 5 "username: ${lines[1]}" log 5 "password: ${lines[2]}" sleep 5 - run setup_policy_with_single_statement "$TEST_FILE_FOLDER/policy_file.txt" "2012-10-17" "Allow" "$USERNAME_ONE" "s3:PutBucketTagging" "arn:aws:s3:::$BUCKET_ONE_NAME" + run setup_policy_with_single_statement "$TEST_FILE_FOLDER/policy_file.txt" "2012-10-17" "Allow" "$USERNAME_ONE" "s3:PutBucketTagging" "arn:aws:s3:::$bucket_name" assert_success - run put_and_check_policy_rest "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER/policy_file.txt" "Allow" "$USERNAME_ONE" "s3:PutBucketTagging" "arn:aws:s3:::$BUCKET_ONE_NAME" + run put_and_check_policy_rest "$bucket_name" "$TEST_FILE_FOLDER/policy_file.txt" "Allow" "$USERNAME_ONE" "s3:PutBucketTagging" "arn:aws:s3:::$bucket_name" assert_success } @@ -185,18 +207,26 @@ export RUN_USERS=true if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1521" fi - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run send_rest_go_command_expect_error "400" "InvalidRequest" "Missing required header" "-bucketName" "$BUCKET_ONE_NAME" "-query" "tagging=" "-method" "PUT" + run send_rest_go_command_expect_error "400" "InvalidRequest" "Missing required header" "-bucketName" "$bucket_name" "-query" "tagging=" "-method" "PUT" assert_success } @test "REST - PutBucketTagging - invalid Content-MD5" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run send_rest_go_command_expect_error "400" "InvalidDigest" "you specified" "-bucketName" "$BUCKET_ONE_NAME" "-query" "tagging=" "-method" "PUT" "-signedParams" "Content-MD5:dummy" \ + run send_rest_go_command_expect_error "400" "InvalidDigest" "you specified" "-bucketName" "$bucket_name" "-query" "tagging=" "-method" "PUT" "-signedParams" "Content-MD5:dummy" \ "-payload" "keyvalue" assert_success } @@ -205,10 +235,14 @@ export RUN_USERS=true if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1526" fi - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket "$bucket_name" assert_success - run send_put_bucket_tagging_command_check_invalid_content_md5 "$BUCKET_ONE_NAME" + run send_put_bucket_tagging_command_check_invalid_content_md5 "$bucket_name" assert_success } @@ -216,10 +250,14 @@ export RUN_USERS=true if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1525" fi - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket "$bucket_name" assert_success - run send_rest_go_command_expect_error "400" "BadDigest" "did not match" "-bucketName" "$BUCKET_ONE_NAME" "-query" "tagging=" "-method" "PUT" "-incorrectContentMD5" \ + run send_rest_go_command_expect_error "400" "BadDigest" "did not match" "-bucketName" "$bucket_name" "-query" "tagging=" "-method" "PUT" "-incorrectContentMD5" \ "-payload" "keyvalue" assert_success } diff --git a/tests/test_rest_checksum.sh b/tests/test_rest_checksum.sh index 6691f83..50b7d00 100755 --- a/tests/test_rest_checksum.sh +++ b/tests/test_rest_checksum.sh @@ -17,6 +17,8 @@ load ./bats-support/load load ./bats-assert/load +source ./tests/drivers/file.sh +source ./tests/drivers/create_bucket/create_bucket_rest.sh source ./tests/setup.sh source ./tests/util/util_setup.sh @@ -24,10 +26,14 @@ export RUN_USERS=true test_file="test_file" @test "REST - invalid checksum type" { - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run check_invalid_checksum_type "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run check_invalid_checksum_type "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success } @@ -47,13 +53,17 @@ test_file="test_file" } @test "REST - HeadObject returns x-amz-checksum-sha256" { - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_object_rest_checksum "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "sha256" + run put_object_rest_checksum "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "sha256" assert_success - run check_checksum_rest_sha256 "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file" + run check_checksum_rest_sha256 "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file" assert_success } @@ -73,13 +83,17 @@ test_file="test_file" } @test "REST - crc32 checksum - HeadObject" { - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_object_rest_checksum "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "crc32" + run put_object_rest_checksum "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "crc32" assert_success - run check_checksum_rest_crc32 "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file" + run check_checksum_rest_crc32 "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file" assert_success } @@ -129,23 +143,31 @@ test_file="test_file" } @test "REST - attempt to get checksum without checksum mode" { - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run add_correct_checksum "sha256" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run head_object_without_and_with_checksum "$BUCKET_ONE_NAME" "$test_file" + run head_object_without_and_with_checksum "$bucket_name" "$test_file" assert_success } @test "REST - HeadObject - default crc64nvme checksum" { - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run check_default_checksum "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file" + run check_default_checksum "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file" assert_success } diff --git a/tests/test_rest_chunked.sh b/tests/test_rest_chunked.sh index 0c1f6bf..8e4173c 100755 --- a/tests/test_rest_chunked.sh +++ b/tests/test_rest_chunked.sh @@ -19,101 +19,131 @@ load ./bats-assert/load source ./tests/logger.sh source ./tests/setup.sh +source ./tests/drivers/file.sh +source ./tests/drivers/create_bucket/create_bucket_rest.sh source ./tests/util/util_bucket.sh source ./tests/util/util_chunked_upload.sh source ./tests/util/util_file.sh source ./tests/util/util_setup.sh @test "REST - chunked upload, no content length" { + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + test_file="test-file" - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" assert_success - run attempt_seed_signature_without_content_length "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run attempt_seed_signature_without_content_length "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success } @test "REST - chunked upload, signature error" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success test_file="test-file" run create_test_file "$test_file" 8192 assert_success - run attempt_chunked_upload_with_bad_first_signature "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run attempt_chunked_upload_with_bad_first_signature "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success } @test "REST - chunked upload, final signature error" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success test_file="test-file" run create_test_file "$test_file" 0 assert_success - run attempt_chunked_upload_with_bad_final_signature "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run attempt_chunked_upload_with_bad_final_signature "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success } @test "REST - chunked upload, success (file with just a's)" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success test_file="test-file" run create_file_single_char "$test_file" 8192 'a' assert_success - run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" + run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" assert_success } @test "REST - chunked upload, success (null bytes)" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success test_file="test-file" run create_file_single_char "$test_file" 8192 '\0' assert_success - run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" + run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" assert_success } @test "REST - chunked upload, success (random bytes)" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success test_file="test-file" run create_test_file "$test_file" 10000 assert_success - run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" + run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" assert_success } @test "REST - chunked upload, success (zero-byte file)" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success test_file="test-file" run create_test_file "$test_file" 0 assert_success - run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success - run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" + run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" assert_success } @@ -143,11 +173,15 @@ source ./tests/util/util_setup.sh } @test "test - REST chunked upload - invalid trailer" { + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + test_file="test-file" - run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file" + run setup_bucket_and_file "$bucket_name" "$test_file" assert_success - run put_chunked_upload_trailer_invalid "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" + run put_chunked_upload_trailer_invalid "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" assert_success } @@ -202,16 +236,20 @@ source ./tests/util/util_setup.sh } @test "REST chunked upload - smaller chunk size" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket "$bucket_name" assert_success test_file="test-file" run create_test_file "$test_file" 200000 assert_success - run chunked_upload_trailer_different_chunk_size "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "sha256" + run chunked_upload_trailer_different_chunk_size "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "sha256" assert_success - run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" + run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" assert_success } diff --git a/tests/test_rest_create_bucket.sh b/tests/test_rest_create_bucket.sh index 70bed40..42da752 100755 --- a/tests/test_rest_create_bucket.sh +++ b/tests/test_rest_create_bucket.sh @@ -28,13 +28,14 @@ export RUN_USERS=true if [ "$RECREATE_BUCKETS" == "false" ]; then skip "skip bucket create tests for static buckets" fi - run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run create_bucket_rest "$BUCKET_ONE_NAME" - assert_success - - run list_check_buckets_rest "$BUCKET_ONE_NAME" + run list_check_buckets_rest "$bucket_name" assert_success } @@ -45,11 +46,15 @@ export RUN_USERS=true if [ "$RECREATE_BUCKETS" == "false" ]; then skip "skip bucket create tests for static buckets" fi - run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run bucket_cleanup_if_bucket_exists_v2 "$BUCKET_ONE_NAME" assert_success envs="ACL=public-reads OBJECT_OWNERSHIP=BucketOwnerPreferred" - run create_bucket_rest_expect_error "$BUCKET_ONE_NAME" "$envs" "400" "InvalidArgument" "" + run create_bucket_rest_expect_error "$bucket_name" "$envs" "400" "InvalidArgument" "" assert_success } @@ -77,7 +82,7 @@ export RUN_USERS=true if [ "$RECREATE_BUCKETS" == "false" ]; then skip "skip bucket create tests for static buckets" fi - run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME" + run bucket_cleanup_if_bucket_exists_v2 "$BUCKET_ONE_NAME" assert_success if [ "$DIRECT" == "true" ]; then @@ -86,7 +91,12 @@ export RUN_USERS=true id="$AWS_ACCESS_KEY_ID" fi envs="GRANT_FULL_CONTROL=$id" - run create_bucket_rest_expect_error "$BUCKET_ONE_NAME" "$envs" "400" "InvalidBucketAclWithObjectOwnership" "Bucket cannot have ACLs set" + + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run create_bucket_rest_expect_error "$bucket_name" "$envs" "400" "InvalidBucketAclWithObjectOwnership" "Bucket cannot have ACLs set" assert_success } diff --git a/tests/test_rest_delete_bucket.sh b/tests/test_rest_delete_bucket.sh index c5c072f..ceadab3 100755 --- a/tests/test_rest_delete_bucket.sh +++ b/tests/test_rest_delete_bucket.sh @@ -18,54 +18,67 @@ load ./bats-support/load load ./bats-assert/load source ./tests/setup.sh +source ./tests/drivers/create_bucket/create_bucket_rest.sh source ./tests/drivers/delete_object/delete_object_rest.sh source ./tests/drivers/put_object/put_object_rest.sh @test "REST - DeleteBucket - can delete with partial multipart upload" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run create_multipart_upload_rest "$BUCKET_ONE_NAME" "test_file" "" + run create_multipart_upload_rest "$bucket_name" "test_file" "" "" assert_success - run delete_bucket_rest "$BUCKET_ONE_NAME" + run delete_bucket_rest "$bucket_name" assert_success } @test "REST - DeleteBucket - file - non-versioning" { - run setup_bucket_and_add_file "$BUCKET_ONE_NAME" "test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_add_file "$bucket_name" "test_file" assert_success - run delete_bucket_rest_expect_error "$BUCKET_ONE_NAME" "" "409" "BucketNotEmpty" "is not empty" + run delete_bucket_rest_expect_error "$bucket_name" "" "409" "BucketNotEmpty" "is not empty" assert_success - run delete_object_rest "$BUCKET_ONE_NAME" "test_file" + run delete_object_rest "$bucket_name" "test_file" assert_success - run delete_bucket_rest "$BUCKET_ONE_NAME" + run delete_bucket_rest "$bucket_name" assert_success } @test "REST - DeleteBucket - file - versioning" { - run setup_bucket_and_add_file "$BUCKET_ONE_NAME" "test_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_add_file "$bucket_name" "test_file" assert_success - run put_bucket_versioning_rest "$BUCKET_ONE_NAME" "Enabled" + run put_bucket_versioning_rest "$bucket_name" "Enabled" assert_success - run delete_bucket_rest_expect_error "$BUCKET_ONE_NAME" "" "409" "BucketNotEmpty" "is not empty" + run delete_bucket_rest_expect_error "$bucket_name" "" "409" "BucketNotEmpty" "is not empty" assert_success - run delete_object_rest "$BUCKET_ONE_NAME" "test_file" + run delete_object_rest "$bucket_name" "test_file" assert_success - run delete_bucket_rest_expect_error "$BUCKET_ONE_NAME" "" "409" "BucketNotEmpty" "is not empty" + run delete_bucket_rest_expect_error "$bucket_name" "" "409" "BucketNotEmpty" "is not empty" assert_success - run delete_old_versions "$BUCKET_ONE_NAME" + run delete_old_versions_base64 "$bucket_name" assert_success - run delete_bucket_rest "$BUCKET_ONE_NAME" + run delete_bucket_rest "$bucket_name" assert_success } @@ -73,10 +86,14 @@ source ./tests/drivers/put_object/put_object_rest.sh if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1428" fi - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket "$bucket_name" assert_success - run send_rest_go_command_expect_error "400" "InvalidBucketOwnerAWSAccountID" "value of the expected bucket owner" "-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-signedParams" "x-amz-expected-bucket-owner:01234567890" + run send_rest_go_command_expect_error "400" "InvalidBucketOwnerAWSAccountID" "value of the expected bucket owner" "-method" "DELETE" "-bucketName" "$bucket_name" "-signedParams" "x-amz-expected-bucket-owner:01234567890" assert_success } @@ -84,17 +101,25 @@ source ./tests/drivers/put_object/put_object_rest.sh if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1428" fi - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket "$bucket_name" assert_success - run send_rest_go_command_expect_error "403" "AccessDenied" "Access Denied" "-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-signedParams" "x-amz-expected-bucket-owner:012345678901" + run send_rest_go_command_expect_error "403" "AccessDenied" "Access Denied" "-method" "DELETE" "-bucketName" "$bucket_name" "-signedParams" "x-amz-expected-bucket-owner:012345678901" assert_success } @test "REST - DeleteBucket - correct x-amz-expected-bucket-owner" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket "$bucket_name" assert_success - run send_rest_go_command "204" "-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-signedParams" "x-amz-expected-bucket-owner:$AWS_USER_ID" + run send_rest_go_command "204" "-method" "DELETE" "-bucketName" "$bucket_name" "-signedParams" "x-amz-expected-bucket-owner:$AWS_USER_ID" assert_success } diff --git a/tests/test_rest_delete_bucket_ownership_controls.sh b/tests/test_rest_delete_bucket_ownership_controls.sh index 2b6f19a..9a9b276 100755 --- a/tests/test_rest_delete_bucket_ownership_controls.sh +++ b/tests/test_rest_delete_bucket_ownership_controls.sh @@ -17,6 +17,7 @@ load ./bats-support/load load ./bats-assert/load +source ./tests/drivers/create_bucket/create_bucket_rest.sh source ./tests/drivers/get_bucket_ownership_controls/get_bucket_ownership_controls_rest.sh source ./tests/drivers/user.sh source ./tests/setup.sh @@ -27,7 +28,11 @@ export RUN_USERS=true if [ "$SKIP_USERS_TESTS" == "true" ]; then skip fi - run setup_bucket_and_user_v2 "$BUCKET_ONE_NAME" "$USERNAME_ONE" "$PASSWORD_ONE" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_and_user_v2 "$bucket_name" "$USERNAME_ONE" "$PASSWORD_ONE" assert_success username=${lines[${#lines[@]}-2]} password=${lines[${#lines[@]}-1]} @@ -35,7 +40,7 @@ export RUN_USERS=true log 5 "username: $username, password: $password" run send_rest_go_command_expect_error "403" "AccessDenied" "Access Denied" "-awsAccessKeyId" "$username" "-awsSecretAccessKey" "$password" \ - "-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-query" "ownershipControls=" + "-method" "DELETE" "-bucketName" "$bucket_name" "-query" "ownershipControls=" assert_success } @@ -43,33 +48,41 @@ export RUN_USERS=true if [ "$SKIP_USERS_TESTS" == "true" ]; then skip fi - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success username="invalid with spaces" password="dummy" run send_rest_go_command_expect_error "403" "InvalidAccessKeyId" "does not exist in our records" "-awsAccessKeyId" "$username" "-awsSecretAccessKey" "$password" \ - "-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-query" "ownershipControls=" + "-method" "DELETE" "-bucketName" "$bucket_name" "-query" "ownershipControls=" assert_success } @test "REST - DeleteBucketOwnershipControls - success" { - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket_v2 "$bucket_name" assert_success - run put_bucket_ownership_controls_rest "$BUCKET_ONE_NAME" "BucketOwnerPreferred" + run put_bucket_ownership_controls_rest "$bucket_name" "BucketOwnerPreferred" assert_success - run get_bucket_ownership_controls_rest "$BUCKET_ONE_NAME" + run get_bucket_ownership_controls_rest "$bucket_name" assert_success rule=${output[${#output[@]}-1]} assert_equal "$rule" "BucketOwnerPreferred" - run send_rest_go_command "204" "-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-query" "ownershipControls=" + run send_rest_go_command "204" "-method" "DELETE" "-bucketName" "$bucket_name" "-query" "ownershipControls=" assert_success - run get_bucket_ownership_controls_rest "$BUCKET_ONE_NAME" + run get_bucket_ownership_controls_rest "$bucket_name" assert_success rule=${output[${#output[@]}-1]} assert_equal "$rule" "" @@ -79,15 +92,19 @@ export RUN_USERS=true if [ "$DIRECT" != "true" ]; then skip "https://github.com/versity/versitygw/issues/1493" fi - run setup_bucket "$BUCKET_ONE_NAME" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run setup_bucket "$bucket_name" assert_success if ! send_rest_go_command "204" \ - "-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-query" "ownershipControls="; then + "-method" "DELETE" "-bucketName" "$bucket_name" "-query" "ownershipControls="; then log 2 "error deleting ownership controls" return 1 fi - run get_bucket_ownership_controls_check_error_after_deletion "$BUCKET_ONE_NAME" + run get_bucket_ownership_controls_check_error_after_deletion "$bucket_name" assert_success } diff --git a/tests/util/util_bucket.sh b/tests/util/util_bucket.sh index 468c646..400016d 100644 --- a/tests/util/util_bucket.sh +++ b/tests/util/util_bucket.sh @@ -64,26 +64,6 @@ reset_bucket() { fi } -# params: bucket name -# return 0 if able to delete recursively, 1 if not -delete_bucket_recursive() { - log 6 "delete_bucket_recursive '$1'" - if ! check_param_count "delete_bucket_recursive_s3api" "bucket" 1 $#; then - return 1 - fi - - if ! reset_bucket "$1"; then - log 2 "error clearing bucket (s3api)" - return 1 - fi - - if ! delete_bucket_rest "$1"; then - log 2 "error deleting bucket" - return 1 - fi - return 0 -} - # check if bucket exists # param: bucket name # return 0 for true, 1 for false, 2 for error @@ -144,10 +124,6 @@ setup_bucket() { log 5 "util.setup_bucket: bucket name: $1" if [[ $RECREATE_BUCKETS == "true" ]]; then - if [ "$DIRECT" == "true" ]; then - log 2 "bucket not successfully deleted" - return 1 - fi if ! create_bucket "s3api" "$1"; then log 2 "error creating bucket" return 1 diff --git a/tests/util/util_chunked_upload.sh b/tests/util/util_chunked_upload.sh index 3a17c40..413954d 100644 --- a/tests/util/util_chunked_upload.sh +++ b/tests/util/util_chunked_upload.sh @@ -44,28 +44,31 @@ attempt_chunked_upload_with_bad_first_signature() { log 2 "error sending command via openssl" return 1 fi - response_code="$(echo "$result" | grep "HTTP" | awk '{print $2}')" - log 5 "response code: $response_code" - if [ "$response_code" != "403" ]; then - log 2 "expected code '403', was '$response_code'" - return 1 - fi log 5 "result: $result" - response_data="$(echo "$result" | grep "")" - response_data="${response_data/---/}" - log 5 "response data: $response_data" - log 5 "END" - echo -n "$response_data" > "$TEST_FILE_FOLDER/response_data.txt" - if ! check_xml_element "$TEST_FILE_FOLDER/response_data.txt" "SignatureDoesNotMatch" "Error" "Code"; then - log 2 "error checking XML element" + echo -n "$result" > "$TEST_FILE_FOLDER/result.txt" + if ! get_xml_data "$TEST_FILE_FOLDER/result.txt" "$TEST_FILE_FOLDER/error_data.txt"; then + log 2 "error parsing XML data from result" return 1 fi + response_code="$(echo "$result" | grep "HTTP" | awk '{print $2}')" + if ! check_rest_expected_error "$response_code" "$TEST_FILE_FOLDER/error_data.txt" "403" "SignatureDoesNotMatch" "does not match"; then + log 2 "error checking expected REST error" + return 1 + fi + #response_data="$(echo "$result" | grep "")" + #response_data="${response_data/---/}" + #log 5 "response data: $response_data" + #log 5 "END" + #echo -n "$response_data" > "$TEST_FILE_FOLDER/response_data.txt" + #if ! check_xml_element "$TEST_FILE_FOLDER/response_data.txt" "SignatureDoesNotMatch" "Error" "Code"; then + # log 2 "error checking XML element" + # return 1 + #fi return 0 } chunked_upload_success() { - if [ $# -ne 3 ]; then - log 2 "'chunked_upload_success_as' requires data file, bucket name, key" + if ! check_param_count_v2 "data file, bucket name, key" 3 $#; then return 1 fi if ! result=$(COMMAND_LOG="$COMMAND_LOG" \ @@ -191,7 +194,11 @@ chunked_upload_trailer_success() { log 2 "'chunked_upload_trailer_success' requires checksum" return 1 fi - if ! setup_bucket "$BUCKET_ONE_NAME"; then + if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then + log 2 "error getting bucket name: $bucket_name" + return 1 + fi + if ! setup_bucket "$bucket_name"; then log 2 "error setting up bucket" return 1 fi @@ -200,11 +207,11 @@ chunked_upload_trailer_success() { log 2 "error creating test file" return 1 fi - if ! put_object_chunked_trailer_success "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$1"; then + if ! put_object_chunked_trailer_success "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$1"; then log 2 "error performing chunked upload w/trailer" return 1 fi - if ! download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"; then + if ! download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"; then log 2 "error downloading and comparing file" return 1 fi @@ -216,7 +223,11 @@ chunked_upload_trailer_invalid_checksum() { log 2 "'chunked_upload_trailer_invalid_checksum' requires checksum" return 1 fi - if ! setup_bucket "$BUCKET_ONE_NAME"; then + if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then + log 2 "error getting bucket name: $bucket_name" + return 1 + fi + if ! setup_bucket "$bucket_name"; then log 2 "error setting up bucket" return 1 fi @@ -231,7 +242,7 @@ chunked_upload_trailer_invalid_checksum() { AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \ AWS_ENDPOINT_URL="$AWS_ENDPOINT_URL" \ DATA_FILE="$TEST_FILE_FOLDER/$test_file" \ - BUCKET_NAME="$BUCKET_ONE_NAME" \ + BUCKET_NAME="$bucket_name" \ OBJECT_KEY="$test_file" CHUNK_SIZE=8192 TEST_MODE=false TRAILER="x-amz-checksum-$1" CHECKSUM="a" TEST_FILE_FOLDER="$TEST_FILE_FOLDER" COMMAND_FILE="$TEST_FILE_FOLDER/command.txt" ./tests/rest_scripts/put_object_openssl_chunked_trailer_example.sh 2>&1); then log 2 "error creating command: $result" return 1 @@ -248,7 +259,11 @@ chunked_upload_trailer_incorrect_checksum() { log 2 "'chunked_upload_trailer_invalid_checksum' requires checksum" return 1 fi - if ! setup_bucket "$BUCKET_ONE_NAME"; then + if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then + log 2 "error getting bucket name: $bucket_name" + return 1 + fi + if ! setup_bucket "$bucket_name"; then log 2 "error setting up bucket" return 1 fi @@ -267,7 +282,7 @@ chunked_upload_trailer_incorrect_checksum() { AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \ AWS_ENDPOINT_URL="$AWS_ENDPOINT_URL" \ DATA_FILE="$TEST_FILE_FOLDER/$test_file" \ - BUCKET_NAME="$BUCKET_ONE_NAME" \ + BUCKET_NAME="$bucket_name" \ OBJECT_KEY="$test_file" CHUNK_SIZE=8192 TEST_MODE=false TRAILER="x-amz-checksum-$1" CHECKSUM="$checksum" TEST_FILE_FOLDER="$TEST_FILE_FOLDER" COMMAND_FILE="$TEST_FILE_FOLDER/command.txt" ./tests/rest_scripts/put_object_openssl_chunked_trailer_example.sh 2>&1); then log 2 "error creating command: $result" return 1 diff --git a/tests/util/util_object.sh b/tests/util/util_object.sh index 858ebf6..cbbbb2a 100644 --- a/tests/util/util_object.sh +++ b/tests/util/util_object.sh @@ -264,12 +264,18 @@ check_checksum_rest_invalid() { if ! check_param_count "check_checksum_rest_invalid" "checksum type" 1 $#; then return 1 fi + + if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then + log 2 "error getting bucket name: $bucket_name" + return 1 + fi + test_file="test_file" - if ! setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"; then + if ! setup_bucket_and_file_v2 "$bucket_name" "$test_file"; then log 2 "error setting up bucket and file" return 1 fi - if ! check_checksum_invalid_or_incorrect "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$1" "dummy" "Value for x-amz-checksum-$1 header is invalid."; then + if ! check_checksum_invalid_or_incorrect "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$1" "dummy" "Value for x-amz-checksum-$1 header is invalid."; then log 2 "error checking checksum" return 1 fi @@ -280,8 +286,14 @@ check_checksum_rest_incorrect() { if ! check_param_count "check_checksum_rest_incorrect" "checksum type" 1 $#; then return 1 fi + + if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then + log 2 "error getting bucket name: $bucket_name" + return 1 + fi + test_file="test_file" - if ! setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"; then + if ! setup_bucket_and_file "$bucket_name" "$test_file"; then log 2 "error setting up bucket and file" return 1 fi @@ -291,7 +303,7 @@ check_checksum_rest_incorrect() { log 2 "error calculating incorrect checksum" return 1 fi - if ! check_checksum_invalid_or_incorrect "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$1" "$incorrect_checksum" "$error_message"; then + if ! check_checksum_invalid_or_incorrect "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$1" "$incorrect_checksum" "$error_message"; then log 2 "error checking checksum" return 1 fi @@ -302,6 +314,7 @@ calculate_incorrect_checksum() { if ! check_param_count "calculate_incorrect_checksum" "checksum type, data file" 2 $#; then return 1 fi + if ! checksum=$(DATA_FILE="$2" CHECKSUM_TYPE="$1" TEST_FILE_FOLDER="$TEST_FILE_FOLDER" ./tests/rest_scripts/calculate_checksum.sh 2>&1); then log 2 "error calculating checksum: $checksum" return 1 @@ -334,13 +347,18 @@ add_correct_checksum() { if ! check_param_count "add_correct_checksum" "checksum type" 1 $#; then return 1 fi + if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then + log 2 "error getting bucket name: $bucket_name" + return 1 + fi + test_file="test_file" - if ! setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"; then + if ! setup_bucket_and_file "$bucket_name" "$test_file"; then log 2 "error setting up bucket and file" return 1 fi - if ! put_object_rest_checksum "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$1"; then + if ! put_object_rest_checksum "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$1"; then log 2 "error adding file with checksum to s3" return 1 fi diff --git a/tests/util/util_setup.sh b/tests/util/util_setup.sh index a6f120f..78902da 100644 --- a/tests/util/util_setup.sh +++ b/tests/util/util_setup.sh @@ -1,92 +1,5 @@ #!/usr/bin/env bash -source ./tests/drivers/params.sh - -setup_bucket_and_file() { - if ! check_param_count_v2 "bucket, file name" 2 $#; then - return 1 - fi - if ! setup_bucket_and_file_base "$1" "setup_bucket_and_files" "$2"; then - log 2 "error setting up bucket and file" - return 1 - fi - return 0 -} - -setup_bucket_and_file_v2() { - if ! check_param_count_v2 "bucket, file name" 2 $#; then - return 1 - fi - if ! setup_bucket_and_file_base "$1" "setup_bucket_and_files_v2" "$2"; then - log 2 "error setting up bucket and files" - return 1 - fi - return 0 -} - -setup_bucket_and_file_base() { - if ! check_param_count_v2 "bucket, function, file name" 3 $#; then - return 1 - fi - if ! "$2" "$1" "$3"; then - log 2 "error setting up bucket and file" - return 1 - fi - return 0 -} - -setup_bucket_and_files() { - if ! check_param_count_gt "bucket, file name" 2 $#; then - return 1 - fi - if ! setup_bucket_and_files_base "$1" "setup_bucket" "${@:2}"; then - log 2 "error setting up bucket and files" - return 1 - fi - return 0 -} - -setup_bucket_and_files_v2() { - if ! check_param_count_gt "bucket, file name" 2 $#; then - return 1 - fi - if ! setup_bucket_and_files_base "$1" "setup_bucket_v2" "${@:2}"; then - log 2 "error setting up bucket and files" - return 1 - fi - return 0 -} - -setup_bucket_and_files_base() { - if ! check_param_count_gt "bucket, setup bucket function, file name" 3 $#; then - return 1 - fi - if ! "$2" "$1"; then - log 2 "error setting up bucket" - return 1 - fi - if ! create_test_files "${@:3}"; then - log 2 "error creating test files" - return 1 - fi - return 0 -} - -setup_bucket_and_large_file() { - if ! check_param_count "setup_bucket_and_large_file" "bucket, file name" 2 $#; then - return 1 - fi - if ! setup_bucket "$1"; then - log 2 "error setting up bucket" - return 1 - fi - if ! create_large_file "$2"; then - log 2 "error creating large file" - return 1 - fi - return 0 -} - setup_bucket_file_and_user() { if ! check_param_count "setup_bucket_file_and_user" "bucket, file, username, password, user type" 5 $#; then return 1 diff --git a/tests/util/util_tags.sh b/tests/util/util_tags.sh index f77d7e5..13e95c6 100644 --- a/tests/util/util_tags.sh +++ b/tests/util/util_tags.sh @@ -283,7 +283,7 @@ add_verify_bucket_tags_rest() { log 2 "expected response code of '204', was '$result' (error: $(cat "$TEST_FILE_FOLDER/result.txt"))" return 1 fi - if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$BUCKET_ONE_NAME" OUTPUT_FILE="$TEST_FILE_FOLDER/bucket_tagging.txt" ./tests/rest_scripts/get_bucket_tagging.sh); then + if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OUTPUT_FILE="$TEST_FILE_FOLDER/bucket_tagging.txt" ./tests/rest_scripts/get_bucket_tagging.sh); then log 2 "error listing bucket tags: $result" return 1 fi