test: PutObject object lock tests and updates, delete bucket test

This commit is contained in:
Luke McCrone
2026-01-16 14:34:46 -03:00
parent 01fc142c1e
commit 1f9856110d
17 changed files with 400 additions and 75 deletions

View File

@@ -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/*

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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"

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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

View File

@@ -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
}

View File

@@ -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

View File

@@ -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

View File

@@ -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
}

View File

@@ -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

View File

@@ -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
}

View File

@@ -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