From 1f9856110d2883175b276d91bd2ce73b8f85e028 Mon Sep 17 00:00:00 2001 From: Luke McCrone Date: Fri, 16 Jan 2026 14:34:46 -0300 Subject: [PATCH] test: PutObject object lock tests and updates, delete bucket test --- tests/Dockerfile_test_bats | 1 + tests/commands/get_bucket_location.sh | 6 +- tests/commands/list_object_versions.sh | 11 ++ .../delete_object/delete_object_rest.sh | 27 ++++ .../get_bucket_location_rest.sh | 1 + .../list_object_versions_rest.sh | 30 +++-- tests/drivers/put_object/put_object.sh | 47 +++++++ tests/drivers/put_object/put_object_rest.sh | 42 ++++++ tests/drivers/rest.sh | 41 +++++- tests/setup.sh | 8 +- tests/test_rest_delete_bucket.sh | 23 ++++ tests/test_rest_delete_object.sh | 1 - tests/test_rest_list_objects.sh | 2 +- tests/test_rest_put_object.sh | 127 ++++++++++++++++++ tests/test_s3api_object.sh | 9 +- tests/test_s3api_root_inner.sh | 97 ++++++------- tests/util/util_get_object_retention.sh | 2 +- 17 files changed, 400 insertions(+), 75 deletions(-) create mode 100644 tests/drivers/put_object/put_object.sh diff --git a/tests/Dockerfile_test_bats b/tests/Dockerfile_test_bats index 1163c200..ee598f0c 100644 --- a/tests/Dockerfile_test_bats +++ b/tests/Dockerfile_test_bats @@ -25,6 +25,7 @@ RUN apt-get update && \ python3-pip \ python3-venv \ xxd \ + uuid-runtime \ ca-certificates && \ update-ca-certificates && \ rm -rf /var/lib/apt/lists/* diff --git a/tests/commands/get_bucket_location.sh b/tests/commands/get_bucket_location.sh index 46bbc59b..c12da68e 100644 --- a/tests/commands/get_bucket_location.sh +++ b/tests/commands/get_bucket_location.sh @@ -89,13 +89,9 @@ get_bucket_location_rest() { if ! check_param_count_v2 "bucket, callback" 2 $#; then return 1 fi - if ! send_rest_go_command "200" "-bucketName" "$1" "-method" "GET" "-query" "location=" "-awsRegion" "$AWS_REGION"; then + if ! send_rest_go_command_callback "200" "$2" "-bucketName" "$1" "-method" "GET" "-query" "location=" "-awsRegion" "$AWS_REGION"; then log 2 "error sending rest go command" return 1 fi - if [ "$2" != "" ] && ! "$2" "$TEST_FILE_FOLDER/result.txt"; then - log 2 "callback error" - return 1 - fi return 0 } \ No newline at end of file diff --git a/tests/commands/list_object_versions.sh b/tests/commands/list_object_versions.sh index 477e02ad..f9ee9200 100644 --- a/tests/commands/list_object_versions.sh +++ b/tests/commands/list_object_versions.sh @@ -48,4 +48,15 @@ list_object_versions_rest() { fi versions=$(cat "$TEST_FILE_FOLDER/object_versions.txt") return 0 +} + +list_object_versions_rest_v2() { + if ! check_param_count_v2 "bucket name, callback" 2 $#; then + return 1 + fi + if ! send_rest_go_command_callback "200" "$2" "-bucketName" "$1" "-query" "versions="; then + log 2 "error sending REST list object versions command" + return 1 + fi + return 0 } \ No newline at end of file diff --git a/tests/drivers/delete_object/delete_object_rest.sh b/tests/drivers/delete_object/delete_object_rest.sh index 953c9096..49f38410 100644 --- a/tests/drivers/delete_object/delete_object_rest.sh +++ b/tests/drivers/delete_object/delete_object_rest.sh @@ -150,3 +150,30 @@ attempt_to_delete_version_after_retention_policy() { return 1 fi } + +delete_delete_marker() { + if ! check_param_count_v2 "data file" 1 $#; then + return 1 + fi + if ! parse_version_or_delete_marker_id "$1" "DeleteMarker" "true"; then + echo "error parsing delete marker ID" + return 1 + fi + log 5 "version or marker ID: $version_or_marker_id" + if ! delete_object_version_rest "$bucket_name" "$object_key" "$version_or_marker_id"; then + log 2 "error deleting delete marker" + return 1 + fi +} + +delete_delete_marker_without_object_lock() { + if ! check_param_count_v2 "bucket name, key" 2 $#; then + return 1 + fi + bucket_name="$1" + object_key="$2" + if ! list_object_versions_rest_v2 "$bucket_name" "delete_delete_marker"; then + return 1 + fi + return 0 +} diff --git a/tests/drivers/get_bucket_location/get_bucket_location_rest.sh b/tests/drivers/get_bucket_location/get_bucket_location_rest.sh index 52d13afc..3a8180dd 100644 --- a/tests/drivers/get_bucket_location/get_bucket_location_rest.sh +++ b/tests/drivers/get_bucket_location/get_bucket_location_rest.sh @@ -51,6 +51,7 @@ parse_bucket_location() { if ! check_param_count_v2 "file" 1 $#; then return 1 fi + log 5 "file: $1" log 5 "data: $(cat "$1")" if ! location_constraint=$(get_element_text "$1" "LocationConstraint" 2>&1); then log 2 "error getting location constraint: $location_constraint" diff --git a/tests/drivers/list_object_versions/list_object_versions_rest.sh b/tests/drivers/list_object_versions/list_object_versions_rest.sh index e393142d..89807f78 100644 --- a/tests/drivers/list_object_versions/list_object_versions_rest.sh +++ b/tests/drivers/list_object_versions/list_object_versions_rest.sh @@ -14,27 +14,39 @@ # specific language governing permissions and limitations # under the License. -parse_version_id() { - if ! check_param_count_v2 "data file, IsLatest val" 2 $#; then +parse_version_or_delete_marker_id() { + if ! check_param_count_v2 "data file, 'Version' or 'DeleteMarker', IsLatest val" 3 $#; then return 1 fi log 5 "data: $(cat "$1")" - version_string="//*[local-name()=\"Version\"][*[local-name()=\"IsLatest\" and text()=\"$2\"]]" + version_string="//*[local-name()=\"$2\"][*[local-name()=\"IsLatest\" and text()=\"$3\"]]" log 5 "match string: $version_string" if ! get_xml_data "$1" "$1.xml"; then log 2 "error getting XML data" return 1 fi - if ! version=$(xmllint --xpath "$version_string" "$1.xml" 2>&1); then - log 2 "error getting result: $version" + if ! version_or_marker=$(xmllint --xpath "$version_string" "$1.xml" 2>&1); then + log 2 "error getting result: $version_or_marker" return 1 fi - log 5 "latest: $2, version: $version" - if ! version_id=$(xmllint --xpath "//*[local-name()=\"VersionId\"]/text()" <(echo "$version" | head -n 1) 2>&1); then - log 2 "error getting version ID: $version_id" + log 5 "latest: $3, version or marker: $version_or_marker" + if ! version_or_marker_id=$(xmllint --xpath "//*[local-name()=\"VersionId\"]/text()" <(echo "$version_or_marker" | head -n 1) 2>&1); then + log 2 "error getting version ID: $version_or_marker_id" return 1 fi - log 5 "version ID: $version_id" + log 5 "version or marker ID: $version_or_marker_id" + return 0 +} + +parse_version_id() { + if ! check_param_count_v2 "data file, IsLatest val" 2 $#; then + return 1 + fi + if ! parse_version_or_delete_marker_id "$1" "Version" "$2"; then + echo "error parsing version ID" + return 1 + fi + version_id=$version_or_marker_id return 0 } diff --git a/tests/drivers/put_object/put_object.sh b/tests/drivers/put_object/put_object.sh new file mode 100644 index 00000000..6eddb5fd --- /dev/null +++ b/tests/drivers/put_object/put_object.sh @@ -0,0 +1,47 @@ +#!/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. + +legal_hold_retention_setup() { + if ! check_param_count_v2 "bucket name, username, password, test file" 4 $#; then + return 1 + fi + local bucket_name=$1 username=$2 password=$3 test_file=$4 + if ! setup_user "$username" "$password" "user"; then + log 2 "error setting up user '$username'" + return 1 + fi + + if ! create_test_file "$test_file"; then + log 2 "error creating test file '$test_file'" + return 1 + fi + + if ! setup_bucket_object_lock_enabled_v2 "$bucket_name"; then + log 2 "error creating bucket with object lock enabled" + return 1 + fi + + if ! change_bucket_owner "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "$bucket_name" "$username"; then + log 2 "error changing bucket owner" + return 1 + fi + + if ! put_object_with_user "s3api" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$username" "$password"; then + log 2 "error putting object with user '$username'" + return 1 + fi + return 0 +} \ No newline at end of file diff --git a/tests/drivers/put_object/put_object_rest.sh b/tests/drivers/put_object/put_object_rest.sh index 370bd166..dfd0a31f 100644 --- a/tests/drivers/put_object/put_object_rest.sh +++ b/tests/drivers/put_object/put_object_rest.sh @@ -391,3 +391,45 @@ setup_bucket_versioning_file_two_versions() { fi return 0 } + +attempt_put_object_with_specific_acl() { + if ! check_param_count_v2 "acl header" 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 + + if ! test_file=$(get_file_name 2>&1); then + log 2 "error retrieving file name: $test_file" + return 1 + fi + + if ! setup_bucket_and_file_v2 "$bucket_name" "$test_file"; then + log 2 "error setting up bucket and file" + return 1 + fi + + if ! put_bucket_ownership_controls_rest "$bucket_name" "BucketOwnerPreferred"; then + log 2 "error changing bucket ownership controls" + return 1 + fi + + if [ "$DIRECT" == "true" ]; then + if ! allow_public_access "$bucket_name"; then + log 2 "error allowing public access" + return 1 + fi + id="id=$ACL_AWS_CANONICAL_ID" + else + id="$AWS_ACCESS_KEY_ID" + fi + + if ! send_rest_go_command_expect_error "501" "NotImplemented" "not implemented" "-method" "PUT" "-payloadFile" "$TEST_FILE_FOLDER/$test_file" "-bucketName" "$bucket_name" \ + "-objectKey" "$test_file" "-signedParams" "$1:$id"; then + log 2 "error sending put object command with header '$1' and checking response" + return 1 + fi + return 0 +} diff --git a/tests/drivers/rest.sh b/tests/drivers/rest.sh index 228e0802..9e45d58d 100644 --- a/tests/drivers/rest.sh +++ b/tests/drivers/rest.sh @@ -147,7 +147,11 @@ send_rest_command_expect_success_callback() { if ! check_param_count_v2 "env vars, script, response code, callback fn" 4 $#; then return 1 fi - output_file="$TEST_FILE_FOLDER/output.txt" + if ! output_file_name=$(get_file_name); then + log 2 "error generating output file name: $output_file_name" + return 1 + fi + output_file="$TEST_FILE_FOLDER/$output_file_name" local env_array=("env" "COMMAND_LOG=$COMMAND_LOG" "OUTPUT_FILE=$output_file") if [ "$1" != "" ]; then IFS=' ' read -r -a env_vars <<< "$1" @@ -160,10 +164,10 @@ send_rest_command_expect_success_callback() { fi response_code="$(echo "$result" | tail -n 1)" if [ "$response_code" != "$3" ]; then - log 2 "expected '$3', was '$response_code' ($(cat "$TEST_FILE_FOLDER/output.txt"))" + log 2 "expected '$3', was '$response_code' ($(cat "$output_file"))" return 1 fi - if [ "$4" != "" ] && ! "$4" "$TEST_FILE_FOLDER/output.txt"; then + if [ "$4" != "" ] && ! "$4" "$output_file"; then log 2 "callback error" return 1 fi @@ -265,8 +269,12 @@ send_rest_go_command_callback() { log 2 "expected curl response '$1', was '$status_code'" return 1 fi - echo -n "$result" > "$TEST_FILE_FOLDER/result.txt" - if [ "$2" != "" ] && ! "$2" "$TEST_FILE_FOLDER/result.txt"; then + if ! output_file_name=$(get_file_name); then + log 2 "error generating output file name: $output_file_name" + return 1 + fi + echo -n "$result" > "$TEST_FILE_FOLDER/$output_file_name" + if [ "$2" != "" ] && ! "$2" "$TEST_FILE_FOLDER/$output_file_name"; then log 2 "error in callback" return 1 fi @@ -317,3 +325,26 @@ send_rest_go_command_expect_error_with_arg_name_value() { fi return 0 } + +check_specific_argument_name_and_value() { + if ! check_param_count_v2 "data file" 1 $#; then + return 1 + fi + if ! check_error_parameter "$1" "$argument_name" "$argument_value"; then + log 2 "error checking 'ArgumentName' parameter" + return 1 + fi +} + +send_rest_go_command_expect_error_with_specific_arg_name_value() { + if ! check_param_count_gt "response code, error code, message, arg name, arg value, params" 5 $#; then + return 1 + fi + argument_name=$4 + argument_value=$5 + if ! send_rest_go_command_expect_error_callback "$1" "$2" "$3" "check_specific_argument_name_and_value" "${@:6}"; then + log 2 "error checking error response values" + return 1 + fi + return 0 +} diff --git a/tests/setup.sh b/tests/setup.sh index 894e087b..046199ed 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -40,7 +40,13 @@ check_secrets_line() { log 2 "$password_env secrets parameter missing" return 1 fi - if ! user_exists "${!username_env}" && ! create_user_versitygw "${!username_env}" "${!password_env}" "$role"; then + local user_exists_code=0 + user_exists "${!username_env}" || user_exists_code=$? + if [ $user_exists_code -eq 2 ]; then + log 2 "error checking for user existence" + return 1 + fi + if [ $user_exists_code -eq 1 ] && ! create_user_versitygw "${!username_env}" "${!password_env}" "$role"; then log 2 "error creating user" return 1 fi diff --git a/tests/test_rest_delete_bucket.sh b/tests/test_rest_delete_bucket.sh index b5c68cbb..0f71dc1a 100755 --- a/tests/test_rest_delete_bucket.sh +++ b/tests/test_rest_delete_bucket.sh @@ -145,3 +145,26 @@ source ./tests/drivers/put_object/put_object_rest.sh run send_rest_go_command "204" "-method" "DELETE" "-bucketName" "$bucket_name" "-signedParams" "x-amz-expected-bucket-owner:$AWS_USER_ID" assert_success } + +@test "REST - DeleteBucket - BucketNotEmpty error contains bucket that is not empty" { + if [ "$DIRECT" != "true" ]; then + skip "https://github.com/versity/versitygw/issues/1780" + fi + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run get_file_name + assert_success + test_file="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" + assert_success + + run put_object_rest "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" + assert_success + + run send_rest_go_command_expect_error_with_specific_arg_name_value "409" "BucketNotEmpty" "not empty" "BucketName" "$bucket_name" \ + "-bucketName" "$bucket_name" "-method" "DELETE" + assert_success +} diff --git a/tests/test_rest_delete_object.sh b/tests/test_rest_delete_object.sh index 04ed40ce..b7336000 100755 --- a/tests/test_rest_delete_object.sh +++ b/tests/test_rest_delete_object.sh @@ -66,7 +66,6 @@ source ./tests/setup.sh run get_file_name assert_success test_file_two="$output" - log 5 "$test_file $test_file_two" run get_bucket_name "$BUCKET_ONE_NAME" assert_success diff --git a/tests/test_rest_list_objects.sh b/tests/test_rest_list_objects.sh index c5f51a08..a691df9f 100755 --- a/tests/test_rest_list_objects.sh +++ b/tests/test_rest_list_objects.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bats -# 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/test_rest_put_object.sh b/tests/test_rest_put_object.sh index 9ce347f0..ce3a6830 100755 --- a/tests/test_rest_put_object.sh +++ b/tests/test_rest_put_object.sh @@ -390,3 +390,130 @@ export RUN_USERS=true run put_object_with_lock_mode_and_delete_latest_version "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$later_date" assert_success } + +@test "PutObject - x-amz-acl - not implemented" { + if [ "$DIRECT" != "true" ]; then + skip "https://github.com/versity/versitygw/issues/1767" + fi + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run get_file_name + assert_success + test_file="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" + assert_success + + run put_bucket_ownership_controls_rest "$bucket_name" "BucketOwnerPreferred" + assert_success + + if [ "$DIRECT" == "true" ]; then + run allow_public_access "$bucket_name" + assert_success + fi + + run send_rest_go_command_expect_error "501" "NotImplemented" "not implemented" "-method" "PUT" "-payloadFile" "$TEST_FILE_FOLDER/$test_file" "-bucketName" "$bucket_name" \ + "-objectKey" "$test_file" "-signedParams" "x-amz-acl:public-read" + assert_success +} + +@test "PutObject - x-amz-grant-full-control - not implemented" { + if [ "$DIRECT" != "true" ]; then + skip "https://github.com/versity/versitygw/issues/1773" + fi + run attempt_put_object_with_specific_acl "x-amz-grant-full-control" + assert_success +} + +@test "PutObject - x-amz-grant-read - not implemented" { + if [ "$DIRECT" != "true" ]; then + skip "https://github.com/versity/versitygw/issues/1773" + fi + run attempt_put_object_with_specific_acl "x-amz-grant-read" + assert_success +} +@test "PutObject - x-amz-grant-read-acp - not implemented" { + if [ "$DIRECT" != "true" ]; then + skip "https://github.com/versity/versitygw/issues/1773" + fi + run attempt_put_object_with_specific_acl "x-amz-grant-read-acp" + assert_success +} + +@test "PutObject - x-amz-grant-write-acp - not implemented" { + if [ "$DIRECT" != "true" ]; then + skip "https://github.com/versity/versitygw/issues/1773" + fi + run attempt_put_object_with_specific_acl "x-amz-grant-write-acp" + assert_success +} + +@test "PutObject - x-amz-object-lock-legal-hold - invalid value" { + if [ "$DIRECT" != "true" ]; then + skip "https://github.com/versity/versitygw/issues/1775" + fi + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run get_file_name + assert_success + test_file="$output" + + run setup_bucket_and_file_v2 "$bucket_name" "$test_file" + assert_success + + local legal_hold_value="wrong" + run send_rest_go_command_expect_error_with_arg_name_value "400" "InvalidArgument" "Legal Hold must be either of" \ + "x-amz-object-lock-legal-hold" "$legal_hold_value" "-method" "PUT" "-payloadFile" "$TEST_FILE_FOLDER/$test_file" \ + "-bucketName" "$bucket_name" "-objectKey" "$test_file" "-signedParams" "x-amz-object-lock-legal-hold:$legal_hold_value" + assert_success +} + +@test "PutObject - x-amz-object-lock-legal-hold - no Content-MD5" { + if [ "$DIRECT" != "true" ]; then + skip "https://github.com/versity/versitygw/issues/1776" + fi + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run get_file_name + assert_success + test_file=$output + + run setup_bucket_object_lock_enabled_v2 "$bucket_name" + assert_success + + run create_test_file "$test_file" + assert_success + + run send_rest_go_command_expect_error "400" "InvalidRequest" "Content-MD5" "-method" "PUT" "-payloadFile" "$TEST_FILE_FOLDER/$test_file" "-bucketName" "$bucket_name" \ + "-objectKey" "$test_file" "-signedParams" "x-amz-object-lock-legal-hold:ON" + assert_success +} + +@test "PutObject - x-amz-object-lock-legal-hold - success" { + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run get_file_name + assert_success + test_file=$output + + run setup_bucket_object_lock_enabled_v2 "$bucket_name" + assert_success + + run create_test_file "$test_file" + assert_success + + run send_rest_go_command "200" "-method" "PUT" "-payloadFile" "$TEST_FILE_FOLDER/$test_file" "-bucketName" "$bucket_name" \ + "-objectKey" "$test_file" "-signedParams" "x-amz-object-lock-legal-hold:ON" "-contentMD5" + assert_success + + run rest_check_legal_hold "$bucket_name" "$test_file" + assert_success +} diff --git a/tests/test_s3api_object.sh b/tests/test_s3api_object.sh index b8801c4f..7b447684 100755 --- a/tests/test_s3api_object.sh +++ b/tests/test_s3api_object.sh @@ -18,10 +18,6 @@ load ./bats-support/load load ./bats-assert/load source ./tests/setup.sh -source ./tests/util/util_file.sh -source ./tests/util/util_lock_config.sh -source ./tests/util/util_object.sh -source ./tests/test_s3api_root_inner.sh source ./tests/test_common.sh source ./tests/test_common_acl.sh source ./tests/commands/copy_object.sh @@ -50,6 +46,11 @@ source ./tests/drivers/copy_object/copy_object_rest.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 +source ./tests/drivers/file.sh +source ./tests/util/util_file.sh +source ./tests/util/util_lock_config.sh +source ./tests/util/util_object.sh +source ./tests/test_s3api_root_inner.sh export RUN_USERS=true diff --git a/tests/test_s3api_root_inner.sh b/tests/test_s3api_root_inner.sh index 545e6898..464efeff 100755 --- a/tests/test_s3api_root_inner.sh +++ b/tests/test_s3api_root_inner.sh @@ -17,6 +17,7 @@ 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 @@ -108,46 +109,64 @@ test_get_put_object_legal_hold_s3api_root() { if [ "$SKIP_USERS_TESTS" == "true" ]; then skip "skipping versitygw-specific users tests" fi - bucket_file="bucket_file" + run get_file_name + assert_success + # shellcheck disable=SC2154 + bucket_file="$output" + username=$USERNAME_ONE password=$PASSWORD_ONE - run legal_hold_retention_setup "$username" "$password" "$bucket_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run legal_hold_retention_setup "$bucket_name" "$username" "$password" "$bucket_file" assert_success - run get_check_object_lock_config_enabled "$BUCKET_ONE_NAME" + run get_check_object_lock_config_enabled "$bucket_name" assert_success - run put_object_legal_hold "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "ON" + run put_object_legal_hold "s3api" "$bucket_name" "$bucket_file" "ON" assert_success - run get_and_check_legal_hold "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "ON" + run get_and_check_legal_hold "s3api" "$bucket_name" "$bucket_file" "ON" assert_success echo "fdkljafajkfs" > "$TEST_FILE_FOLDER/$bucket_file" - run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" "$username" "$password" + run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$bucket_file" "$bucket_name" "$bucket_file" "$username" "$password" assert_success - run delete_object_with_user "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "$username" "$password" + run delete_object_with_user "s3api" "$bucket_name" "$bucket_file" "$username" "$password" assert_success - run put_object_legal_hold "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "OFF" + run put_object_legal_hold "s3api" "$bucket_name" "$bucket_file" "OFF" assert_failure assert_output -p "MethodNotAllowed" + + run delete_delete_marker_without_object_lock "$bucket_name" "$bucket_file" + assert_success } test_get_put_object_retention_s3api_root() { if [ "$SKIP_USERS_TESTS" == "true" ]; then skip "skipping versitygw-specific users tests" fi - bucket_file="bucket_file" + run get_file_name + assert_success + bucket_file="$output" + username=$USERNAME_ONE secret_key=$PASSWORD_ONE - run legal_hold_retention_setup "$username" "$secret_key" "$bucket_file" + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + + run legal_hold_retention_setup "$bucket_name" "$username" "$secret_key" "$bucket_file" assert_success - run get_check_object_lock_config_enabled "$BUCKET_ONE_NAME" + run get_check_object_lock_config_enabled "$bucket_name" assert_success if [[ "$OSTYPE" == "darwin"* ]]; then @@ -157,17 +176,17 @@ test_get_put_object_retention_s3api_root() { fi log 5 "retention date: $retention_date" - run put_object_retention "$BUCKET_ONE_NAME" "$bucket_file" "GOVERNANCE" "$retention_date" + run put_object_retention "$bucket_name" "$bucket_file" "GOVERNANCE" "$retention_date" assert_success - run get_check_object_retention "$BUCKET_ONE_NAME" "$bucket_file" "$retention_date" + run get_check_object_retention "$bucket_name" "$bucket_file" "$retention_date" assert_success echo "fdkljafajkfs" > "$TEST_FILE_FOLDER/$bucket_file" - run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" "$username" "$secret_key" + run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$bucket_file" "$bucket_name" "$bucket_file" "$username" "$secret_key" assert_success - run delete_object_with_user "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "$username" "$secret_key" + run delete_object_with_user "s3api" "$bucket_name" "$bucket_file" "$username" "$secret_key" assert_success } @@ -175,15 +194,22 @@ test_retention_bypass_s3api_root() { if [ "$SKIP_USERS_TESTS" == "true" ]; then skip "skipping versitygw-specific users tests" fi - bucket_file="bucket_file" + run get_file_name + assert_success + bucket_file="$output" + + run get_bucket_name "$BUCKET_ONE_NAME" + assert_success + bucket_name="$output" + username=$USERNAME_ONE secret_key=$PASSWORD_ONE policy_file="policy_file" - run legal_hold_retention_setup "$username" "$secret_key" "$bucket_file" + run legal_hold_retention_setup "$bucket_name" "$username" "$secret_key" "$bucket_file" assert_success - run get_check_object_lock_config_enabled "$BUCKET_ONE_NAME" + run get_check_object_lock_config_enabled "$bucket_name" assert_success if [[ "$OSTYPE" == "darwin"* ]]; then @@ -193,45 +219,20 @@ test_retention_bypass_s3api_root() { fi log 5 "retention date: $retention_date" - run put_object_retention "$BUCKET_ONE_NAME" "$bucket_file" "GOVERNANCE" "$retention_date" + run put_object_retention "$bucket_name" "$bucket_file" "GOVERNANCE" "$retention_date" assert_success - run delete_object_with_user "s3api" "$BUCKET_ONE_NAME" "$bucket_file" + run delete_object_with_user "s3api" "$bucket_name" "$bucket_file" assert_failure 1 run setup_policy_with_single_statement "$TEST_FILE_FOLDER/$policy_file" "2012-10-17" "Allow" "$username" \ - "[\"s3:BypassGovernanceRetention\",\"s3:DeleteObject\"]" "arn:aws:s3:::$BUCKET_ONE_NAME/*" + "[\"s3:BypassGovernanceRetention\",\"s3:DeleteObject\"]" "arn:aws:s3:::$bucket_name/*" assert_success - run put_bucket_policy "s3api" "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER/$policy_file" + run put_bucket_policy "s3api" "$bucket_name" "$TEST_FILE_FOLDER/$policy_file" assert_success - run delete_object_bypass_retention "$BUCKET_ONE_NAME" "$bucket_file" "$username" "$secret_key" - assert_success -} - -legal_hold_retention_setup() { - assert [ $# -eq 3 ] - - run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME" - assert_success - - run setup_user "$1" "$2" "user" - assert_success - - run create_test_file "$3" - assert_success - - #create_bucket "s3api" "$BUCKET_ONE_NAME" || fail "error creating bucket" - if [[ $RECREATE_BUCKETS == "true" ]]; then - run create_bucket_object_lock_enabled "$BUCKET_ONE_NAME" - assert_success - fi - - run change_bucket_owner "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "$BUCKET_ONE_NAME" "$1" - assert_success - - run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$3" "$BUCKET_ONE_NAME" "$3" "$1" "$2" + run delete_object_bypass_retention "$bucket_name" "$bucket_file" "$username" "$secret_key" assert_success } diff --git a/tests/util/util_get_object_retention.sh b/tests/util/util_get_object_retention.sh index e515c22f..53137914 100644 --- a/tests/util/util_get_object_retention.sh +++ b/tests/util/util_get_object_retention.sh @@ -20,7 +20,7 @@ get_check_object_retention() { return 1 fi # shellcheck disable=SC2154 - if ! get_object_retention "$BUCKET_ONE_NAME" "$bucket_file"; then + if ! get_object_retention "$1" "$bucket_file"; then log 2 "failed to get object retention" return 1 fi