mirror of
https://github.com/versity/versitygw.git
synced 2026-04-22 05:30:29 +00:00
test: ListObjects encoding-type tests
This commit is contained in:
@@ -26,7 +26,6 @@ create_bucket() {
|
||||
fi
|
||||
|
||||
local exit_code=0
|
||||
local error
|
||||
if [[ $1 == 's3' ]]; then
|
||||
error=$(send_command aws --no-verify-ssl s3 mb s3://"$2" 2>&1) || exit_code=$?
|
||||
elif [[ $1 == 's3api' ]]; then
|
||||
|
||||
@@ -304,14 +304,10 @@ send_curl_command_create_bucket_expect_error_callback() {
|
||||
log 2 "error getting bucket name from '$BUCKET_ONE_NAME': $bucket_name"
|
||||
return 1
|
||||
fi
|
||||
if ! send_rest_go_command_expect_error "$1" "$2" "$3" "-bucketName" "$bucket_name" "-commandType" "createBucket" "${@:5}"; then
|
||||
if ! send_rest_go_command_expect_error_callback "$1" "$2" "$3" "$4" "-bucketName" "$bucket_name" "-commandType" "createBucket" "${@:5}"; then
|
||||
log 2 "error sending rest go command"
|
||||
return 1
|
||||
fi
|
||||
if [ "$4" != "" ] && ! "$4" "$TEST_FILE_FOLDER/result.txt"; then
|
||||
log 2 "callback error"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@@ -163,3 +163,29 @@ list_objects_with_prefix_and_delimiter_check_results() {
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
list_objects_check_key() {
|
||||
if ! check_param_count_v2 "bucket name, key, encoding type" 3 $#; then
|
||||
return 1
|
||||
fi
|
||||
query=()
|
||||
if [ "$3" != "" ]; then
|
||||
query=("-query" "encoding-type=$3")
|
||||
fi
|
||||
if ! send_rest_go_command_callback "200" "check_if_key_exists" "-bucketName" "$1" "${query[@]}" "--" "$2"; then
|
||||
log 2 "error sending rest command"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_if_key_exists() {
|
||||
if ! check_param_count_v2 "data file, key" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! check_if_element_exists "$1" "$2" "ListBucketResult" "Contents" "Key"; then
|
||||
log 2 "error checking if CommonPrefix '$2' exists"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ send_via_openssl() {
|
||||
if ! record_openssl_command "$1"; then
|
||||
log 3 "error recording openssl command"
|
||||
fi
|
||||
log 5 "sending openssl command file '$1'"
|
||||
if ! result=$(openssl s_client -connect "$host" -ign_eof < "$1" 2>&1); then
|
||||
log 2 "error sending openssl command: $result"
|
||||
return 1
|
||||
|
||||
@@ -174,3 +174,44 @@ source ./tests/drivers/create_bucket/create_bucket_rest.sh
|
||||
run list_objects_with_prefix_and_delimiter_check_results "$bucket_name" "$prefix" "/" "a-b/" "--" "a-b-1.txt" "a-b-2.txt"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - ListObjects - invalid encoding" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1984"
|
||||
fi
|
||||
run setup_bucket_and_file_v3 "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
read -r bucket_name file_name <<< "$output"
|
||||
|
||||
run send_rest_go_command "200" "-method" PUT "-bucketName" "$bucket_name" "-payloadFile" "$TEST_FILE_FOLDER/$file_name" "-objectKey" "$file_name"
|
||||
assert_success
|
||||
|
||||
local bad_encoding="jdfkllaj"
|
||||
run send_rest_go_command_expect_error_with_arg_name_value "400" "InvalidArgument" "Invalid Encoding Method specified in Request" \
|
||||
"encoding-type" "$bad_encoding" "-bucketName" "$bucket_name" "-query" "encoding-type=$bad_encoding"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - ListObjects - encoding success" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1985"
|
||||
fi
|
||||
run setup_bucket_v3 "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name=$output
|
||||
|
||||
file_name="a+ b.txt"
|
||||
expected_encoding="a%2B+b.txt"
|
||||
run create_test_file "$file_name"
|
||||
assert_success
|
||||
|
||||
payload_file="$TEST_FILE_FOLDER/$file_name"
|
||||
run send_rest_go_command "200" "-method" "PUT" "-payloadFile" "$payload_file" "-bucketName" "$bucket_name" "-objectKey" "$file_name"
|
||||
assert_success
|
||||
|
||||
run list_objects_check_key "$bucket_name" "$expected_encoding" "url"
|
||||
assert_success
|
||||
|
||||
run list_objects_check_key "$bucket_name" "$file_name" ""
|
||||
assert_success
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user