test: PutBucketOwnershipControls tests

This commit is contained in:
Luke McCrone
2025-08-27 18:43:45 -03:00
parent 13ea2286f7
commit 278946f132
24 changed files with 306 additions and 181 deletions

View File

@@ -33,9 +33,9 @@ jobs:
RECREATE_BUCKETS: "true"
DELETE_BUCKETS_AFTER_TEST: "true"
BACKEND: "posix"
- set: "REST, posix, non-static, not implemented, folder IAM"
- set: "REST, posix, non-static, not implemented|rest-delete-bucket-ownership-controls, folder IAM"
IAM_TYPE: folder
RUN_SET: "rest-not-implemented"
RUN_SET: "rest-not-implemented,rest-delete-bucket-ownership-controls"
RECREATE_BUCKETS: "true"
DELETE_BUCKETS_AFTER_TEST: "true"
BACKEND: "posix"

View File

@@ -185,6 +185,8 @@ A single instance can be run with `docker-compose -f docker-compose-bats.yml up
**MAX_FILE_DOWNLOAD_CHUNK_SIZE**: when set, will divide the download of large files with GetObject into chunks of the given size. Useful for direct testing with slower connections.
**SKIP_USERS_TESTS**: skip versitygw-specific users tests, set to **false** to test against other S3 gateways
## REST Scripts
REST scripts are included for calls to S3's REST API in the `./tests/rest_scripts/` folder. To call a script, the following parameters are needed:

View File

@@ -61,6 +61,17 @@ get_bucket_ownership_controls_rest() {
echo "$rule"
}
get_bucket_ownership_controls_expect_error_callback() {
if ! check_param_count_v2 "bucket name, expected HTTP error, expected S3 error, expected message, callback" 5 $#; then
return 1
fi
if ! send_rest_go_command_expect_error_callback "$2" "$3" "$4" "$5" "-bucketName" "$1" "-query" "ownershipControls="; then
log 2 "error checking ownership controls error and callback"
return 1
fi
return 0
}
get_object_ownership_rule() {
if [[ -n "$SKIP_BUCKET_OWNERSHIP_CONTROLS" ]]; then
log 5 "Skipping get bucket ownership controls"

View File

@@ -31,4 +31,20 @@ put_bucket_ownership_controls() {
log 2 "error putting bucket ownership controls: $error"
return 1
fi
}
}
put_bucket_ownership_controls_rest() {
if [ $# -ne 2 ]; then
log 2 "'put_bucket_ownership_controls_rest' missing bucket name, ownership"
return 1
fi
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OWNERSHIP="$2" OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" ./tests/rest_scripts/put_bucket_ownership_controls.sh); then
log 2 "error putting bucket ownership controls: $result"
return 1
fi
if [ "$result" != "200" ]; then
log 2 "put bucket ownership controls returned code $result: $(cat "$TEST_FILE_FOLDER/result.txt")"
return 1
fi
return 0
}

View File

@@ -0,0 +1,53 @@
#!/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.
get_bucket_ownership_controls_check_error_after_deletion() {
if ! check_param_count_v2 "bucket name" 1 $#; then
return 1
fi
bucket_name="$1"
if ! get_bucket_ownership_controls_expect_error_callback "$1" "404" "OwnershipControlsNotFoundError" "were not found" "check_error_bucket_name"; then
log 2 "error checking bucket ownership controls error"
return 1
fi
return 0
}
check_error_bucket_name() {
if ! check_param_count_v2 "data file" 1 $#; then
return 1
fi
if ! check_xml_element_contains "$1" "$bucket_name" "Error" "BucketName"; then
log 2 "error checking BucketName XML element"
return 1
fi
return 0
}
get_and_check_ownership_controls() {
if ! check_param_count "get_and_check_ownership_controls" "bucket, expected result" 2 $#; then
return 1
fi
if ! rule=$(get_bucket_ownership_controls_rest "$1" 2>&1); then
log 2 "error getting ownership rule: $rule"
return 1
fi
if [ "$rule" != "$2" ]; then
log 2 "rule mismatch (expected '$2', actual '$rule')"
return 1
fi
return 0
}

View File

@@ -166,10 +166,22 @@ send_rest_command_expect_success_callback() {
send_rest_go_command_expect_error() {
if [ $# -lt 3 ] && [ $(($# % 2)) -ne 1 ]; then
log 2 "'send_rest_go_command_expect_error' param count must be 3 or greater, odd (key/value pairs)"
log 2 "'send_rest_go_command_expect_error' param count must be 3 or greater, odd (expected HTTP code, expected error code, expected message, key/value pairs)"
return 1
fi
if ! curl_command=$(go run ./tests/rest_scripts/generate_command.go -awsAccessKeyId "$AWS_ACCESS_KEY_ID" -awsSecretAccessKey "$AWS_SECRET_ACCESS_KEY" -url "$AWS_ENDPOINT_URL" "${@:4}" 2>&1); then
if ! send_rest_go_command_expect_error_callback "$1" "$2" "$3" "" "${@:4}"; then
log 2 "error sending go command and checking error"
return 1
fi
return 0
}
send_rest_go_command_expect_error_callback() {
if [ $# -lt 4 ] && [ $(($# % 2)) -eq 1 ]; then
log 2 "'send_rest_go_command_expect_error' param count must be 4 or greater, even (expected HTTP code, expected error code, expected message, callback, key/value pairs)"
return 1
fi
if ! curl_command=$(go run ./tests/rest_scripts/generate_command.go -awsAccessKeyId "$AWS_ACCESS_KEY_ID" -awsSecretAccessKey "$AWS_SECRET_ACCESS_KEY" -url "$AWS_ENDPOINT_URL" "${@:5}" 2>&1); then
log 2 "error: $curl_command"
return 1
fi
@@ -185,6 +197,10 @@ send_rest_go_command_expect_error() {
log 2 "error checking expected header error"
return 1
fi
if [ "$4" != "" ] && ! "$4" "$TEST_FILE_FOLDER/result.txt"; then
log 2 "callback error"
return 1
fi
return 0
}

View File

@@ -17,35 +17,36 @@
# Function to display help information
show_help() {
echo "Usage: $0 [option...]"
echo " -h, --help Display this help message and exit"
echo " Separate the below by comma"
echo " s3api Run all tests with s3api cli"
echo " s3api-multipart Run multipart tests with s3api cli"
echo " s3api-bucket Run bucket tests with s3api cli"
echo " s3api-object Run object tests with s3api cli"
echo " s3api-policy Run policy tests with s3api cli"
echo " s3api-user Run user tests with s3api cli"
echo " s3 Run tests with s3 cli"
echo " s3cmd Run tests with s3cmd utility"
echo " s3cmd-user Run user tests with s3cmd utility"
echo " s3cmd-non-user Run non-user tests with s3cmd utility"
echo " s3cmd-file-count Run file count test with s3cmd utility"
echo " mc Run tests with mc utility"
echo " mc-non-file-count Run non-file count tests with mc utility"
echo " mc-file-count Run file count test with mc utility"
echo " rest Run tests with rest cli"
echo " rest-base Run REST base tests"
echo " rest-acl Run REST ACL tests"
echo " rest-chunked Run REST chunked upload tests"
echo " rest-checksum Run REST checksum tests"
echo " rest-create-bucket Run REST create bucket tests"
echo " rest-head-bucket Run REST head bucket tests"
echo " rest-list-buckets Run REST list-buckets tests"
echo " rest-multipart Run REST multipart tests"
echo " rest-not-implemented Run REST multipart tests"
echo " rest-put-object Run REST put-object tests"
echo " rest-versioning Run REST versioning tests"
echo " rest-bucket Run REST bucket tests"
echo " -h, --help Display this help message and exit"
echo " Separate the below by comma"
echo " s3api Run all tests with s3api cli"
echo " s3api-multipart Run multipart tests with s3api cli"
echo " s3api-bucket Run bucket tests with s3api cli"
echo " s3api-object Run object tests with s3api cli"
echo " s3api-policy Run policy tests with s3api cli"
echo " s3api-user Run user tests with s3api cli"
echo " s3 Run tests with s3 cli"
echo " s3cmd Run tests with s3cmd utility"
echo " s3cmd-user Run user tests with s3cmd utility"
echo " s3cmd-non-user Run non-user tests with s3cmd utility"
echo " s3cmd-file-count Run file count test with s3cmd utility"
echo " mc Run tests with mc utility"
echo " mc-non-file-count Run non-file count tests with mc utility"
echo " mc-file-count Run file count test with mc utility"
echo " rest Run tests with rest cli"
echo " rest-base Run REST base tests"
echo " rest-acl Run REST ACL tests"
echo " rest-chunked Run REST chunked upload tests"
echo " rest-checksum Run REST checksum tests"
echo " rest-create-bucket Run REST create bucket tests"
echo " rest-delete-bucket-ownership-controls Run REST delete bucket ownership controls tests"
echo " rest-head-bucket Run REST head bucket tests"
echo " rest-list-buckets Run REST list-buckets tests"
echo " rest-multipart Run REST multipart tests"
echo " rest-not-implemented Run REST multipart tests"
echo " rest-put-object Run REST put-object tests"
echo " rest-versioning Run REST versioning tests"
echo " rest-bucket Run REST bucket tests"
}
handle_param() {
@@ -58,7 +59,7 @@ handle_param() {
s3cmd-file-count|mc|mc-non-file-count|mc-file-count|s3api-user|rest|s3api-policy|\
s3api-bucket|s3api-object|s3api-multipart|rest-base|rest-acl|rest-chunked|rest-checksum|\
rest-create-bucket|rest-head-bucket|rest-list-buckets|rest-not-implemented|\
rest-put-object|rest-versioning|rest-bucket|rest-multipart)
rest-put-object|rest-versioning|rest-bucket|rest-multipart|rest-delete-bucket-ownership-controls)
run_suite "$1"
;;
*) # Handle unrecognized options or positional arguments
@@ -167,6 +168,8 @@ run_suite() {
exit_code=1
elif ! "$HOME"/bin/bats ./tests/test_rest_create_bucket.sh; then
exit_code=1
elif ! "$HOME"/bin/bats ./tests/test_rest_delete_bucket_ownership_controls.sh; then
exit_code=1
elif ! "$HOME"/bin/bats ./tests/test_rest_head_bucket.sh; then
exit_code=1
elif ! "$HOME"/bin/bats ./tests/test_rest_list_buckets.sh; then
@@ -207,6 +210,10 @@ run_suite() {
echo "Running REST create bucket tests ..."
"$HOME"/bin/bats ./tests/test_rest_create_bucket.sh || exit_code=$?
;;
rest-delete-bucket-ownership-controls)
echo "Running REST delete bucket ownership controls tests ..."
"$HOME"/bin/bats ./tests/test_rest_delete_bucket_ownership_controls.sh || exit_code=$?
;;
rest-head-bucket)
echo "Running REST head bucket tests ..."
"$HOME"/bin/bats ./tests/test_rest_head_bucket.sh || exit_code=$?

View File

@@ -14,7 +14,7 @@
# specific language governing permissions and limitations
# under the License.
if [ "$SKIP_ACL_TESTING" == "true" ]; then
if [ "$SKIP_ACL_TESTING" == "true" ] || [ "$SKIP_USERS_TESTS" == "true" ]; then
skip "Skipping ACL tests"
exit 0
fi

View File

@@ -30,6 +30,7 @@ source ./tests/commands/put_object.sh
source ./tests/commands/put_object_retention.sh
source ./tests/commands/put_object_tagging.sh
source ./tests/drivers/copy_object/copy_object_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/xml.sh
source ./tests/logger.sh
@@ -44,7 +45,6 @@ source ./tests/util/util_list_parts.sh
source ./tests/util/util_lock_config.sh
source ./tests/util/util_multipart_before_completion.sh
source ./tests/util/util_object.sh
source ./tests/util/util_ownership.sh
source ./tests/util/util_policy.sh
source ./tests/util/util_public_access_block.sh
source ./tests/util/util_rest.sh
@@ -282,16 +282,6 @@ test_file="test_file"
assert_success
}
@test "REST - PutObject - user permission, bad signature" {
run setup_bucket_file_and_user "$BUCKET_ONE_NAME" "$test_file" "$USERNAME_ONE" "$PASSWORD_ONE" "admin"
assert_success
username="${lines[${#lines[@]}-2]}"
password="${lines[${#lines[@]}-1]}"
run put_object_rest_user_bad_signature "$username" "$password" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
assert_success
}
@test "REST - PutObjectRetention - w/o request body" {
run setup_bucket_object_lock_enabled "$BUCKET_ONE_NAME"
assert_success

View File

@@ -28,7 +28,7 @@ source ./tests/util/util_setup.sh
export RUN_USERS=true
if [ "$SKIP_ACL_TESTING" == "true" ]; then
if [ "$SKIP_ACL_TESTING" == "true" ] || [ "$SKIP_USERS_TESTS" == "true" ]; then
skip "Skipping ACL tests"
exit 0
fi

View File

@@ -21,6 +21,7 @@ source ./tests/commands/get_object_lock_configuration.sh
source ./tests/commands/head_bucket.sh
source ./tests/commands/list_buckets.sh
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/list_buckets/list_buckets_rest.sh
source ./tests/logger.sh
source ./tests/setup.sh
@@ -28,7 +29,6 @@ source ./tests/util/util_bucket.sh
source ./tests/util/util_delete_object.sh
source ./tests/util/util_list_buckets.sh
source ./tests/util/util_lock_config.sh
source ./tests/util/util_ownership.sh
source ./tests/util/util_public_access_block.sh
source ./tests/util/util_rest.sh
source ./tests/util/util_tags.sh
@@ -151,6 +151,9 @@ export RUN_USERS=true
}
@test "REST - put policy" {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
run setup_bucket "$BUCKET_ONE_NAME"
assert_success

View File

@@ -0,0 +1,82 @@
#!/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.
load ./bats-support/load
load ./bats-assert/load
source ./tests/drivers/get_bucket_ownership_controls/get_bucket_ownership_controls_rest.sh
source ./tests/drivers/user.sh
source ./tests/setup.sh
export RUN_USERS=true
@test "REST - DeleteBucketOwnershipControls - lack permission" {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
run setup_bucket "$BUCKET_ONE_NAME"
assert_success
run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE"
assert_success
username=${lines[2]}
password=${lines[3]}
run put_bucket_ownership_controls_rest "$BUCKET_ONE_NAME" "BucketOwnerPreferred"
assert_success
run send_rest_go_command_expect_error "403" "AccessDenied" "Access Denied" "-awsAccessKeyId" "$username" "-awsSecretAccessKey" "$password" \
"-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-query" "ownershipControls="
assert_success
}
@test "REST - DeleteBucketOwnershipControls - success" {
run setup_bucket "$BUCKET_ONE_NAME"
assert_success
run put_bucket_ownership_controls_rest "$BUCKET_ONE_NAME" "BucketOwnerPreferred"
assert_success
run get_bucket_ownership_controls_rest "$BUCKET_ONE_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="
assert_success
run get_bucket_ownership_controls_rest "$BUCKET_ONE_NAME"
assert_success
rule=${output[${#output[@]}-1]}
assert_equal "$rule" ""
}
@test "REST - DeleteBucketOwnershipControls - BucketName is reported in error" {
if [ "$DIRECT" != "true" ]; then
skip "https://github.com/versity/versitygw/issues/1493"
fi
run setup_bucket "$BUCKET_ONE_NAME"
assert_success
if ! send_rest_go_command "204" \
"-method" "DELETE" "-bucketName" "$BUCKET_ONE_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"
assert_success
}

View File

@@ -42,6 +42,9 @@ export RUN_USERS=true
}
@test "REST - PutObject with user permission - admin user" {
if [ "$SKIP_USERS_TEST" == "true" ]; then
skip "skipping versity-specific users tests"
fi
run setup_bucket_file_and_user "$BUCKET_ONE_NAME" "$test_file" "$USERNAME_ONE" "$PASSWORD_ONE" "admin"
assert_success
username="${lines[${#lines[@]}-2]}"
@@ -53,6 +56,9 @@ export RUN_USERS=true
}
@test "REST - PutObject with no permission - 'user' user" {
if [ "$SKIP_USERS_TEST" == "true" ]; then
skip "skipping versity-specific users tests"
fi
run setup_bucket_file_and_user "$BUCKET_ONE_NAME" "$test_file" "$USERNAME_ONE" "$PASSWORD_ONE" "user"
assert_success
username="${lines[${#lines[@]}-2]}"
@@ -97,7 +103,6 @@ export RUN_USERS=true
if [ "$DIRECT" != "true" ]; then
skip "https://github.com/versity/versitygw/issues/821"
fi
test_file="test_file"
run setup_bucket_and_add_file "$BUCKET_ONE_NAME" "$test_file"
assert_success
@@ -110,7 +115,6 @@ export RUN_USERS=true
if [ "$DIRECT" != "true" ]; then
skip "https://github.com/versity/versitygw/issues/821"
fi
test_file="test_file"
run setup_bucket "$BUCKET_ONE_NAME"
assert_success
@@ -126,7 +130,6 @@ export RUN_USERS=true
if [ "$DIRECT" != "true" ]; then
skip "https://github.com/versity/versitygw/issues/821"
fi
test_file="test_file"
run setup_bucket "$BUCKET_ONE_NAME"
assert_success
@@ -139,7 +142,6 @@ export RUN_USERS=true
if [ "$DIRECT" != "true" ]; then
skip "https://github.com/versity/versitygw/issues/821"
fi
test_file="test_file"
run setup_bucket "$BUCKET_ONE_NAME"
assert_success
@@ -158,7 +160,6 @@ export RUN_USERS=true
if [ "$DIRECT" != "true" ]; then
skip "https://github.com/versity/versitygw/issues/821"
fi
test_file="test_file"
run setup_bucket "$BUCKET_ONE_NAME"
assert_success
@@ -185,7 +186,6 @@ export RUN_USERS=true
uppercase_key="CAPITAL"
uppercase_value="DUMMY"
test_file="test_file"
run setup_bucket "$BUCKET_ONE_NAME"
assert_success
@@ -199,3 +199,16 @@ export RUN_USERS=true
run check_metadata_key_case "$BUCKET_ONE_NAME" "$test_file" "$uppercase_key" "$uppercase_value"
assert_success
}
@test "REST - PutObject - user permission, bad signature" {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
run setup_bucket_file_and_user "$BUCKET_ONE_NAME" "$test_file" "$USERNAME_ONE" "$PASSWORD_ONE" "admin"
assert_success
username="${lines[${#lines[@]}-2]}"
password="${lines[${#lines[@]}-1]}"
run put_object_rest_user_bad_signature "$username" "$password" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
assert_success
}

View File

@@ -24,7 +24,6 @@ source ./tests/util/util_head_bucket.sh
source ./tests/util/util_lock_config.sh
source ./tests/util/util_object.sh
source ./tests/util/util_tags.sh
source ./tests/util/util_users.sh
source ./tests/test_s3api_root_inner.sh
source ./tests/test_common.sh
source ./tests/test_common_acl.sh

View File

@@ -70,7 +70,7 @@ export RUN_USERS=true
local bucket_file="bucket-file"
local expected_content_type="application/zip"
local expected_meta_key="testKey"
local expected_meta_key="testkey"
local expected_meta_val="testValue"
local expected_hold_status="ON"
local expected_retention_mode="GOVERNANCE"

View File

@@ -24,7 +24,6 @@ source ./tests/util/util_lock_config.sh
source ./tests/util/util_object.sh
source ./tests/util/util_setup.sh
source ./tests/util/util_tags.sh
source ./tests/util/util_users.sh
source ./tests/test_s3api_root_inner.sh
source ./tests/test_common.sh
source ./tests/test_common_acl.sh

View File

@@ -39,142 +39,87 @@ source ./tests/drivers/get_bucket_acl/get_bucket_acl_s3api.sh
export RUN_USERS=true
if [ -n "$SKIP_POLICY" ] || [ "$SKIP_USERS_TESTS" == "true" ]; then
skip "Skipping ACL tests"
exit 0
fi
@test "test_policy_abort_multipart_upload" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_abort_multipart_upload
}
@test "test_policy_allow_deny" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_allow_deny
}
@test "test_policy_delete" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_delete
}
@test "test_policy_delete_bucket_policy" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_delete_bucket_policy
}
@test "test_policy_deny" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_deny
}
@test "test_policy_get_bucket_acl" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_bucket_acl
}
@test "test_policy_get_bucket_policy" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_bucket_policy
}
@test "test_policy_get_bucket_tagging" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_bucket_tagging
}
@test "test_policy_get_object_file_wildcard" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_object_file_wildcard
}
@test "test_policy_get_object_folder_wildcard" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_object_folder_wildcard
}
@test "test_policy_get_object_specific_file" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_object_specific_file
}
@test "test_policy_get_object_with_user" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_object_with_user
}
@test "test_policy_list_multipart_uploads" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_list_multipart_uploads
}
@test "test_policy_list_upload_parts" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_list_upload_parts
}
@test "test_policy_put_acl" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_put_acl
}
@test "test_policy_put_bucket_policy" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_put_bucket_policy
}
@test "test_policy_put_bucket_tagging" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_put_bucket_tagging
}
@test "test_policy_two_principals" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_two_principals
}
@test "test_policy_put_wildcard" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_put_wildcard
}
@test "test_put_policy_invalid_action" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_invalid_action
}

View File

@@ -106,6 +106,9 @@ test_get_object_attributes_s3api_root() {
}
test_get_put_object_legal_hold_s3api_root() {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
bucket_file="bucket_file"
username=$USERNAME_ONE
password=$PASSWORD_ONE
@@ -140,6 +143,9 @@ test_get_put_object_legal_hold_s3api_root() {
}
test_get_put_object_retention_s3api_root() {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
bucket_file="bucket_file"
username=$USERNAME_ONE
secret_key=$PASSWORD_ONE
@@ -176,6 +182,9 @@ test_get_put_object_retention_s3api_root() {
}
test_retention_bypass_s3api_root() {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
bucket_file="bucket_file"
username=$USERNAME_ONE
secret_key=$PASSWORD_ONE

View File

@@ -22,7 +22,6 @@ source ./tests/test_common.sh
source ./tests/test_common_acl.sh
source ./tests/util/util_create_bucket.sh
source ./tests/util/util_object.sh
source ./tests/util/util_users.sh
source ./tests/commands/delete_bucket_policy.sh
source ./tests/commands/get_bucket_policy.sh
source ./tests/commands/put_bucket_policy.sh

View File

@@ -34,9 +34,11 @@ export RUN_USERS=true
}
@test "test_delete_user_no_access_key" {
if delete_user ""; then
fail "delete user with empty access key succeeded"
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
run delete_user ""
assert_failure
}
@test "test_user_user_aws" {
@@ -48,6 +50,9 @@ export RUN_USERS=true
}
@test "test_user_get_object" {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
test_file="test_file"
run setup_user_versitygw_or_direct "$USERNAME_ONE" "$PASSWORD_ONE" "user" "$BUCKET_ONE_NAME"
@@ -72,6 +77,9 @@ export RUN_USERS=true
}
@test "test_userplus_get_object" {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
test_file="test_file"
run setup_user_versitygw_or_direct "$USERNAME_ONE" "$PASSWORD_ONE" "userplus" "$BUCKET_ONE_NAME"
@@ -96,6 +104,9 @@ export RUN_USERS=true
}
@test "test_user_delete_object" {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
test_file="test_file"
run setup_user_versitygw_or_direct "$USERNAME_ONE" "$PASSWORD_ONE" "user" "$BUCKET_ONE_NAME"
@@ -120,6 +131,9 @@ export RUN_USERS=true
}
@test "test_admin_put_get_object" {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
test_file="test_file"
run setup_user_versitygw_or_direct "$USERNAME_ONE" "$PASSWORD_ONE" "admin" "$BUCKET_ONE_NAME"
@@ -148,6 +162,9 @@ export RUN_USERS=true
}
@test "test_user_create_multipart_upload" {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
test_file="test_file"
run setup_user_versitygw_or_direct "$USERNAME_TWO" "$PASSWORD_TWO" "user" "$BUCKET_ONE_NAME"

View File

@@ -23,6 +23,9 @@ source ./tests/util/util_users.sh
source ./tests/commands/list_buckets.sh
test_admin_user() {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
admin_username="$USERNAME_ONE"
admin_password="$PASSWORD_ONE"
user_username="$USERNAME_TWO"
@@ -59,6 +62,9 @@ test_admin_user() {
}
test_create_user_already_exists() {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
username="$USERNAME_ONE"
password="$PASSWORD_ONE"
@@ -70,6 +76,9 @@ test_create_user_already_exists() {
}
test_user_user() {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
if [ "$RECREATE_BUCKETS" == "false" ]; then
skip "test not valid for static buckets"
fi
@@ -106,6 +115,9 @@ test_user_user() {
}
test_userplus_operation() {
if [ "$SKIP_USERS_TESTS" == "true" ]; then
skip
fi
username="$USERNAME_ONE"
password="$PASSWORD_ONE"

View File

@@ -257,7 +257,7 @@ chunked_upload_trailer_incorrect_checksum() {
log 2 "error creating test file"
return 1
fi
if ! checksum=$(calculate_incorrect_checksum "$1" "$test_file"); then
if ! checksum=$(calculate_incorrect_checksum "$1" "$TEST_FILE_FOLDER/$test_file"); then
log 2 "error calculating incorrect checksum"
return 1
fi

View File

@@ -46,6 +46,7 @@ source ./tests/commands/put_object_lock_configuration.sh
source ./tests/commands/upload_part_copy.sh
source ./tests/commands/upload_part.sh
source ./tests/drivers/head_object/head_object_rest.sh
source ./tests/drivers/openssl.sh
source ./tests/util/util_users.sh
# params: bucket, object name
@@ -286,7 +287,7 @@ check_checksum_rest_incorrect() {
fi
error_cs_str="$(echo "$1" | tr '[:lower:]' '[:upper:]')"
error_message="The $error_cs_str you specified did not match the calculated checksum."
if ! calculate_incorrect_checksum "$1" "$(cat "$TEST_FILE_FOLDER/$test_file")"; then
if ! calculate_incorrect_checksum "$1" "$TEST_FILE_FOLDER/$test_file"; then
log 2 "error calculating incorrect checksum"
return 1
fi
@@ -298,35 +299,18 @@ check_checksum_rest_incorrect() {
}
calculate_incorrect_checksum() {
if ! check_param_count "calculate_incorrect_checksum" "checksum type, data" 2 $#; then
if ! check_param_count "calculate_incorrect_checksum" "checksum type, data file" 2 $#; then
return 1
fi
case "$1" in
"sha1")
incorrect_checksum="$(echo -n "$2"a | sha1sum | awk '{print $1}' | xxd -r -p | base64)"
;;
"sha256")
incorrect_checksum="$(echo -n "$2"a | sha256sum | awk '{print $1}' | xxd -r -p | base64)"
;;
"crc32")
incorrect_checksum="$(echo -n "$2"a | gzip -c -1 | tail -c8 | od -t x4 -N 4 -A n | awk '{print $1}' | xxd -r -p | base64)"
;;
"crc32c")
if ! incorrect_checksum=$(DATA_FILE=<(echo -n "$2"a) TEST_FILE_FOLDER="$TEST_FILE_FOLDER" CHECKSUM_TYPE="crc32c" ./tests/rest_scripts/calculate_checksum.sh 2>&1); then
log 2 "error calculating checksum: $incorrect_checksum"
return 1
fi
;;
"crc64nvme")
if ! incorrect_checksum=$(DATA_FILE=<(echo -n "$2"a) TEST_FILE_FOLDER="$TEST_FILE_FOLDER" CHECKSUM_TYPE="crc64nvme" ./tests/rest_scripts/calculate_checksum.sh 2>&1); then
log 2 "error calculating checksum: $incorrect_checksum"
return 1
fi
;;
*)
log 2 "invalid checksum type: $1"
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
esac
fi
if [ "${checksum:0:1}" == "a" ]; then
incorrect_checksum="A${checksum:1}"
else
incorrect_checksum="a${checksum:1}"
fi
echo "$incorrect_checksum"
return 0
}

View File

@@ -1,32 +0,0 @@
#!/usr/bin/env bash
get_and_check_ownership_controls() {
if ! check_param_count "get_and_check_ownership_controls" "bucket, expected result" 2 $#; then
return 1
fi
if ! rule=$(get_bucket_ownership_controls_rest "$1" 2>&1); then
log 2 "error getting ownership rule: $rule"
return 1
fi
if [ "$rule" != "$2" ]; then
log 2 "rule mismatch (expected '$2', actual '$rule')"
return 1
fi
return 0
}
put_bucket_ownership_controls_rest() {
if [ $# -ne 2 ]; then
log 2 "'put_bucket_ownership_controls_rest' missing bucket name, ownership"
return 1
fi
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OWNERSHIP="$2" OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" ./tests/rest_scripts/put_bucket_ownership_controls.sh); then
log 2 "error putting bucket ownership controls: $result"
return 1
fi
if [ "$result" != "200" ]; then
log 2 "put bucket ownership controls returned code $result: $(cat "$TEST_FILE_FOLDER/result.txt")"
return 1
fi
return 0
}