test: GetBucketPolicy - test w/o policy

This commit is contained in:
Luke McCrone
2024-11-22 13:09:54 +01:00
parent 80b316fccf
commit 0f2c727990
73 changed files with 375 additions and 328 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ copy_object() {
record_command "copy-object" "client:$1"
if [[ $1 == 's3' ]]; then
error=$(send_command aws --no-verify-ssl s3 cp "$2" s3://"$3/$4" 2>&1) || exit_code=$?
elif [[ $1 == 's3api' ]] || [[ $1 == 'aws' ]]; then
elif [[ $1 == 's3api' ]]; then
error=$(send_command aws --no-verify-ssl s3api copy-object --copy-source "$2" --bucket "$3" --key "$4" 2>&1) || exit_code=$?
elif [[ $1 == 's3cmd' ]]; then
log 5 "s3cmd ${S3CMD_OPTS[*]} --no-check-certificate cp s3://$2 s3://$3/$4"
+1 -1
View File
@@ -31,7 +31,7 @@ create_bucket() {
log 6 "create bucket"
if [[ $1 == 's3' ]]; then
error=$(send_command aws --no-verify-ssl s3 mb s3://"$2" 2>&1) || exit_code=$?
elif [[ $1 == "aws" ]] || [[ $1 == 's3api' ]]; then
elif [[ $1 == 's3api' ]]; then
error=$(send_command aws --no-verify-ssl s3api create-bucket --bucket "$2" 2>&1) || exit_code=$?
elif [[ $1 == "s3cmd" ]]; then
log 5 "s3cmd ${S3CMD_OPTS[*]} --no-check-certificate mb s3://$2"
+1 -1
View File
@@ -7,7 +7,7 @@ create_presigned_url() {
fi
local presign_result=0
if [[ $1 == 'aws' ]]; then
if [[ $1 == 's3api' ]]; then
presigned_url=$(send_command aws s3 presign "s3://$2/$3" --expires-in 900) || presign_result=$?
elif [[ $1 == 's3cmd' ]]; then
presigned_url=$(send_command s3cmd --no-check-certificate "${S3CMD_OPTS[@]}" signurl "s3://$2/$3" "$(echo "$(date +%s)" + 900 | bc)") || presign_result=$?
+1 -1
View File
@@ -32,7 +32,7 @@ delete_bucket() {
exit_code=0
if [[ $1 == 's3' ]]; then
error=$(send_command aws --no-verify-ssl s3 rb s3://"$2") || exit_code=$?
elif [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then
elif [[ $1 == 's3api' ]]; then
error=$(send_command aws --no-verify-ssl s3api delete-bucket --bucket "$2" 2>&1) || exit_code=$?
elif [[ $1 == 's3cmd' ]]; then
error=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate rb s3://"$2" 2>&1) || exit_code=$?
+1 -1
View File
@@ -21,7 +21,7 @@ delete_bucket_policy() {
return 1
fi
local delete_result=0
if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then
if [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then
error=$(send_command aws --no-verify-ssl s3api delete-bucket-policy --bucket "$2" 2>&1) || delete_result=$?
elif [[ $1 == 's3cmd' ]]; then
error=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate delpolicy "s3://$2" 2>&1) || delete_result=$?
+1 -1
View File
@@ -21,7 +21,7 @@ delete_bucket_tagging() {
return 1
fi
local result
if [[ $1 == 'aws' ]]; then
if [[ $1 == 's3api' ]]; then
tags=$(send_command aws --no-verify-ssl s3api delete-bucket-tagging --bucket "$2" 2>&1) || result=$?
elif [[ $1 == 'mc' ]]; then
tags=$(send_command mc --insecure tag remove "$MC_ALIAS"/"$2" 2>&1) || result=$?
+1 -1
View File
@@ -25,7 +25,7 @@ delete_object() {
local exit_code=0
if [[ $1 == 's3' ]]; then
delete_object_error=$(send_command aws --no-verify-ssl s3 rm "s3://$2/$3" 2>&1) || exit_code=$?
elif [[ $1 == 's3api' ]] || [[ $1 == 'aws' ]]; then
elif [[ $1 == 's3api' ]]; then
delete_object_error=$(send_command aws --no-verify-ssl s3api delete-object --bucket "$2" --key "$3" 2>&1) || exit_code=$?
elif [[ $1 == 's3cmd' ]]; then
delete_object_error=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate rm "s3://$2/$3" 2>&1) || exit_code=$?
+1 -1
View File
@@ -21,7 +21,7 @@ delete_object_tagging() {
return 1
fi
delete_result=0
if [[ $1 == 'aws' ]]; then
if [[ $1 == 's3api' ]]; then
error=$(send_command aws --no-verify-ssl s3api delete-object-tagging --bucket "$2" --key "$3" 2>&1) || delete_result=$?
elif [[ $1 == 'mc' ]]; then
error=$(send_command mc --insecure tag remove "$MC_ALIAS/$2/$3") || delete_result=$?
+1 -1
View File
@@ -21,7 +21,7 @@ get_bucket_acl() {
return 1
fi
local exit_code=0
if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then
if [[ $1 == 's3api' ]]; then
acl=$(send_command aws --no-verify-ssl s3api get-bucket-acl --bucket "$2" 2>&1) || exit_code="$?"
elif [[ $1 == 's3cmd' ]]; then
acl=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate info "s3://$2" 2>&1) || exit_code="$?"
+1 -1
View File
@@ -21,7 +21,7 @@ get_bucket_location() {
return 1
fi
get_result=0
if [[ $1 == 'aws' ]]; then
if [[ $1 == 's3api' ]]; then
get_bucket_location_aws "$2" || get_result=$?
elif [[ $1 == 's3cmd' ]]; then
get_bucket_location_s3cmd "$2" || get_result=$?
+1 -1
View File
@@ -21,7 +21,7 @@ get_bucket_policy() {
return 1
fi
local get_bucket_policy_result=0
if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then
if [[ $1 == 's3api' ]]; then
get_bucket_policy_aws "$2" || get_bucket_policy_result=$?
elif [[ $1 == 's3cmd' ]]; then
get_bucket_policy_s3cmd "$2" || get_bucket_policy_result=$?
+1 -1
View File
@@ -21,7 +21,7 @@ get_bucket_tagging() {
assert [ $# -eq 2 ]
record_command "get-bucket-tagging" "client:$1"
local result
if [[ $1 == 'aws' ]]; then
if [[ $1 == 's3api' ]]; then
tags=$(send_command aws --no-verify-ssl s3api get-bucket-tagging --bucket "$2" 2>&1) || result=$?
elif [[ $1 == 'mc' ]]; then
tags=$(send_command mc --insecure tag list "$MC_ALIAS"/"$2" 2>&1) || result=$?
+1 -1
View File
@@ -24,7 +24,7 @@ get_object() {
local exit_code=0
if [[ $1 == 's3' ]]; then
get_object_error=$(send_command aws --no-verify-ssl s3 mv "s3://$2/$3" "$4" 2>&1) || exit_code=$?
elif [[ $1 == 's3api' ]] || [[ $1 == 'aws' ]]; then
elif [[ $1 == 's3api' ]]; then
get_object_error=$(send_command aws --no-verify-ssl s3api get-object --bucket "$2" --key "$3" "$4" 2>&1) || exit_code=$?
elif [[ $1 == 's3cmd' ]]; then
get_object_error=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate get "s3://$2/$3" "$4" 2>&1) || exit_code=$?
+1 -1
View File
@@ -21,7 +21,7 @@ get_object_tagging() {
return 1
fi
local result
if [[ "$1" == 'aws' ]] || [[ $1 == 's3api' ]]; then
if [[ $1 == 's3api' ]]; then
tags=$(send_command aws --no-verify-ssl s3api get-object-tagging --bucket "$2" --key "$3" 2>&1) || result=$?
elif [[ "$1" == 'mc' ]]; then
tags=$(send_command mc --insecure tag list "$MC_ALIAS"/"$2"/"$3" 2>&1) || result=$?
+1 -1
View File
@@ -29,7 +29,7 @@ head_bucket() {
return 1
fi
local exit_code=0
if [[ $1 == "aws" ]] || [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then
if [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then
bucket_info=$(send_command aws --no-verify-ssl s3api head-bucket --bucket "$2" 2>&1) || exit_code=$?
elif [[ $1 == "s3cmd" ]]; then
bucket_info=$(send_command s3cmd --no-check-certificate info "s3://$2" 2>&1) || exit_code=$?
+1 -1
View File
@@ -21,7 +21,7 @@ head_object() {
return 2
fi
local exit_code=0
if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then
if [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then
metadata=$(send_command aws --no-verify-ssl s3api head-object --bucket "$2" --key "$3" 2>&1) || exit_code="$?"
elif [[ $1 == 's3cmd' ]]; then
metadata=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate info s3://"$2/$3" 2>&1) || exit_code="$?"
+1 -1
View File
@@ -25,7 +25,7 @@ list_buckets() {
local exit_code=0
if [[ $1 == 's3' ]]; then
buckets=$(send_command aws --no-verify-ssl s3 ls 2>&1 s3://) || exit_code=$?
elif [[ $1 == 's3api' ]] || [[ $1 == 'aws' ]]; then
elif [[ $1 == 's3api' ]]; then
list_buckets_s3api "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" || exit_code=$?
elif [[ $1 == 's3cmd' ]]; then
buckets=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate ls s3:// 2>&1) || exit_code=$?
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
source ./tests/util_list_objects.sh
source ./tests/util/util_list_objects.sh
source ./tests/commands/command.sh
# Copyright 2024 Versity Software
@@ -29,7 +29,7 @@ list_objects() {
local output
local result=0
if [[ $1 == "aws" ]] || [[ $1 == 's3' ]]; then
if [[ $1 == 's3' ]]; then
output=$(send_command aws --no-verify-ssl s3 ls s3://"$2" 2>&1) || result=$?
elif [[ $1 == 's3api' ]]; then
list_objects_s3api "$2" || result=$?
+1 -1
View File
@@ -14,7 +14,7 @@
# specific language governing permissions and limitations
# under the License.
source ./tests/util_file.sh
source ./tests/util/util_file.sh
source ./tests/commands/command.sh
put_bucket_acl_s3api() {
+1 -1
View File
@@ -21,7 +21,7 @@ put_bucket_policy() {
return 1
fi
local put_policy_result=0
if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then
if [[ $1 == 's3api' ]]; then
policy=$(send_command aws --no-verify-ssl s3api put-bucket-policy --bucket "$2" --policy "file://$3" 2>&1) || put_policy_result=$?
elif [[ $1 == 's3cmd' ]]; then
policy=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate setpolicy "$3" "s3://$2" 2>&1) || put_policy_result=$?
+1 -1
View File
@@ -23,7 +23,7 @@ put_bucket_tagging() {
local error
local result=0
record_command "put-bucket-tagging" "client:$1"
if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then
if [[ $1 == 's3api' ]]; then
error=$(send_command aws --no-verify-ssl s3api put-bucket-tagging --bucket "$2" --tagging "TagSet=[{Key=$3,Value=$4}]") || result=$?
elif [[ $1 == 'mc' ]]; then
error=$(send_command mc --insecure tag set "$MC_ALIAS"/"$2" "$3=$4" 2>&1) || result=$?
+1 -1
View File
@@ -27,7 +27,7 @@ put_object() {
local error
if [[ $1 == 's3' ]]; then
error=$(send_command aws --no-verify-ssl s3 mv "$2" s3://"$3/$4" 2>&1) || exit_code=$?
elif [[ $1 == 's3api' ]] || [[ $1 == 'aws' ]]; then
elif [[ $1 == 's3api' ]]; then
error=$(send_command aws --no-verify-ssl s3api put-object --body "$2" --bucket "$3" --key "$4" 2>&1) || exit_code=$?
elif [[ $1 == 's3cmd' ]]; then
error=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate put "$2" s3://"$3/$4" 2>&1) || exit_code=$?
+1 -1
View File
@@ -22,7 +22,7 @@ put_object_tagging() {
local error
local result
record_command "put-object-tagging" "client:$1"
if [[ $1 == 'aws' ]]; then
if [[ $1 == 's3api' ]]; then
error=$(send_command aws --no-verify-ssl s3api put-object-tagging --bucket "$2" --key "$3" --tagging "TagSet=[{Key=$4,Value=$5}]" 2>&1) || result=$?
elif [[ $1 == 'mc' ]]; then
error=$(send_command mc --insecure tag set "$MC_ALIAS"/"$2"/"$3" "$4=$5" 2>&1) || result=$?
+1 -1
View File
@@ -15,7 +15,7 @@
# under the License.
source ./tests/setup.sh
source ./tests/util.sh
source ./tests/util/util.sh
delete_bucket_if_exists() {
if [[ $# -ne 2 ]]; then
+43
View File
@@ -0,0 +1,43 @@
#!/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.
source ./tests/rest_scripts/rest.sh
# Fields
# shellcheck disable=SC2153
bucket_name="$BUCKET_NAME"
current_date_time=$(date -u +"%Y%m%dT%H%M%SZ")
canonical_request="GET
/$bucket_name
policy=
host:$host
x-amz-content-sha256:UNSIGNED-PAYLOAD
x-amz-date:$current_date_time
host;x-amz-content-sha256;x-amz-date
UNSIGNED-PAYLOAD"
create_canonical_hash_sts_and_signature
curl_command+=(curl -ks -w "\"%{http_code}\"" "$AWS_ENDPOINT_URL/$bucket_name?policy="
-H "\"Authorization: AWS4-HMAC-SHA256 Credential=$aws_access_key_id/$year_month_day/$aws_region/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=$signature\""
-H "\"x-amz-content-sha256: UNSIGNED-PAYLOAD\""
-H "\"x-amz-date: $current_date_time\""
-o "$OUTPUT_FILE")
# shellcheck disable=SC2154
eval "${curl_command[*]}" 2>&1
+1 -1
View File
@@ -20,7 +20,7 @@ load ./bats-assert/load
source ./tests/env.sh
source ./tests/report.sh
source ./tests/setup_mc.sh
source ./tests/util.sh
source ./tests/util/util.sh
source ./tests/versity.sh
# bats setup function
+1 -1
View File
@@ -15,7 +15,7 @@
# under the License.
source ./tests/env.sh
source ./tests/util.sh
source ./tests/util/util.sh
source ./tests/commands/create_bucket.sh
create_bucket_if_not_exists() {
+1 -1
View File
@@ -15,7 +15,7 @@
# under the License.
source ./tests/setup.sh
source ./tests/util.sh
source ./tests/util/util.sh
if ! base_setup; then
log 2 "error starting versity to set up static buckets"
+7 -7
View File
@@ -15,13 +15,13 @@
# under the License.
source ./tests/setup.sh
source ./tests/util.sh
source ./tests/util_acl.sh
source ./tests/util_bucket_location.sh
source ./tests/util_file.sh
source ./tests/util_list_buckets.sh
source ./tests/util_policy.sh
source ./tests/util_presigned_url.sh
source ./tests/util/util.sh
source ./tests/util/util_acl.sh
source ./tests/util/util_bucket_location.sh
source ./tests/util/util_file.sh
source ./tests/util/util_list_buckets.sh
source ./tests/util/util_policy.sh
source ./tests/util/util_presigned_url.sh
source ./tests/commands/copy_object.sh
source ./tests/commands/delete_bucket_tagging.sh
source ./tests/commands/delete_object_tagging.sh
+3 -5
View File
@@ -15,13 +15,11 @@
# under the License.
test_put_bucket_acl_s3cmd() {
if [[ $DIRECT != "true" ]]; then
skip "https://github.com/versity/versitygw/issues/695"
if [ "$DIRECT" != "true" ]; then
skip "https://github.com/versity/versitygw/issues/963"
fi
run setup_bucket "s3cmd" "$BUCKET_ONE_NAME"
assert_success
run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred"
run setup_bucket "s3cmd" "$BUCKET_ONE_NAME"
assert_success
username=$USERNAME_ONE
+3 -3
View File
@@ -16,9 +16,9 @@
source ./tests/test_common.sh
source ./tests/setup.sh
source ./tests/util_create_bucket.sh
source ./tests/util_head_bucket.sh
source ./tests/util_tags.sh
source ./tests/util/util_create_bucket.sh
source ./tests/util/util_head_bucket.sh
source ./tests/util/util_tags.sh
source ./tests/commands/delete_bucket_policy.sh
source ./tests/commands/get_bucket_policy.sh
source ./tests/commands/put_bucket_policy.sh
+25 -12
View File
@@ -28,18 +28,19 @@ source ./tests/commands/put_object_retention.sh
source ./tests/commands/put_object_tagging.sh
source ./tests/logger.sh
source ./tests/setup.sh
source ./tests/util.sh
source ./tests/util_attributes.sh
source ./tests/util_legal_hold.sh
source ./tests/util_list_buckets.sh
source ./tests/util_list_objects.sh
source ./tests/util_list_parts.sh
source ./tests/util_lock_config.sh
source ./tests/util_ownership.sh
source ./tests/util_rest.sh
source ./tests/util_tags.sh
source ./tests/util_time.sh
source ./tests/util_versioning.sh
source ./tests/util/util.sh
source ./tests/util/util_attributes.sh
source ./tests/util/util_legal_hold.sh
source ./tests/util/util_list_buckets.sh
source ./tests/util/util_list_objects.sh
source ./tests/util/util_list_parts.sh
source ./tests/util/util_lock_config.sh
source ./tests/util/util_ownership.sh
source ./tests/util/util_policy.sh
source ./tests/util/util_rest.sh
source ./tests/util/util_tags.sh
source ./tests/util/util_time.sh
source ./tests/util/util_versioning.sh
@test "test_rest_list_objects" {
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
@@ -409,4 +410,16 @@ source ./tests/util_versioning.sh
run get_and_check_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred"
assert_success
}
@test "REST - get policy w/o policy" {
if [ "$DIRECT" != "true" ]; then
skip "https://github.com/versity/versitygw/issues/959"
fi
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run get_and_check_no_policy_error "$BUCKET_ONE_NAME"
assert_success
}
+1 -1
View File
@@ -15,7 +15,7 @@
# under the License.
source ./tests/test_common.sh
source ./tests/util_file.sh
source ./tests/util/util_file.sh
# complete-multipart-upload
@test "test_complete_multipart_upload" {
+1 -1
View File
@@ -15,7 +15,7 @@
# under the License.
source ./tests/test_common.sh
source ./tests/util_file.sh
source ./tests/util/util_file.sh
@test "test_list_objects_file_count" {
test_common_list_objects_file_count "s3"
+29 -21
View File
@@ -15,14 +15,13 @@
# under the License.
source ./tests/setup.sh
source ./tests/util.sh
source ./tests/util_aws.sh
source ./tests/util_create_bucket.sh
source ./tests/util_file.sh
source ./tests/util_lock_config.sh
source ./tests/util_tags.sh
source ./tests/util_users.sh
source ./tests/test_aws_root_inner.sh
source ./tests/util/util.sh
source ./tests/util/util_create_bucket.sh
source ./tests/util/util_file.sh
source ./tests/util/util_lock_config.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
source ./tests/commands/copy_object.sh
@@ -51,33 +50,42 @@ source ./tests/commands/select_object_content.sh
export RUN_USERS=true
@test "test_create_bucket_invalid_name" {
test_create_bucket_invalid_name_aws_root
if [[ $RECREATE_BUCKETS != "true" ]]; then
return
fi
run create_and_check_bucket_invalid_name "s3api"
assert_success
}
# create-bucket
@test "test_create_delete_bucket_aws" {
test_common_create_delete_bucket "aws"
@test "test_create_delete_bucket_s3api" {
test_common_create_delete_bucket "s3api"
}
# delete-bucket - test_create_delete_bucket_aws
# delete-bucket - test_create_delete_bucket_s3api
# delete-bucket-policy
@test "test_get_put_delete_bucket_policy" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_common_get_put_delete_bucket_policy "aws"
test_common_get_put_delete_bucket_policy "s3api"
}
# get-bucket-acl
@test "test_get_bucket_acl" {
test_get_bucket_acl_aws_root
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run get_bucket_acl_and_check_owner "s3api" "$BUCKET_ONE_NAME"
assert_success
}
# get-bucket-location
@test "test_get_bucket_location" {
test_common_get_bucket_location "aws"
test_common_get_bucket_location "s3api"
}
# get-bucket-policy - test_get_put_delete_bucket_policy
@@ -85,7 +93,7 @@ export RUN_USERS=true
# get-bucket-tagging - test_set_get_delete_bucket_tags
@test "test_head_bucket" {
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run check_for_empty_region "$BUCKET_ONE_NAME"
@@ -93,17 +101,17 @@ export RUN_USERS=true
}
@test "test_head_bucket_doesnt_exist" {
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
head_bucket "aws" "$BUCKET_ONE_NAME"a || local info_result=$?
head_bucket "s3api" "$BUCKET_ONE_NAME"a || local info_result=$?
[[ $info_result -eq 1 ]] || fail "bucket info for non-existent bucket returned"
[[ $bucket_info == *"404"* ]] || fail "404 not returned for non-existent bucket info"
bucket_cleanup "aws" "$BUCKET_ONE_NAME"
bucket_cleanup "s3api" "$BUCKET_ONE_NAME"
}
@test "test_head_bucket_invalid_name" {
if head_bucket "aws" ""; then
if head_bucket "s3api" ""; then
fail "able to get bucket info for invalid name"
fi
}
@@ -119,5 +127,5 @@ export RUN_USERS=true
# delete-bucket-tagging
@test "test-set-get-delete-bucket-tags" {
test_common_set_get_delete_bucket_tags "aws"
test_common_set_get_delete_bucket_tags "s3api"
}
+111 -12
View File
@@ -15,27 +15,112 @@
# under the License.
source ./tests/setup.sh
source ./tests/test_aws_root_inner.sh
source ./tests/util_file.sh
source ./tests/util_multipart.sh
source ./tests/util_tags.sh
source ./tests/test_s3api_root_inner.sh
source ./tests/util/util_file.sh
source ./tests/util/util_multipart.sh
source ./tests/util/util_tags.sh
source ./tests/commands/get_object.sh
source ./tests/commands/put_object.sh
source ./tests/commands/list_multipart_uploads.sh
# abort-multipart-upload
@test "test_abort_multipart_upload" {
test_abort_multipart_upload_aws_root
local bucket_file="bucket-file"
run create_test_file "$bucket_file"
assert_success
# shellcheck disable=SC2154
run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1
assert_success
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run run_then_abort_multipart_upload "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4
assert_success
run object_exists "s3api" "$BUCKET_ONE_NAME" "$bucket_file"
assert_failure 1
}
# complete-multipart-upload
@test "test_complete_multipart_upload" {
test_complete_multipart_upload_aws_root
local bucket_file="bucket-file"
run create_test_files "$bucket_file"
assert_success
run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1
assert_success
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run multipart_upload "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4
assert_success
run download_and_compare_file "s3api" "$TEST_FILE_FOLDER/$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file-copy"
assert_success
}
# create-multipart-upload
@test "test_create_multipart_upload_properties" {
test_create_multipart_upload_properties_aws_root
local bucket_file="bucket-file"
local expected_content_type="application/zip"
local expected_meta_key="testKey"
local expected_meta_val="testValue"
local expected_hold_status="ON"
local expected_retention_mode="GOVERNANCE"
local expected_tag_key="TestTag"
local expected_tag_val="TestTagVal"
os_name="$(uname)"
if [[ "$os_name" == "Darwin" ]]; then
now=$(date -u +"%Y-%m-%dT%H:%M:%S")
later=$(date -j -v +15S -f "%Y-%m-%dT%H:%M:%S" "$now" +"%Y-%m-%dT%H:%M:%S")
else
now=$(date +"%Y-%m-%dT%H:%M:%S")
later=$(date -d "$now 15 seconds" +"%Y-%m-%dT%H:%M:%S")
fi
run create_test_files "$bucket_file"
assert_success
run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1
assert_success
run bucket_cleanup_if_bucket_exists "s3api" "$BUCKET_ONE_NAME"
assert_success
# in static bucket config, bucket will still exist
if ! bucket_exists "s3api" "$BUCKET_ONE_NAME"; then
run create_bucket_object_lock_enabled "$BUCKET_ONE_NAME"
assert_success
fi
run multipart_upload_with_params "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4 \
"$expected_content_type" \
"{\"$expected_meta_key\": \"$expected_meta_val\"}" \
"$expected_hold_status" \
"$expected_retention_mode" \
"$later" \
"$expected_tag_key=$expected_tag_val"
assert_success
run get_and_verify_metadata "$bucket_file" "$expected_content_type" "$expected_meta_key" "$expected_meta_val" \
"$expected_hold_status" "$expected_retention_mode" "$later"
assert_success
run check_verify_object_tags "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "$expected_tag_key" "$expected_tag_val"
assert_success
run put_object_legal_hold "$BUCKET_ONE_NAME" "$bucket_file" "OFF"
assert_success
run get_and_check_legal_hold "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "OFF"
assert_success
run download_and_compare_file "s3api" "$TEST_FILE_FOLDER/$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file-copy" || fail "error getting object"
assert_success
}
@test "test-multipart-upload-from-bucket" {
@@ -47,7 +132,7 @@ source ./tests/commands/list_multipart_uploads.sh
run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1
assert_success
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run multipart_upload_from_bucket "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4
@@ -65,7 +150,7 @@ source ./tests/commands/list_multipart_uploads.sh
run create_large_file "$bucket_file"
assert_success
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run multipart_upload_range_too_large "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file"
@@ -77,7 +162,7 @@ source ./tests/commands/list_multipart_uploads.sh
run create_large_file "$bucket_file"
assert_success
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run run_and_verify_multipart_upload_with_valid_range "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file"
@@ -86,7 +171,21 @@ source ./tests/commands/list_multipart_uploads.sh
# test multi-part upload list parts command
@test "test-multipart-upload-list-parts" {
test_multipart_upload_list_parts_aws_root
local bucket_file="bucket-file"
run create_test_file "$bucket_file" 0
assert_success
run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1
assert_success
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run start_multipart_upload_list_check_parts "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file"
assert_success
run run_then_abort_multipart_upload "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file" 4
assert_success
}
# test listing of active uploads
@@ -102,7 +201,7 @@ source ./tests/commands/list_multipart_uploads.sh
run create_test_files "$bucket_file_one" "$bucket_file_two"
assert_success
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run create_list_check_multipart_uploads "$BUCKET_ONE_NAME" "$bucket_file_one" "$bucket_file_two"
+35 -36
View File
@@ -15,14 +15,13 @@
# under the License.
source ./tests/setup.sh
source ./tests/util.sh
source ./tests/util_aws.sh
source ./tests/util_create_bucket.sh
source ./tests/util_file.sh
source ./tests/util_lock_config.sh
source ./tests/util_tags.sh
source ./tests/util_users.sh
source ./tests/test_aws_root_inner.sh
source ./tests/util/util.sh
source ./tests/util/util_create_bucket.sh
source ./tests/util/util_file.sh
source ./tests/util/util_lock_config.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
source ./tests/commands/copy_object.sh
@@ -63,7 +62,7 @@ export RUN_USERS=true
# delete-object-tagging
@test "test_delete_object_tagging" {
test_common_delete_object_tagging "aws"
test_common_delete_object_tagging "s3api"
}
# delete-objects
@@ -71,34 +70,34 @@ export RUN_USERS=true
if [ "$RECREATE_BUCKETS" == "false" ]; then
skip "https://github.com/versity/versitygw/issues/888"
fi
test_delete_objects_aws_root
test_delete_objects_s3api_root
}
# get-object
@test "test_get_object_full_range" {
test_get_object_full_range_aws_root
test_get_object_full_range_s3api_root
}
@test "test_get_object_invalid_range" {
test_get_object_invalid_range_aws_root
test_get_object_invalid_range_s3api_root
}
# get-object-attributes
@test "test_get_object_attributes" {
test_get_object_attributes_aws_root
test_get_object_attributes_s3api_root
}
@test "test_get_put_object_legal_hold" {
test_get_put_object_legal_hold_aws_root
test_get_put_object_legal_hold_s3api_root
}
@test "test_get_put_object_retention" {
test_get_put_object_retention_aws_root
test_get_put_object_retention_s3api_root
}
# test listing a bucket's objects on versitygw
@test "test_list_objects" {
test_common_list_objects "aws"
test_common_list_objects "s3api"
}
@test "test-list-objects-delimiter" {
@@ -111,10 +110,10 @@ export RUN_USERS=true
run create_test_file "$folder_name"/"$object_name"
assert_success
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run put_object "aws" "$TEST_FILE_FOLDER/$folder_name/$object_name" "$BUCKET_ONE_NAME" "$folder_name/$object_name"
run put_object "s3api" "$TEST_FILE_FOLDER/$folder_name/$object_name" "$BUCKET_ONE_NAME" "$folder_name/$object_name"
assert_success
run check_object_listing_with_prefixes "$BUCKET_ONE_NAME" "$folder_name" "$object_name"
@@ -122,7 +121,7 @@ export RUN_USERS=true
}
@test "test_put_object" {
test_put_object_aws_root
test_put_object_s3api_root
}
# test adding and removing an object on versitygw
@@ -130,18 +129,18 @@ export RUN_USERS=true
if [ "$RECREATE_BUCKETS" == "false" ]; then
skip "https://github.com/versity/versitygw/issues/888"
fi
test_common_put_object_with_data "aws"
test_common_put_object_with_data "s3api"
}
@test "test_put_object_no_data" {
if [ "$RECREATE_BUCKETS" == "false" ]; then
skip "https://github.com/versity/versitygw/issues/888"
fi
test_common_put_object_no_data "aws"
test_common_put_object_no_data "s3api"
}
@test "test-presigned-url-utf8-chars" {
test_common_presigned_url_utf8_chars "aws"
test_common_presigned_url_utf8_chars "s3api"
}
@test "test_put_object_lock_configuration" {
@@ -162,7 +161,7 @@ export RUN_USERS=true
run get_and_check_object_lock_config "$bucket_name" "$enabled" "$governance" "$days"
assert_success "error getting and checking object lock config"
bucket_cleanup "aws" "$bucket_name"
bucket_cleanup "s3api" "$bucket_name"
}
@test "test_put_object_metadata" {
@@ -173,50 +172,50 @@ export RUN_USERS=true
run create_test_files "$object_one"
assert_success
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
object="$TEST_FILE_FOLDER"/"$object_one"
put_object_with_metadata "aws" "$object" "$BUCKET_ONE_NAME" "$object_one" "$test_key" "$test_value" || fail "failed to add object to bucket"
object_exists "aws" "$BUCKET_ONE_NAME" "$object_one" || fail "object not found after being added to bucket"
put_object_with_metadata "s3api" "$object" "$BUCKET_ONE_NAME" "$object_one" "$test_key" "$test_value" || fail "failed to add object to bucket"
object_exists "s3api" "$BUCKET_ONE_NAME" "$object_one" || fail "object not found after being added to bucket"
get_object_metadata "aws" "$BUCKET_ONE_NAME" "$object_one" || fail "error getting object metadata"
get_object_metadata "s3api" "$BUCKET_ONE_NAME" "$object_one" || fail "error getting object metadata"
key=$(echo "$metadata" | jq -r 'keys[]' 2>&1) || fail "error getting key from metadata: $key"
value=$(echo "$metadata" | jq -r '.[]' 2>&1) || fail "error getting value from metadata: $value"
[[ $key == "$test_key" ]] || fail "keys doesn't match (expected $key, actual \"$test_key\")"
[[ $value == "$test_value" ]] || fail "values doesn't match (expected $value, actual \"$test_value\")"
bucket_cleanup "aws" "$BUCKET_ONE_NAME"
bucket_cleanup "s3api" "$BUCKET_ONE_NAME"
delete_test_files "$object_one"
}
@test "test_retention_bypass" {
test_retention_bypass_aws_root
test_retention_bypass_s3api_root
}
# test v1 s3api list objects command
@test "test-s3api-list-objects-v1" {
test_s3api_list_objects_v1_aws_root
test_s3api_list_objects_v1_s3api_root
}
# test v2 s3api list objects command
@test "test-s3api-list-objects-v2" {
test_s3api_list_objects_v2_aws_root
test_s3api_list_objects_v2_s3api_root
}
# test abilty to set and retrieve object tags
@test "test-set-get-object-tags" {
test_common_set_get_object_tags "aws"
test_common_set_get_object_tags "s3api"
}
# ensure that lists of files greater than a size of 1000 (pagination) are returned properly
#@test "test_list_objects_file_count" {
# test_common_list_objects_file_count "aws"
# test_common_list_objects_file_count "s3api"
#}
# ensure that lists of files greater than a size of 1000 (pagination) are returned properly
#@test "test_list_objects_file_count" {
# test_common_list_objects_file_count "aws"
# test_common_list_objects_file_count "s3api"
#}
#@test "test_filename_length" {
@@ -226,10 +225,10 @@ export RUN_USERS=true
# create_test_files "$file_name" || created=$?
# [[ $created -eq 0 ]] || fail "error creating file"
# setup_bucket "aws" "$BUCKET_ONE_NAME" || local setup_result=$?
# setup_bucket "s3api" "$BUCKET_ONE_NAME" || local setup_result=$?
# [[ $setup_result -eq 0 ]] || fail "error setting up bucket"
# put_object "aws" "$TEST_FILE_FOLDER"/"$file_name" "$BUCKET_ONE_NAME"/"$file_name" || local put_object=$?
# put_object "s3api" "$TEST_FILE_FOLDER"/"$file_name" "$BUCKET_ONE_NAME"/"$file_name" || local put_object=$?
# [[ $put_object -eq 0 ]] || fail "Failed to add object to bucket"
#}
+5 -5
View File
@@ -19,11 +19,11 @@ source ./tests/setup.sh
source ./tests/test_s3api_policy_bucket.sh
source ./tests/test_s3api_policy_multipart.sh
source ./tests/test_s3api_policy_object.sh
source ./tests/util_multipart.sh
source ./tests/util_file.sh
source ./tests/util_policy.sh
source ./tests/util_tags.sh
source ./tests/util_users.sh
source ./tests/util/util_multipart.sh
source ./tests/util/util_file.sh
source ./tests/util/util_policy.sh
source ./tests/util/util_tags.sh
source ./tests/util/util_users.sh
source ./tests/commands/get_bucket_policy.sh
source ./tests/commands/get_bucket_tagging.sh
source ./tests/commands/get_object.sh
+1 -1
View File
@@ -14,7 +14,7 @@
# specific language governing permissions and limitations
# under the License.
source ./tests/util_acl.sh
source ./tests/util/util_acl.sh
test_s3api_policy_delete_bucket_policy() {
policy_file="policy_file"
@@ -17,111 +17,14 @@
source ./tests/commands/delete_objects.sh
source ./tests/commands/list_objects_v2.sh
source ./tests/commands/list_parts.sh
source ./tests/util_get_bucket_acl.sh
source ./tests/util_get_object_attributes.sh
source ./tests/util_get_object_retention.sh
source ./tests/util_head_object.sh
source ./tests/util_legal_hold.sh
source ./tests/util_list_objects.sh
source ./tests/util/util_get_bucket_acl.sh
source ./tests/util/util_get_object_attributes.sh
source ./tests/util/util_get_object_retention.sh
source ./tests/util/util_head_object.sh
source ./tests/util/util_legal_hold.sh
source ./tests/util/util_list_objects.sh
test_abort_multipart_upload_aws_root() {
local bucket_file="bucket-file"
run create_test_file "$bucket_file"
assert_success
# shellcheck disable=SC2154
run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1
assert_success
run setup_bucket "aws" "$BUCKET_ONE_NAME"
assert_success
run run_then_abort_multipart_upload "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4
assert_success
run object_exists "aws" "$BUCKET_ONE_NAME" "$bucket_file"
assert_failure 1
}
test_complete_multipart_upload_aws_root() {
local bucket_file="bucket-file"
run create_test_files "$bucket_file"
assert_success
run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1
assert_success
run setup_bucket "aws" "$BUCKET_ONE_NAME"
assert_success
run multipart_upload "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4
assert_success
run download_and_compare_file "s3api" "$TEST_FILE_FOLDER/$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file-copy"
assert_success
}
test_create_multipart_upload_properties_aws_root() {
local bucket_file="bucket-file"
local expected_content_type="application/zip"
local expected_meta_key="testKey"
local expected_meta_val="testValue"
local expected_hold_status="ON"
local expected_retention_mode="GOVERNANCE"
local expected_tag_key="TestTag"
local expected_tag_val="TestTagVal"
os_name="$(uname)"
if [[ "$os_name" == "Darwin" ]]; then
now=$(date -u +"%Y-%m-%dT%H:%M:%S")
later=$(date -j -v +15S -f "%Y-%m-%dT%H:%M:%S" "$now" +"%Y-%m-%dT%H:%M:%S")
else
now=$(date +"%Y-%m-%dT%H:%M:%S")
later=$(date -d "$now 15 seconds" +"%Y-%m-%dT%H:%M:%S")
fi
run create_test_files "$bucket_file"
assert_success
run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1
assert_success
run bucket_cleanup_if_bucket_exists "s3api" "$BUCKET_ONE_NAME"
assert_success
# in static bucket config, bucket will still exist
if ! bucket_exists "s3api" "$BUCKET_ONE_NAME"; then
run create_bucket_object_lock_enabled "$BUCKET_ONE_NAME"
assert_success
fi
run multipart_upload_with_params "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4 \
"$expected_content_type" \
"{\"$expected_meta_key\": \"$expected_meta_val\"}" \
"$expected_hold_status" \
"$expected_retention_mode" \
"$later" \
"$expected_tag_key=$expected_tag_val"
assert_success
run get_and_verify_metadata "$bucket_file" "$expected_content_type" "$expected_meta_key" "$expected_meta_val" \
"$expected_hold_status" "$expected_retention_mode" "$later"
assert_success
run check_verify_object_tags "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "$expected_tag_key" "$expected_tag_val"
assert_success
run put_object_legal_hold "$BUCKET_ONE_NAME" "$bucket_file" "OFF"
assert_success
run get_and_check_legal_hold "s3api" "$BUCKET_ONE_NAME" "$bucket_file" "OFF"
assert_success
run download_and_compare_file "s3api" "$TEST_FILE_FOLDER/$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file-copy" || fail "error getting object"
assert_success
}
test_delete_objects_aws_root() {
test_delete_objects_s3api_root() {
local object_one="test-file-one"
local object_two="test-file-two"
@@ -147,19 +50,7 @@ test_delete_objects_aws_root() {
assert_failure 1
}
test_get_bucket_acl_aws_root() {
# TODO remove when able to assign bucket ownership back to root
if [[ $RECREATE_BUCKETS == "false" ]]; then
skip
fi
run setup_bucket "aws" "$BUCKET_ONE_NAME"
assert_success
run get_bucket_acl_and_check_owner "s3api" "$BUCKET_ONE_NAME"
assert_success
}
test_get_object_full_range_aws_root() {
test_get_object_full_range_s3api_root() {
bucket_file="bucket_file"
run create_test_files "$bucket_file" 0
@@ -178,7 +69,7 @@ test_get_object_full_range_aws_root() {
assert [ "$(cat "$TEST_FILE_FOLDER/$bucket_file-range")" == "9" ]
}
test_get_object_invalid_range_aws_root() {
test_get_object_invalid_range_s3api_root() {
bucket_file="bucket_file"
run create_test_files "$bucket_file"
assert_success
@@ -193,7 +84,7 @@ test_get_object_invalid_range_aws_root() {
assert_success
}
test_put_object_aws_root() {
test_put_object_s3api_root() {
bucket_file="bucket_file"
run create_test_files "$bucket_file"
@@ -212,16 +103,7 @@ test_put_object_aws_root() {
assert_success
}
test_create_bucket_invalid_name_aws_root() {
if [[ $RECREATE_BUCKETS != "true" ]]; then
return
fi
run create_and_check_bucket_invalid_name "aws"
assert_success
}
test_get_object_attributes_aws_root() {
test_get_object_attributes_s3api_root() {
bucket_file="bucket_file"
run create_test_file "$bucket_file"
assert_success
@@ -236,10 +118,9 @@ test_get_object_attributes_aws_root() {
assert_success
}
test_get_put_object_legal_hold_aws_root() {
test_get_put_object_legal_hold_s3api_root() {
if [[ $RECREATE_BUCKETS == "false" ]]; then
# https://github.com/versity/versitygw/issues/716
skip
skip "https://github.com/versity/versitygw/issues/716"
fi
bucket_file="bucket_file"
@@ -276,14 +157,13 @@ test_get_put_object_legal_hold_aws_root() {
assert_success
}
test_get_put_object_retention_aws_root() {
test_get_put_object_retention_s3api_root() {
bucket_file="bucket_file"
username=$USERNAME_ONE
secret_key=$PASSWORD_ONE
if [[ $RECREATE_BUCKETS == "false" ]]; then
# https://github.com/versity/versitygw/issues/716
skip
skip "https://github.com/versity/versitygw/issues/716"
fi
run legal_hold_retention_setup "$username" "$secret_key" "$bucket_file"
@@ -317,10 +197,9 @@ test_get_put_object_retention_aws_root() {
assert_output --partial "Object is WORM protected and cannot be overwritten"
}
test_retention_bypass_aws_root() {
test_retention_bypass_s3api_root() {
if [[ $RECREATE_BUCKETS == "false" ]]; then
# https://github.com/versity/versitygw/issues/716
skip
skip "https://github.com/versity/versitygw/issues/716"
fi
bucket_file="bucket_file"
username=$USERNAME_ONE
@@ -382,14 +261,14 @@ legal_hold_retention_setup() {
assert_success
}
test_s3api_list_objects_v1_aws_root() {
test_s3api_list_objects_v1_s3api_root() {
local object_one="test-file-one"
local object_two="test-file-two"
run create_test_files "$object_one" "$object_two"
assert_success
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run put_object "s3api" "$TEST_FILE_FOLDER"/"$object_one" "$BUCKET_ONE_NAME" "$object_one"
@@ -402,14 +281,14 @@ test_s3api_list_objects_v1_aws_root() {
assert_success
}
test_s3api_list_objects_v2_aws_root() {
test_s3api_list_objects_v2_s3api_root() {
local object_one="test-file-one"
local object_two="test-file-two"
run create_test_files "$object_one" "$object_two"
assert_success
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
run put_object "s3api" "$TEST_FILE_FOLDER"/"$object_one" "$BUCKET_ONE_NAME" "$object_one"
@@ -421,21 +300,3 @@ test_s3api_list_objects_v2_aws_root() {
run list_check_objects_v2 "$BUCKET_ONE_NAME" "$object_one" 10 "$object_two" 10
assert_success
}
test_multipart_upload_list_parts_aws_root() {
local bucket_file="bucket-file"
run create_test_file "$bucket_file" 0
assert_success
run dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1
assert_success
run setup_bucket "aws" "$BUCKET_ONE_NAME"
assert_success
run start_multipart_upload_list_check_parts "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file"
assert_success
run run_then_abort_multipart_upload "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER/$bucket_file" 4
assert_success
}
+3 -3
View File
@@ -17,9 +17,9 @@
source ./tests/setup.sh
source ./tests/test_common.sh
source ./tests/test_common_acl.sh
source ./tests/util.sh
source ./tests/util_create_bucket.sh
source ./tests/util_users.sh
source ./tests/util/util.sh
source ./tests/util/util_create_bucket.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
+1 -1
View File
@@ -15,7 +15,7 @@
# under the License.
source ./tests/test_user_common.sh
source ./tests/util_users.sh
source ./tests/util/util_users.sh
source ./tests/commands/get_object.sh
source ./tests/commands/put_object.sh
+17 -17
View File
@@ -15,10 +15,10 @@
# under the License.
source ./tests/setup.sh
source ./tests/util_users.sh
source ./tests/util.sh
source ./tests/util_create_bucket.sh
source ./tests/util_list_buckets.sh
source ./tests/util/util.sh
source ./tests/util/util_create_bucket.sh
source ./tests/util/util_list_buckets.sh
source ./tests/util/util_users.sh
source ./tests/commands/list_buckets.sh
test_admin_user() {
@@ -41,7 +41,7 @@ test_admin_user() {
run create_user_with_user "$admin_username" "$admin_password" "$user_username" "$user_password" "user"
assert_success
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
if [ "$RECREATE_BUCKETS" == "true" ]; then
@@ -52,7 +52,7 @@ test_admin_user() {
assert_success
fi
run list_and_check_buckets_with_user "aws" "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME" "$admin_username" "$admin_password"
run list_and_check_buckets_with_user "s3api" "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME" "$admin_username" "$admin_password"
assert_success
run change_bucket_owner "$admin_username" "$admin_password" "$BUCKET_TWO_NAME" "$user_username"
@@ -89,25 +89,25 @@ test_user_user() {
password="$PASSWORD_ONE"
setup_user "$username" "$password" "user" || fail "error setting up user"
bucket_cleanup_if_bucket_exists "aws" "versity-gwtest-user-bucket"
bucket_cleanup_if_bucket_exists "s3api" "versity-gwtest-user-bucket"
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
if create_bucket_with_user "aws" "versity-gwtest-user-bucket" "$username" "$password"; then
if create_bucket_with_user "s3api" "versity-gwtest-user-bucket" "$username" "$password"; then
fail "creating bucket with 'user' account failed to return error"
fi
# shellcheck disable=SC2154
[[ $error == *"Access Denied"* ]] || fail "error message '$error' doesn't contain 'Access Denied'"
create_bucket "aws" "versity-gwtest-user-bucket" || fail "error creating bucket"
create_bucket "s3api" "versity-gwtest-user-bucket" || fail "error creating bucket"
change_bucket_owner "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "versity-gwtest-user-bucket" "$username" || fail "error changing bucket owner"
if change_bucket_owner "$username" "$password" "versity-gwtest-user-bucket" "admin"; then
fail "user shouldn't be able to change bucket owner"
fi
list_buckets_with_user "aws" "$username" "$password" || fail "error listing buckets with user '$username'"
list_buckets_with_user "s3api" "$username" "$password" || fail "error listing buckets with user '$username'"
bucket_found=false
for bucket in "${bucket_array[@]}"; do
if [ "$bucket" == "$BUCKET_ONE_NAME" ]; then
@@ -120,7 +120,7 @@ test_user_user() {
fail "user-owned bucket not found in user list"
fi
run delete_bucket "aws" "versity-gwtest-user-bucket"
run delete_bucket "s3api" "versity-gwtest-user-bucket"
assert_success "failed to delete bucket"
delete_user "$username"
}
@@ -133,15 +133,15 @@ test_userplus_operation() {
username="$USERNAME_ONE"
password="$PASSWORD_ONE"
bucket_cleanup_if_bucket_exists "aws" "versity-gwtest-userplus-bucket"
bucket_cleanup_if_bucket_exists "s3api" "versity-gwtest-userplus-bucket"
setup_user "$username" "$password" "userplus" || fail "error creating user '$username'"
run setup_bucket "aws" "$BUCKET_ONE_NAME"
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
assert_success
create_bucket_with_user "aws" "versity-gwtest-userplus-bucket" "$username" "$password" || fail "error creating bucket with user '$username'"
create_bucket_with_user "s3api" "versity-gwtest-userplus-bucket" "$username" "$password" || fail "error creating bucket with user '$username'"
list_buckets_with_user "aws" "$username" "$password" || fail "error listing buckets with user '$username'"
list_buckets_with_user "s3api" "$username" "$password" || fail "error listing buckets with user '$username'"
bucket_found=false
for bucket in "${bucket_array[@]}"; do
if [ "$bucket" == "$BUCKET_ONE_NAME" ]; then
@@ -158,7 +158,7 @@ test_userplus_operation() {
fail "userplus shouldn't be able to change bucket owner"
fi
run delete_bucket "aws" "versity-gwtest-admin-bucket"
run delete_bucket "s3api" "versity-gwtest-admin-bucket"
assert_success "failed to delete bucket"
delete_user "$username"
}
+10 -10
View File
@@ -14,11 +14,11 @@
# specific language governing permissions and limitations
# under the License.
source ./tests/util_bucket.sh
source ./tests/util_create_bucket.sh
source ./tests/util_mc.sh
source ./tests/util_multipart.sh
source ./tests/util_versioning.sh
source ./tests/util/util_bucket.sh
source ./tests/util/util_create_bucket.sh
source ./tests/util/util_mc.sh
source ./tests/util/util_multipart.sh
source ./tests/util/util_versioning.sh
source ./tests/logger.sh
source ./tests/commands/abort_multipart_upload.sh
source ./tests/commands/complete_multipart_upload.sh
@@ -45,7 +45,7 @@ source ./tests/commands/put_object_legal_hold.sh
source ./tests/commands/put_object_lock_configuration.sh
source ./tests/commands/upload_part_copy.sh
source ./tests/commands/upload_part.sh
source ./tests/util_users.sh
source ./tests/util/util_users.sh
# params: bucket name
# return 0 for success, 1 for error
@@ -275,7 +275,7 @@ put_object_with_metadata() {
local exit_code=0
local error
if [[ $1 == 'aws' ]]; then
if [[ $1 == 's3api' ]]; then
error=$(aws --no-verify-ssl s3api put-object --body "$2" --bucket "$3" --key "$4" --metadata "{\"$5\":\"$6\"}") || exit_code=$?
else
log 2 "invalid command type $1"
@@ -296,7 +296,7 @@ get_object_metadata() {
fi
local exit_code=0
if [[ $1 == 'aws' ]]; then
if [[ $1 == 's3api' ]]; then
metadata_struct=$(aws --no-verify-ssl s3api head-object --bucket "$2" --key "$3") || exit_code=$?
else
log 2 "invalid command type $1"
@@ -320,7 +320,7 @@ put_object_multiple() {
fi
local exit_code=0
local error
if [[ $1 == 'aws' ]] || [[ $1 == 's3' ]]; then
if [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then
# shellcheck disable=SC2086
error=$(aws --no-verify-ssl s3 cp "$(dirname "$2")" s3://"$3" --recursive --exclude="*" --include="$2" 2>&1) || exit_code=$?
elif [[ $1 == 's3cmd' ]]; then
@@ -350,7 +350,7 @@ check_and_put_object() {
log 2 "check and put object function requires source, bucket, destination"
return 1
fi
object_exists "aws" "$2" "$3" || local exists_result=$?
object_exists "s3api" "$2" "$3" || local exists_result=$?
if [ "$exists_result" -eq 2 ]; then
log 2 "error checking if object exists"
return 1
@@ -44,6 +44,7 @@ get_check_post_change_acl_s3cmd() {
log 5 "ACL after read put: $acl"
acl_lines=$(echo "$acl" | grep "ACL")
log 5 "ACL lines: $acl_lines"
lines=()
while IFS= read -r line; do
lines+=("$line")
done <<< "$acl_lines"
@@ -14,7 +14,7 @@ delete_bucket_recursive() {
local error
if [[ $1 == 's3' ]]; then
error=$(aws --no-verify-ssl s3 rb s3://"$2" --force 2>&1) || exit_code="$?"
elif [[ $1 == "aws" ]] || [[ $1 == 's3api' ]]; then
elif [[ $1 == 's3api' ]]; then
if ! delete_bucket_recursive_s3api "$2"; then
log 2 "error deleting bucket recursively (s3api)"
return 1
@@ -123,7 +123,7 @@ delete_bucket_contents() {
local exit_code=0
local error
if [[ $1 == "aws" ]] || [[ $1 == 's3api' ]]; then
if [[ $1 == 's3api' ]]; then
if ! clear_bucket_s3api "$2"; then
log 2 "error clearing bucket (s3api)"
return 1
@@ -308,7 +308,7 @@ check_for_empty_region() {
log 2 "'check_for_empty_region' requires bucket name"
return 1
fi
if ! head_bucket "aws" "$BUCKET_ONE_NAME"; then
if ! head_bucket "s3api" "$BUCKET_ONE_NAME"; then
log 2 "error getting bucket info"
return 1
fi
@@ -14,7 +14,7 @@
# specific language governing permissions and limitations
# under the License.
source ./tests/util_mc.sh
source ./tests/util/util_mc.sh
source ./tests/logger.sh
create_bucket_invalid_name() {
@@ -223,6 +223,31 @@ put_and_check_for_malformed_policy() {
return 0
}
get_and_check_no_policy_error() {
if [ $# -ne 1 ]; then
log 2 "'get_and_check_no_policy_error' requires bucket name"
return 1
fi
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OUTPUT_FILE="$TEST_FILE_FOLDER/response.txt" ./tests/rest_scripts/get_bucket_policy.sh); then
log 2 "error attempting to get bucket policy response: $result"
return 1
fi
if [ "$result" != "404" ]; then
log 2 "GetBucketOwnershipControls returned unexpected response code: $result, reply: $(cat "$TEST_FILE_FOLDER/response.txt")"
return 1
fi
log 5 "response: $(cat "$TEST_FILE_FOLDER/response.txt")"
if ! bucket_name=$(xmllint --xpath '//*[local-name()="BucketName"]/text()' "$TEST_FILE_FOLDER/response.txt" 2>&1); then
log 2 "error getting bucket name: $bucket_name"
return 1
fi
if [ "$bucket_name" != "$1" ]; then
log 2 "rule mismatch (expected '$1', actual '$bucket_name')"
return 1
fi
return 0
}
get_and_compare_policy_with_file() {
if [ $# -ne 4 ]; then
log 2 "'get_and_compare_policies' reuires bucket, username, password, filename"
+1 -1
View File
@@ -14,7 +14,7 @@
# specific language governing permissions and limitations
# under the License.
source ./tests/util_file.sh
source ./tests/util/util_file.sh
start_versity_process() {
if [[ $# -ne 1 ]]; then