mirror of
https://github.com/versity/versitygw.git
synced 2026-06-05 10:32:33 +00:00
Merge pull request #800 from versity/ben/tests_direct
fix: get direct tests working against a non-versitygw endpoint
This commit is contained in:
@@ -35,7 +35,7 @@ RUN curl https://dl.min.io/client/mc/release/${MC_FOLDER}/mc \
|
||||
--create-dirs \
|
||||
-o /usr/local/minio-binaries/mc && \
|
||||
chmod -R 755 /usr/local/minio-binaries
|
||||
ENV PATH="/usr/local/minio-binaries":${PATH}
|
||||
ENV PATH=/usr/local/minio-binaries:${PATH}
|
||||
|
||||
# Download Go 1.21 (adjust the version and platform as needed)
|
||||
RUN wget https://golang.org/dl/${GO_LIBRARY}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
no_certs:
|
||||
build:
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
version: "3"
|
||||
services:
|
||||
posix:
|
||||
build:
|
||||
|
||||
@@ -21,7 +21,7 @@ delete_bucket_policy() {
|
||||
return 1
|
||||
fi
|
||||
local delete_result=0
|
||||
if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then
|
||||
if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then
|
||||
error=$(aws --no-verify-ssl s3api delete-bucket-policy --bucket "$2" 2>&1) || delete_result=$?
|
||||
elif [[ $1 == 's3cmd' ]]; then
|
||||
error=$(s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate delpolicy "s3://$2" 2>&1) || delete_result=$?
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
# under the License.
|
||||
|
||||
get_bucket_ownership_controls() {
|
||||
if [[ -n "$SKIP_BUCKET_OWNERSHIP_CONTROLS" ]]; then
|
||||
log 5 "Skipping get bucket ownership controls"
|
||||
return 0
|
||||
fi
|
||||
|
||||
record_command "get-bucket-ownership-controls" "client:s3api"
|
||||
if [[ $# -ne 1 ]]; then
|
||||
log 2 "'get bucket ownership controls' command requires bucket name"
|
||||
@@ -32,6 +37,11 @@ get_bucket_ownership_controls() {
|
||||
}
|
||||
|
||||
get_object_ownership_rule() {
|
||||
if [[ -n "$SKIP_BUCKET_OWNERSHIP_CONTROLS" ]]; then
|
||||
log 5 "Skipping get bucket ownership controls"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
log 2 "'get object ownership rule' command requires bucket name"
|
||||
return 1
|
||||
|
||||
@@ -57,7 +57,7 @@ reset_bucket_acl() {
|
||||
return 1
|
||||
fi
|
||||
# shellcheck disable=SC2154
|
||||
cat <<EOF > "$test_file_folder/$acl_file"
|
||||
cat <<EOF > "$TEST_FILE_FOLDER/$acl_file"
|
||||
{
|
||||
"Grants": [
|
||||
{
|
||||
@@ -73,7 +73,7 @@ reset_bucket_acl() {
|
||||
}
|
||||
}
|
||||
EOF
|
||||
if ! put_bucket_acl_s3api "$BUCKET_ONE_NAME" "$test_file_folder/$acl_file"; then
|
||||
if ! put_bucket_acl_s3api "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER/$acl_file"; then
|
||||
log 2 "error putting bucket acl (s3api)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
|
||||
# fail if unable to put bucket ownership controls
|
||||
put_bucket_ownership_controls() {
|
||||
if [[ -n "$SKIP_BUCKET_OWNERSHIP_CONTROLS" ]]; then
|
||||
log 5 "Skipping get bucket ownership controls"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log 6 "put_bucket_ownership_controls"
|
||||
record_command "put-bucket-ownership-controls" "client:s3api"
|
||||
assert [ $# -eq 2 ]
|
||||
|
||||
@@ -19,19 +19,12 @@ if [[ -z "$VERSITYGW_TEST_ENV" ]] && [[ $BYPASS_ENV_FILE != "true" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! ./tests/run.sh aws; then
|
||||
exit 1
|
||||
fi
|
||||
if ! ./tests/run.sh s3; then
|
||||
exit 1
|
||||
fi
|
||||
if ! ./tests/run.sh s3cmd; then
|
||||
exit 1
|
||||
fi
|
||||
if ! ./tests/run.sh mc; then
|
||||
exit 1
|
||||
fi
|
||||
if ! ./tests/run.sh rest; then
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
status=0
|
||||
|
||||
for cmd in aws s3 s3cmd mc rest; do
|
||||
if ! ./tests/run.sh "$cmd"; then
|
||||
status=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $status
|
||||
|
||||
@@ -63,10 +63,10 @@ setup() {
|
||||
# bats teardown function
|
||||
teardown() {
|
||||
# shellcheck disable=SC2154
|
||||
if ! delete_bucket_or_contents_if_exists "$BUCKET_ONE_NAME"; then
|
||||
if ! delete_bucket_or_contents_if_exists "s3api" "$BUCKET_ONE_NAME"; then
|
||||
log 3 "error deleting bucket $BUCKET_ONE_NAME or contents"
|
||||
fi
|
||||
if ! delete_bucket_or_contents_if_exists "$BUCKET_TWO_NAME"; then
|
||||
if ! delete_bucket_or_contents_if_exists "s3api" "$BUCKET_TWO_NAME"; then
|
||||
log 3 "error deleting bucket $BUCKET_TWO_NAME or contents"
|
||||
fi
|
||||
if [ "$REMOVE_TEST_FILE_FOLDER" == "true" ]; then
|
||||
|
||||
@@ -96,9 +96,9 @@ test_common_copy_object() {
|
||||
assert_success
|
||||
|
||||
if [[ $1 == 's3' ]]; then
|
||||
copy_object "$1" "$test_file_folder/$object_name" "$BUCKET_ONE_NAME" "$object_name" || fail "failed to copy object to bucket one"
|
||||
copy_object "$1" "$TEST_FILE_FOLDER/$object_name" "$BUCKET_ONE_NAME" "$object_name" || fail "failed to copy object to bucket one"
|
||||
else
|
||||
put_object "$1" "$test_file_folder/$object_name" "$BUCKET_ONE_NAME" "$object_name" || fail "failed to put object to bucket one"
|
||||
put_object "$1" "$TEST_FILE_FOLDER/$object_name" "$BUCKET_ONE_NAME" "$object_name" || fail "failed to put object to bucket one"
|
||||
fi
|
||||
if [[ $1 == 's3' ]]; then
|
||||
copy_object "$1" "s3://$BUCKET_ONE_NAME/$object_name" "$BUCKET_TWO_NAME" "$object_name" || fail "object not copied to bucket two"
|
||||
@@ -151,7 +151,7 @@ test_common_put_object() {
|
||||
assert_success
|
||||
fi
|
||||
|
||||
run put_object "$1" "$test_file_folder/$2" "$BUCKET_ONE_NAME" "$2"
|
||||
run put_object "$1" "$TEST_FILE_FOLDER/$2" "$BUCKET_ONE_NAME" "$2"
|
||||
assert_success
|
||||
|
||||
if [ "$1" == 's3' ]; then
|
||||
@@ -185,9 +185,9 @@ test_common_put_get_object() {
|
||||
assert_success
|
||||
|
||||
if [[ $1 == 's3' ]]; then
|
||||
copy_object "$1" "$test_file_folder/$object_name" "$BUCKET_ONE_NAME" "$object_name" || fail "failed to add object to bucket"
|
||||
copy_object "$1" "$TEST_FILE_FOLDER/$object_name" "$BUCKET_ONE_NAME" "$object_name" || fail "failed to add object to bucket"
|
||||
else
|
||||
put_object "$1" "$test_file_folder/$object_name" "$BUCKET_ONE_NAME" "$object_name" || fail "failed to add object to bucket"
|
||||
put_object "$1" "$TEST_FILE_FOLDER/$object_name" "$BUCKET_ONE_NAME" "$object_name" || fail "failed to add object to bucket"
|
||||
fi
|
||||
object_exists "$1" "$BUCKET_ONE_NAME" "$object_name" || fail "object not added to bucket"
|
||||
|
||||
@@ -268,15 +268,15 @@ test_common_list_objects() {
|
||||
run create_test_files $object_one $object_two
|
||||
assert_success
|
||||
|
||||
echo "test data" > "$test_file_folder"/"$object_one"
|
||||
echo "test data 2" > "$test_file_folder"/"$object_two"
|
||||
echo "test data" > "$TEST_FILE_FOLDER"/"$object_one"
|
||||
echo "test data 2" > "$TEST_FILE_FOLDER"/"$object_two"
|
||||
|
||||
run setup_bucket "$1" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
put_object "$1" "$test_file_folder"/$object_one "$BUCKET_ONE_NAME" "$object_one" || local result_two=$?
|
||||
put_object "$1" "$TEST_FILE_FOLDER"/$object_one "$BUCKET_ONE_NAME" "$object_one" || local result_two=$?
|
||||
[[ result_two -eq 0 ]] || fail "Error adding object one"
|
||||
put_object "$1" "$test_file_folder"/$object_two "$BUCKET_ONE_NAME" "$object_two" || local result_three=$?
|
||||
put_object "$1" "$TEST_FILE_FOLDER"/$object_two "$BUCKET_ONE_NAME" "$object_two" || local result_three=$?
|
||||
[[ result_three -eq 0 ]] || fail "Error adding object two"
|
||||
|
||||
list_objects "$1" "$BUCKET_ONE_NAME"
|
||||
@@ -355,7 +355,7 @@ test_common_set_get_object_tags() {
|
||||
run setup_bucket "$1" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
put_object "$1" "$test_file_folder"/"$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" || fail "Failed to add object to bucket '$BUCKET_ONE_NAME'"
|
||||
put_object "$1" "$TEST_FILE_FOLDER"/"$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" || fail "Failed to add object to bucket '$BUCKET_ONE_NAME'"
|
||||
|
||||
get_object_tagging "$1" "$BUCKET_ONE_NAME" $bucket_file || fail "Error getting object tags"
|
||||
if [[ $1 == 'aws' ]]; then
|
||||
@@ -393,25 +393,25 @@ test_common_presigned_url_utf8_chars() {
|
||||
|
||||
run create_test_file "$bucket_file"
|
||||
assert_success
|
||||
dd if=/dev/urandom of="$test_file_folder/$bucket_file" bs=5M count=1 || fail "error creating test file"
|
||||
dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1 || fail "error creating test file"
|
||||
|
||||
run setup_bucket "$1" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
put_object "$1" "$test_file_folder"/"$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" || put_result=$?
|
||||
put_object "$1" "$TEST_FILE_FOLDER"/"$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" || put_result=$?
|
||||
[[ $put_result -eq 0 ]] || fail "Failed to add object $bucket_file"
|
||||
|
||||
create_presigned_url "$1" "$BUCKET_ONE_NAME" "$bucket_file" || presigned_result=$?
|
||||
[[ $presigned_result -eq 0 ]] || fail "presigned url creation failure"
|
||||
|
||||
error=$(curl -k -v "$presigned_url" -o "$test_file_folder"/"$bucket_file_copy") || curl_result=$?
|
||||
error=$(curl -k -v "$presigned_url" -o "$TEST_FILE_FOLDER"/"$bucket_file_copy") || curl_result=$?
|
||||
if [[ $curl_result -ne 0 ]]; then
|
||||
fail "error downloading file with curl: $error"
|
||||
fi
|
||||
compare_files "$test_file_folder"/"$bucket_file" "$test_file_folder"/"$bucket_file_copy" || compare_result=$?
|
||||
compare_files "$TEST_FILE_FOLDER"/"$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file_copy" || compare_result=$?
|
||||
if [[ $compare_result -ne 0 ]]; then
|
||||
echo "file one: $(cat "$test_file_folder"/"$bucket_file")"
|
||||
echo "file two: $(cat "$test_file_folder"/"$bucket_file_copy")"
|
||||
echo "file one: $(cat "$TEST_FILE_FOLDER"/"$bucket_file")"
|
||||
echo "file two: $(cat "$TEST_FILE_FOLDER"/"$bucket_file_copy")"
|
||||
fail "files don't match"
|
||||
fi
|
||||
|
||||
@@ -430,7 +430,7 @@ test_common_list_objects_file_count() {
|
||||
run setup_bucket "$1" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
put_object_multiple "$1" "$test_file_folder/file_*" "$BUCKET_ONE_NAME" || local put_result=$?
|
||||
put_object_multiple "$1" "$TEST_FILE_FOLDER/file_*" "$BUCKET_ONE_NAME" || local put_result=$?
|
||||
[[ $put_result -eq 0 ]] || fail "Failed to copy files to bucket"
|
||||
list_objects "$1" "$BUCKET_ONE_NAME"
|
||||
if [[ $LOG_LEVEL -ge 5 ]]; then
|
||||
@@ -454,7 +454,7 @@ test_common_delete_object_tagging() {
|
||||
run setup_bucket "$1" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
put_object "$1" "$test_file_folder"/"$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" || fail "Failed to add object to bucket"
|
||||
put_object "$1" "$TEST_FILE_FOLDER"/"$bucket_file" "$BUCKET_ONE_NAME" "$bucket_file" || fail "Failed to add object to bucket"
|
||||
|
||||
put_object_tagging "$1" "$BUCKET_ONE_NAME" "$bucket_file" "$tag_key" "$tag_value" || fail "failed to add tags to object"
|
||||
|
||||
@@ -563,7 +563,7 @@ test_common_put_bucket_acl() {
|
||||
grantee="{\"ID\": \"$username\", \"Type\": \"CanonicalUser\"}"
|
||||
fi
|
||||
|
||||
cat <<EOF > "$test_file_folder"/"$acl_file"
|
||||
cat <<EOF > "$TEST_FILE_FOLDER"/"$acl_file"
|
||||
{
|
||||
"Grants": [
|
||||
{
|
||||
@@ -578,7 +578,7 @@ cat <<EOF > "$test_file_folder"/"$acl_file"
|
||||
EOF
|
||||
|
||||
log 6 "before 1st put acl"
|
||||
put_bucket_acl_s3api "$BUCKET_ONE_NAME" "$test_file_folder"/"$acl_file" || fail "error putting first acl"
|
||||
put_bucket_acl_s3api "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER"/"$acl_file" || fail "error putting first acl"
|
||||
get_bucket_acl "$1" "$BUCKET_ONE_NAME" || fail "error retrieving second ACL"
|
||||
|
||||
log 5 "Acls after 1st put: $acl"
|
||||
@@ -586,7 +586,7 @@ EOF
|
||||
permission=$(echo "$public_grants" | jq -r '.Permission' 2>&1) || fail "error getting permission: $permission"
|
||||
[[ $permission == "READ" ]] || fail "incorrect permission ($permission)"
|
||||
|
||||
cat <<EOF > "$test_file_folder"/"$acl_file"
|
||||
cat <<EOF > "$TEST_FILE_FOLDER"/"$acl_file"
|
||||
{
|
||||
"Grants": [
|
||||
{
|
||||
@@ -603,7 +603,7 @@ cat <<EOF > "$test_file_folder"/"$acl_file"
|
||||
}
|
||||
EOF
|
||||
|
||||
put_bucket_acl_s3api "$BUCKET_ONE_NAME" "$test_file_folder"/"$acl_file" || fail "error putting second acl"
|
||||
put_bucket_acl_s3api "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER"/"$acl_file" || fail "error putting second acl"
|
||||
get_bucket_acl "$1" "$BUCKET_ONE_NAME" || fail "error retrieving second ACL"
|
||||
|
||||
log 5 "Acls after 2nd put: $acl"
|
||||
@@ -634,7 +634,7 @@ test_common_get_put_delete_bucket_policy() {
|
||||
action="s3:GetObject"
|
||||
resource="arn:aws:s3:::$BUCKET_ONE_NAME/*"
|
||||
|
||||
cat <<EOF > "$test_file_folder"/$policy_file
|
||||
cat <<EOF > "$TEST_FILE_FOLDER"/$policy_file
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
@@ -647,14 +647,14 @@ test_common_get_put_delete_bucket_policy() {
|
||||
]
|
||||
}
|
||||
EOF
|
||||
log 5 "POLICY: $(cat "$test_file_folder/$policy_file")"
|
||||
log 5 "POLICY: $(cat "$TEST_FILE_FOLDER/$policy_file")"
|
||||
|
||||
run setup_bucket "$1" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
check_for_empty_policy "$1" "$BUCKET_ONE_NAME" || fail "policy not empty"
|
||||
|
||||
put_bucket_policy "$1" "$BUCKET_ONE_NAME" "$test_file_folder"/"$policy_file" || fail "error putting bucket policy"
|
||||
put_bucket_policy "$1" "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER"/"$policy_file" || fail "error putting bucket policy"
|
||||
|
||||
get_bucket_policy "$1" "$BUCKET_ONE_NAME" || fail "error getting bucket policy after setting"
|
||||
|
||||
|
||||
@@ -51,6 +51,9 @@ export RUN_MC=true
|
||||
|
||||
# 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 "mc"
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,9 @@ export RUN_USERS=true
|
||||
|
||||
# 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"
|
||||
}
|
||||
|
||||
@@ -214,7 +217,7 @@ export RUN_USERS=true
|
||||
run setup_bucket "aws" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
create_and_list_multipart_uploads "$BUCKET_ONE_NAME" "$test_file_folder"/"$bucket_file_one" "$test_file_folder"/"$bucket_file_two" || fail "failed to list multipart uploads"
|
||||
create_and_list_multipart_uploads "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER"/"$bucket_file_one" "$TEST_FILE_FOLDER"/"$bucket_file_two" || fail "failed to list multipart uploads"
|
||||
|
||||
local key_one
|
||||
local key_two
|
||||
@@ -225,8 +228,8 @@ export RUN_USERS=true
|
||||
key_two=$(echo "$raw_uploads" | jq -r '.Uploads[1].Key' 2>&1) || fail "error getting key two: $key_two"
|
||||
key_one=${key_one//\"/}
|
||||
key_two=${key_two//\"/}
|
||||
[[ "$test_file_folder/$bucket_file_one" == *"$key_one" ]] || fail "Key mismatch ($test_file_folder/$bucket_file_one, $key_one)"
|
||||
[[ "$test_file_folder/$bucket_file_two" == *"$key_two" ]] || fail "Key mismatch ($test_file_folder/$bucket_file_two, $key_two)"
|
||||
[[ "$TEST_FILE_FOLDER/$bucket_file_one" == *"$key_one" ]] || fail "Key mismatch ($TEST_FILE_FOLDER/$bucket_file_one, $key_one)"
|
||||
[[ "$TEST_FILE_FOLDER/$bucket_file_two" == *"$key_two" ]] || fail "Key mismatch ($TEST_FILE_FOLDER/$bucket_file_two, $key_two)"
|
||||
|
||||
delete_bucket_or_contents "aws" "$BUCKET_ONE_NAME"
|
||||
delete_test_files "$bucket_file_one" "$bucket_file_two"
|
||||
@@ -237,15 +240,15 @@ export RUN_USERS=true
|
||||
|
||||
run create_test_file "$bucket_file"
|
||||
assert_success
|
||||
dd if=/dev/urandom of="$test_file_folder/$bucket_file" bs=5M count=1 || fail "error adding data to test file"
|
||||
dd if=/dev/urandom of="$TEST_FILE_FOLDER/$bucket_file" bs=5M count=1 || fail "error adding data to test file"
|
||||
|
||||
run setup_bucket "aws" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
multipart_upload_from_bucket "$BUCKET_ONE_NAME" "$bucket_file" "$test_file_folder"/"$bucket_file" 4 || fail "error performing multipart upload"
|
||||
multipart_upload_from_bucket "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4 || fail "error performing multipart upload"
|
||||
|
||||
get_object "s3api" "$BUCKET_ONE_NAME" "$bucket_file-copy" "$test_file_folder/$bucket_file-copy" || fail "error getting object"
|
||||
compare_files "$test_file_folder"/$bucket_file-copy "$test_file_folder"/$bucket_file || fail "data doesn't match"
|
||||
get_object "s3api" "$BUCKET_ONE_NAME" "$bucket_file-copy" "$TEST_FILE_FOLDER/$bucket_file-copy" || fail "error getting object"
|
||||
compare_files "$TEST_FILE_FOLDER"/$bucket_file-copy "$TEST_FILE_FOLDER"/$bucket_file || fail "data doesn't match"
|
||||
|
||||
delete_bucket_or_contents "aws" "$BUCKET_ONE_NAME"
|
||||
delete_test_files $bucket_file
|
||||
@@ -259,7 +262,7 @@ export RUN_USERS=true
|
||||
run setup_bucket "aws" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
multipart_upload_from_bucket_range "$BUCKET_ONE_NAME" "$bucket_file" "$test_file_folder"/"$bucket_file" 4 "bytes=0-1000000000" || local upload_result=$?
|
||||
multipart_upload_from_bucket_range "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4 "bytes=0-1000000000" || local upload_result=$?
|
||||
[[ $upload_result -eq 1 ]] || fail "multipart upload with overly large range should have failed"
|
||||
log 5 "error: $upload_part_copy_error"
|
||||
[[ $upload_part_copy_error == *"Range specified is not valid"* ]] || [[ $upload_part_copy_error == *"InvalidRange"* ]] || fail "unexpected error: $upload_part_copy_error"
|
||||
@@ -277,13 +280,13 @@ export RUN_USERS=true
|
||||
assert_success
|
||||
|
||||
range_max=$((5*1024*1024-1))
|
||||
multipart_upload_from_bucket_range "$BUCKET_ONE_NAME" "$bucket_file" "$test_file_folder"/"$bucket_file" 4 "bytes=0-$range_max" || fail "upload failure"
|
||||
multipart_upload_from_bucket_range "$BUCKET_ONE_NAME" "$bucket_file" "$TEST_FILE_FOLDER"/"$bucket_file" 4 "bytes=0-$range_max" || fail "upload failure"
|
||||
|
||||
get_object "s3api" "$BUCKET_ONE_NAME" "$bucket_file-copy" "$test_file_folder/$bucket_file-copy" || fail "error retrieving object after upload"
|
||||
get_object "s3api" "$BUCKET_ONE_NAME" "$bucket_file-copy" "$TEST_FILE_FOLDER/$bucket_file-copy" || fail "error retrieving object after upload"
|
||||
if [[ $(uname) == 'Darwin' ]]; then
|
||||
object_size=$(stat -f%z "$test_file_folder/$bucket_file-copy")
|
||||
object_size=$(stat -f%z "$TEST_FILE_FOLDER/$bucket_file-copy")
|
||||
else
|
||||
object_size=$(stat --format=%s "$test_file_folder/$bucket_file-copy")
|
||||
object_size=$(stat --format=%s "$TEST_FILE_FOLDER/$bucket_file-copy")
|
||||
fi
|
||||
[[ object_size -eq $((range_max*4+4)) ]] || fail "object size mismatch ($object_size, $((range_max*4+4)))"
|
||||
|
||||
@@ -308,7 +311,7 @@ export RUN_USERS=true
|
||||
run setup_bucket "aws" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
put_object "aws" "$test_file_folder/$folder_name/$object_name" "$BUCKET_ONE_NAME" "$folder_name/$object_name" || fail "failed to add object to bucket"
|
||||
put_object "aws" "$TEST_FILE_FOLDER/$folder_name/$object_name" "$BUCKET_ONE_NAME" "$folder_name/$object_name" || fail "failed to add object to bucket"
|
||||
|
||||
list_objects_s3api_v1 "$BUCKET_ONE_NAME" "/"
|
||||
prefix=$(echo "${objects[@]}" | jq -r ".CommonPrefixes[0].Prefix" 2>&1) || fail "error getting object prefix from object list: $prefix"
|
||||
@@ -323,58 +326,100 @@ export RUN_USERS=true
|
||||
}
|
||||
|
||||
@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
|
||||
}
|
||||
|
||||
@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_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_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_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_deny" {
|
||||
if [[ -n $SKIP_POLICY ]]; then
|
||||
skip "will not test policy actions with SKIP_POLICY set"
|
||||
fi
|
||||
test_s3api_policy_deny
|
||||
}
|
||||
|
||||
@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_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_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_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_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_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_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
|
||||
}
|
||||
|
||||
@@ -398,7 +443,7 @@ export RUN_USERS=true
|
||||
# setup_bucket "aws" "$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 "aws" "$TEST_FILE_FOLDER"/"$file_name" "$BUCKET_ONE_NAME"/"$file_name" || local put_object=$?
|
||||
# [[ $put_object -eq 0 ]] || fail "Failed to add object to bucket"
|
||||
#}
|
||||
|
||||
@@ -438,7 +483,7 @@ export RUN_USERS=true
|
||||
run setup_bucket "aws" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
object="$test_file_folder"/"$object_one"
|
||||
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"
|
||||
|
||||
@@ -453,26 +498,44 @@ export RUN_USERS=true
|
||||
}
|
||||
|
||||
@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_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_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_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_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
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,10 @@ export RUN_USERS=true
|
||||
|
||||
# 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 "s3cmd"
|
||||
}
|
||||
|
||||
|
||||
@@ -56,12 +56,12 @@ export RUN_USERS=true
|
||||
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
if get_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$test_file_folder/$test_file-copy" "$username" "$password"; then
|
||||
if get_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" "$username" "$password"; then
|
||||
fail "able to get object despite not being bucket owner"
|
||||
fi
|
||||
change_bucket_owner "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "$BUCKET_ONE_NAME" "$username" || fail "error changing bucket ownership"
|
||||
put_object "s3api" "$test_file_folder/$test_file" "$BUCKET_ONE_NAME" "$test_file" || fail "failed to add object to bucket"
|
||||
get_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$test_file_folder/$test_file-copy" "$username" "$password" || fail "error getting object"
|
||||
put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" || fail "failed to add object to bucket"
|
||||
get_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" "$username" "$password" || fail "error getting object"
|
||||
}
|
||||
|
||||
@test "test_userplus_get_object" {
|
||||
@@ -77,12 +77,12 @@ export RUN_USERS=true
|
||||
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
if get_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$test_file_folder/$test_file-copy" "$username" "$password"; then
|
||||
if get_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" "$username" "$password"; then
|
||||
fail "able to get object despite not being bucket owner"
|
||||
fi
|
||||
change_bucket_owner "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "$BUCKET_ONE_NAME" "$username" || fail "error changing bucket ownership"
|
||||
put_object "s3api" "$test_file_folder/$test_file" "$BUCKET_ONE_NAME" "$test_file" || fail "failed to add object to bucket"
|
||||
get_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$test_file_folder/$test_file-copy" "$username" "$password" || fail "error getting object"
|
||||
put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" || fail "failed to add object to bucket"
|
||||
get_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" "$username" "$password" || fail "error getting object"
|
||||
}
|
||||
|
||||
@test "test_user_delete_object" {
|
||||
@@ -98,11 +98,11 @@ export RUN_USERS=true
|
||||
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
if get_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$test_file_folder/$test_file-copy" "$username" "$password"; then
|
||||
if get_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" "$username" "$password"; then
|
||||
fail "able to get object despite not being bucket owner"
|
||||
fi
|
||||
change_bucket_owner "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "$BUCKET_ONE_NAME" "$username" || fail "error changing bucket ownership"
|
||||
put_object "s3api" "$test_file_folder/$test_file" "$BUCKET_ONE_NAME" "$test_file" || fail "failed to add object to bucket"
|
||||
put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" || fail "failed to add object to bucket"
|
||||
delete_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$username" "$password" || fail "error deleting object"
|
||||
}
|
||||
|
||||
@@ -119,11 +119,11 @@ export RUN_USERS=true
|
||||
run setup_bucket "s3api" "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
put_object_with_user "s3api" "$test_file_folder/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$username" "$password" || fail "failed to add object to bucket"
|
||||
get_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$test_file_folder/$test_file-copy" "$username" "$password" || fail "error getting object"
|
||||
compare_files "$test_file_folder/$test_file" "$test_file_folder/$test_file-copy" || fail "files don't match"
|
||||
put_object_with_user "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$username" "$password" || fail "failed to add object to bucket"
|
||||
get_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" "$username" "$password" || fail "error getting object"
|
||||
compare_files "$TEST_FILE_FOLDER/$test_file" "$TEST_FILE_FOLDER/$test_file-copy" || fail "files don't match"
|
||||
delete_object_with_user "s3api" "$BUCKET_ONE_NAME" "$test_file" "$username" "$password" || fail "error deleting object"
|
||||
if get_object "s3api" "$BUCKET_ONE_NAME" "$test_file" "$test_file_folder/$test_file-copy"; then
|
||||
if get_object "s3api" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"; then
|
||||
fail "file not successfully deleted"
|
||||
fi
|
||||
# shellcheck disable=SC2154
|
||||
|
||||
@@ -89,14 +89,13 @@ add_governance_bypass_policy() {
|
||||
log 2 "'add governance bypass policy' command requires bucket name"
|
||||
return 1
|
||||
fi
|
||||
test_file_folder=$PWD
|
||||
if [[ -z "$GITHUB_ACTIONS" ]]; then
|
||||
if ! create_test_file_folder; then
|
||||
log 2 "error creating test file folder"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
cat <<EOF > "$test_file_folder/policy-bypass-governance.txt"
|
||||
cat <<EOF > "$TEST_FILE_FOLDER/policy-bypass-governance.txt"
|
||||
{
|
||||
"Version": "dummy",
|
||||
"Statement": [
|
||||
@@ -109,7 +108,7 @@ add_governance_bypass_policy() {
|
||||
]
|
||||
}
|
||||
EOF
|
||||
if ! put_bucket_policy "s3api" "$1" "$test_file_folder/policy-bypass-governance.txt"; then
|
||||
if ! put_bucket_policy "s3api" "$1" "$TEST_FILE_FOLDER/policy-bypass-governance.txt"; then
|
||||
log 2 "error putting governance bypass policy"
|
||||
return 1
|
||||
fi
|
||||
@@ -346,6 +345,8 @@ delete_bucket_contents() {
|
||||
delete_bucket_recursive "s3cmd" "$1"
|
||||
elif [[ $1 == "mc" ]]; then
|
||||
delete_bucket_recursive "mc" "$1"
|
||||
elif [[ $1 == "s3" ]]; then
|
||||
delete_bucket_recursive "s3" "$1"
|
||||
else
|
||||
log 2 "unrecognized client: '$1'"
|
||||
return 1
|
||||
|
||||
@@ -25,7 +25,6 @@ create_test_files() {
|
||||
log 2 "'create_test_files' requires file names"
|
||||
return 1
|
||||
fi
|
||||
#test_file_folder=$PWD
|
||||
if [[ -z "$GITHUB_ACTIONS" ]]; then
|
||||
if ! create_test_file_folder; then
|
||||
log 2 "error creating test file folder"
|
||||
@@ -38,7 +37,6 @@ create_test_files() {
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
#export test_file_folder
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -48,6 +46,12 @@ create_test_file() {
|
||||
log 2 "'create_test_file' requires filename, size (optional)"
|
||||
return 1
|
||||
fi
|
||||
if [[ -z "$GITHUB_ACTIONS" ]]; then
|
||||
if ! create_test_file_folder; then
|
||||
log 2 "error creating test file folder"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [[ -e "$TEST_FILE_FOLDER/$1" ]]; then
|
||||
if ! error=$(rm "$TEST_FILE_FOLDER/$1" 2>&1); then
|
||||
log 2 "error removing existing file: $error"
|
||||
@@ -80,7 +84,6 @@ create_test_folder() {
|
||||
log 2 "'create_test_folder' requires folder names"
|
||||
return 1
|
||||
fi
|
||||
#test_file_folder=$PWD
|
||||
if [[ -z "$GITHUB_ACTIONS" ]]; then
|
||||
if ! create_test_file_folder; then
|
||||
log 2 "error creating test file folder"
|
||||
@@ -170,7 +173,6 @@ create_test_file_folder() {
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
export test_file_folder=$TEST_FILE_FOLDER
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -183,8 +185,6 @@ create_large_file() {
|
||||
log 2 "'create_large_file' requires file name"
|
||||
return 1
|
||||
fi
|
||||
|
||||
#test_file_folder=$PWD/versity-gwtest-files
|
||||
if [[ -z "$GITHUB_ACTIONS" ]]; then
|
||||
if ! create_test_file_folder; then
|
||||
log 2 "error creating test file folder"
|
||||
@@ -207,7 +207,6 @@ create_test_file_count() {
|
||||
log 2 "'create_test_file_count' requires number of files"
|
||||
return 1
|
||||
fi
|
||||
#test_file_folder=$PWD
|
||||
if [[ -z "$GITHUB_ACTIONS" ]]; then
|
||||
if ! create_test_file_folder; then
|
||||
log 2 "error creating test file folder"
|
||||
|
||||
@@ -86,13 +86,13 @@ put_user_policy_userplus() {
|
||||
log 2 "'put user policy userplus' function requires username"
|
||||
return 1
|
||||
fi
|
||||
if [[ -z "$test_file_folder" ]] && [[ -z "$GITHUB_ACTIONS" ]] && ! create_test_file_folder; then
|
||||
if [[ -z "$TEST_FILE_FOLDER" ]] && [[ -z "$GITHUB_ACTIONS" ]] && ! create_test_file_folder; then
|
||||
log 2 "unable to create test file folder"
|
||||
return 1
|
||||
fi
|
||||
#"Resource": "arn:aws:s3:::${aws:username}-*"
|
||||
|
||||
cat <<EOF > "$test_file_folder"/user_policy_file
|
||||
cat <<EOF > "$TEST_FILE_FOLDER"/user_policy_file
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
@@ -118,7 +118,7 @@ cat <<EOF > "$test_file_folder"/user_policy_file
|
||||
]
|
||||
}
|
||||
EOF
|
||||
if ! error=$(aws iam put-user-policy --user-name "$1" --policy-name "UserPolicy" --policy-document "file://$test_file_folder/user_policy_file" 2>&1); then
|
||||
if ! error=$(aws iam put-user-policy --user-name "$1" --policy-name "UserPolicy" --policy-document "file://$TEST_FILE_FOLDER/user_policy_file" 2>&1); then
|
||||
log 2 "error putting user policy: $error"
|
||||
return 1
|
||||
fi
|
||||
@@ -131,7 +131,7 @@ put_user_policy() {
|
||||
log 2 "attaching user policy requires user ID, role, bucket name"
|
||||
return 1
|
||||
fi
|
||||
if [[ -z "$test_file_folder" ]] && [[ -z "$GITHUB_ACTIONS" ]] && ! create_test_file_folder; then
|
||||
if [[ -z "$TEST_FILE_FOLDER" ]] && [[ -z "$GITHUB_ACTIONS" ]] && ! create_test_file_folder; then
|
||||
log 2 "unable to create test file folder"
|
||||
return 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user