Skip to content

Commit

Permalink
test: bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lrm25 committed Sep 18, 2024
1 parent 68d3bba commit d7211ff
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion tests/commands/get_object_tagging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ get_object_tagging() {
return 1
fi
local result
if [[ $1 == 'aws' ]]; then
if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then
tags=$(aws --no-verify-ssl s3api get-object-tagging --bucket "$2" --key "$3" 2>&1) || result=$?
elif [[ $1 == 'mc' ]]; then
tags=$(mc --insecure tag list "$MC_ALIAS"/"$2"/"$3" 2>&1) || result=$?
Expand Down
4 changes: 2 additions & 2 deletions tests/test_aws_root_inner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ test_create_multipart_upload_properties_aws_root() {
"$expected_hold_status" \
"$expected_retention_mode" \
"$later" \
"$expected_tag_key=$expected_tag_val" || fail "error performing multipart upload"
"$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 get_and_check_bucket_tags "$BUCKET_ONE_NAME" "$expected_tag_key" "$expected_tag_val"
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"
Expand Down
10 changes: 6 additions & 4 deletions tests/test_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@

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/commands/copy_object.sh
source ./tests/commands/delete_bucket_tagging.sh
source ./tests/commands/delete_object_tagging.sh
Expand Down Expand Up @@ -238,9 +242,7 @@ test_common_list_objects() {
}

test_common_set_get_delete_bucket_tags() {
if [[ $# -ne 1 ]]; then
fail "set/get bucket tags test requires command type"
fi
assert [ $# -eq 1 ]

local key="test_key"
local value="test_value"
Expand All @@ -254,7 +256,7 @@ test_common_set_get_delete_bucket_tags() {
run put_bucket_tagging "$1" "$BUCKET_ONE_NAME" $key $value
assert_success

run get_and_check_bucket_tags "$1" "$BUCKET_ONE_NAME" "$key" "$value"
run get_and_check_bucket_tags "$BUCKET_ONE_NAME" "$key" "$value"
assert_success

run delete_bucket_tagging "$1" "$BUCKET_ONE_NAME"
Expand Down
2 changes: 2 additions & 0 deletions tests/util_presigned_url.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

source ./tests/commands/create_presigned_url.sh

create_check_presigned_url() {
if [ $# -ne 4 ]; then
log 2 "'create_check_presigned_url' requires client, bucket, key, save location"
Expand Down
22 changes: 11 additions & 11 deletions tests/util_tags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ get_and_check_bucket_tags() {
}

verify_no_bucket_tags() {
if [ $# -ne 1 ]; then
if [ $# -ne 2 ]; then
log 2 "'verify_no_bucket_tags' requires bucket name"
return 1
fi
if ! get_bucket_tagging "$1"; then
if ! get_bucket_tagging "$1" "$2"; then
log 2 "error retrieving bucket tagging"
return 1
fi
Expand Down Expand Up @@ -116,7 +116,7 @@ check_verify_object_tags() {
log 2 "error getting object tags"
return 1
fi
if [[ $1 == 'aws' ]]; then
if [[ $1 == 'aws' ]] || [[ $1 == 's3api' ]]; then
if ! tag_set_key=$(echo "$tags" | jq -r '.TagSet[0].Key' 2>&1); then
log 2 "error retrieving tag key: $tag_set_key"
return 1
Expand All @@ -125,22 +125,22 @@ check_verify_object_tags() {
log 2 "error retrieving tag value: $tag_set_value"
return 1
fi
if [[ $tag_set_key != "$key" ]]; then
log 2 "key mismatch ($tag_set_key, $key)"
if [[ $tag_set_key != "$4" ]]; then
log 2 "key mismatch ($tag_set_key, $4)"
return 1
fi
if [[ $tag_set_value != "$value" ]]; then
log 2 "value mismatch ($tag_set_value, $value)"
if [[ $tag_set_value != "$5" ]]; then
log 2 "value mismatch ($tag_set_value, $5)"
return 1
fi
else
read -r tag_set_key tag_set_value <<< "$(echo "$tags" | awk 'NR==2 {print $1, $3}')"
if [[ $tag_set_key != "$key" ]]; then
log 2 "Key mismatch ($tag_set_key, $key)"
if [[ $tag_set_key != "$4" ]]; then
log 2 "Key mismatch ($tag_set_key, $4)"
return 1
fi
if [[ $tag_set_value != "$value" ]]; then
log 2 "Value mismatch ($tag_set_value, $value)"
if [[ $tag_set_value != "$5" ]]; then
log 2 "Value mismatch ($tag_set_value, $5)"
return 1
fi
fi
Expand Down

0 comments on commit d7211ff

Please sign in to comment.