mirror of
https://github.com/versity/versitygw.git
synced 2025-12-23 05:05:16 +00:00
test: HeadBucket tests, test file reorganization
This commit is contained in:
2
.github/workflows/system.yml
vendored
2
.github/workflows/system.yml
vendored
@@ -29,7 +29,7 @@ jobs:
|
||||
BACKEND: "posix"
|
||||
- set: "REST, posix, non-static, chunked|checksum|versioning|bucket, folder IAM"
|
||||
IAM_TYPE: folder
|
||||
RUN_SET: "rest-chunked,rest-checksum,rest-versioning,rest-bucket"
|
||||
RUN_SET: "rest-chunked,rest-checksum,rest-versioning,rest-bucket,rest-list-buckets,rest-create-bucket,rest-head-bucket"
|
||||
RECREATE_BUCKETS: "true"
|
||||
DELETE_BUCKETS_AFTER_TEST: "true"
|
||||
BACKEND: "posix"
|
||||
|
||||
@@ -55,7 +55,7 @@ head_bucket() {
|
||||
|
||||
head_bucket_rest() {
|
||||
log 6 "head_bucket_rest '$1'"
|
||||
if ! check_param_count "head_bucket_rest" "bucket" 1 $#; then
|
||||
if ! check_param_count_gt "bucket, callback, params (optional)" 1 $#; then
|
||||
return 2
|
||||
fi
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" ./tests/rest_scripts/head_bucket.sh 2>&1); then
|
||||
@@ -74,3 +74,27 @@ head_bucket_rest() {
|
||||
log 2 "unexpected response code '$result' ($(cat "$TEST_FILE_FOLDER/result.txt"))"
|
||||
return 2
|
||||
}
|
||||
|
||||
head_bucket_rest_expect_success() {
|
||||
if ! check_param_count_v2 "bucket name, params" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
env_vars="BUCKET_NAME=$1 $2"
|
||||
if ! send_rest_command_expect_success "$env_vars" "./tests/rest_scripts/head_bucket.sh" "200"; then
|
||||
log 2 "error sending REST command"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
head_bucket_rest_expect_error() {
|
||||
if ! check_param_count_v2 "bucket name, params, response code, message" 4 $#; then
|
||||
return 1
|
||||
fi
|
||||
env_vars="BUCKET_NAME=$1 $2"
|
||||
if ! send_rest_command_expect_header_error "$env_vars" "./tests/rest_scripts/head_bucket.sh" "$3" "$4"; then
|
||||
log 2 "error sending REST command and checking error"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -70,43 +70,83 @@ send_rest_command_expect_error() {
|
||||
return 0
|
||||
}
|
||||
|
||||
send_rest_command_expect_success() {
|
||||
if ! check_param_count_v2 "env vars, script, response code" 3 $#; then
|
||||
check_rest_expected_header_error() {
|
||||
if ! check_param_count_v2 "response code, file, expected response, expected error" 4 $#; then
|
||||
return 1
|
||||
fi
|
||||
status_line=$(head -n 1 "$2")
|
||||
|
||||
# Parse the status code and message
|
||||
status_code=$(echo "$status_line" | awk '{print $2}')
|
||||
status_message=$(echo "$status_line" | cut -d' ' -f3- | tr -d '\r')
|
||||
log 5 "status code: $status_code, status message: $status_message"
|
||||
if [ "$1" != "$3" ]; then
|
||||
log 2 "expected curl response '$3', was '$1"
|
||||
return 1
|
||||
fi
|
||||
if [ "$status_code" != "$3" ]; then
|
||||
log 2 "expected HTTP response '$3', was '$status_code"
|
||||
return 1
|
||||
fi
|
||||
if [ "$status_message" != "$4" ]; then
|
||||
log 2 "expected message '$4', was '$status_message'"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
send_rest_command_expect_header_error() {
|
||||
if ! check_param_count_v2 "env vars, script, response code, message" 4 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! send_rest_command "$1" "$2"; then
|
||||
log 2 "error sending REST command"
|
||||
return 1
|
||||
fi
|
||||
if [ "$result" != "$3" ]; then
|
||||
log 2 "expected '$3', was '$result' ($(cat "$output_file"))"
|
||||
if ! check_rest_expected_header_error "$result" "$output_file" "$3" "$4"; then
|
||||
log 2 "error checking REST error"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
send_rest_command_expect_success_callback() {
|
||||
if ! check_param_count_v2 "env vars, script, response code, callback fn" 4 $#; then
|
||||
return 1
|
||||
fi
|
||||
output_file="$TEST_FILE_FOLDER/output.txt"
|
||||
local env_array=("env" "COMMAND_LOG=$COMMAND_LOG" "OUTPUT_FILE=$output_file")
|
||||
if [ "$1" != "" ]; then
|
||||
IFS=' ' read -r -a env_vars <<< "$1"
|
||||
env_array+=("${env_vars[@]}")
|
||||
fi
|
||||
# shellcheck disable=SC2068
|
||||
if ! result=$(${env_array[@]} "$2" 2>&1); then
|
||||
log 2 "error sending command: $result"
|
||||
return 1
|
||||
fi
|
||||
if [ "$result" != "$3" ]; then
|
||||
log 2 "expected '$3', was '$result' ($(cat "$TEST_FILE_FOLDER/output.txt"))"
|
||||
return 1
|
||||
fi
|
||||
if [ "$4" != "" ] && ! "$4" "$TEST_FILE_FOLDER/output.txt"; then
|
||||
log 2 "callback error"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
send_rest_command_expect_success() {
|
||||
if ! check_param_count_v2 "env vars, script, response code" 3 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! send_rest_command "$1" "$2"; then
|
||||
log 2 "error sending REST command"
|
||||
return 1
|
||||
fi
|
||||
if [ "$result" != "$3" ]; then
|
||||
log 2 "expected '$3', was '$result' ($(cat "$output_file"))"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
send_rest_command_expect_success_callback() {
|
||||
if ! check_param_count_v2 "env vars, script, response code, callback fn" 4 $#; then
|
||||
return 1
|
||||
fi
|
||||
output_file="$TEST_FILE_FOLDER/output.txt"
|
||||
local env_array=("env" "COMMAND_LOG=$COMMAND_LOG" "OUTPUT_FILE=$output_file")
|
||||
if [ "$1" != "" ]; then
|
||||
IFS=' ' read -r -a env_vars <<< "$1"
|
||||
env_array+=("${env_vars[@]}")
|
||||
fi
|
||||
# shellcheck disable=SC2068
|
||||
if ! result=$(${env_array[@]} "$2" 2>&1); then
|
||||
log 2 "error sending command: $result"
|
||||
return 1
|
||||
fi
|
||||
if [ "$result" != "$3" ]; then
|
||||
log 2 "expected '$3', was '$result' ($(cat "$TEST_FILE_FOLDER/output.txt"))"
|
||||
return 1
|
||||
fi
|
||||
if [ "$4" != "" ] && ! "$4" "$TEST_FILE_FOLDER/output.txt"; then
|
||||
log 2 "callback error"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ check_universal_vars() {
|
||||
fi
|
||||
export LOG_LEVEL_INT=$LOG_LEVEL
|
||||
fi
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
if [ -z "$DIRECT_POST_COMMAND_DELAY" ]; then
|
||||
DIRECT_POST_COMMAND_DELAY=0
|
||||
fi
|
||||
|
||||
@@ -142,7 +142,7 @@ check_arg_for_mask() {
|
||||
elif [[ "$arg" == --access_key=* ]]; then
|
||||
masked_args+=("${arg:0:17}****")
|
||||
elif [[ "$arg" == *"Credential="* ]]; then
|
||||
masked_args+=("$(echo "$arg" | sed -E 's/(Credential=[A-Z]{5})[^\/]*/\1*****/g')")
|
||||
masked_args+=("$(echo "$arg" | sed -E 's/(Credential=[A-Z0-9]{5})[^\/]*/\1****/g')")
|
||||
elif [[ "$arg" == *"AWS_ACCESS_KEY_ID="* ]]; then
|
||||
masked_args+=("AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:0:5}****")
|
||||
else
|
||||
|
||||
@@ -20,12 +20,17 @@ source ./tests/rest_scripts/rest.sh
|
||||
|
||||
# shellcheck disable=SC2153
|
||||
bucket_name="$BUCKET_NAME"
|
||||
# shellcheck disable=SC2153
|
||||
expected_owner="$EXPECTED_OWNER"
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
current_date_time=$(date -u +"%Y%m%dT%H%M%SZ")
|
||||
|
||||
canonical_request_data=("HEAD" "/$bucket_name" "" "host:$host")
|
||||
canonical_request_data+=("x-amz-content-sha256:UNSIGNED-PAYLOAD" "x-amz-date:$current_date_time")
|
||||
if [ "$expected_owner" != "" ]; then
|
||||
canonical_request_data+=("x-amz-expected-bucket-owner:$expected_owner")
|
||||
fi
|
||||
if ! build_canonical_request "${canonical_request_data[@]}"; then
|
||||
log_rest 2 "error building request"
|
||||
exit 1
|
||||
@@ -33,7 +38,7 @@ fi
|
||||
# shellcheck disable=SC2119
|
||||
create_canonical_hash_sts_and_signature
|
||||
|
||||
curl_command+=(curl -ksI -w "\"%{http_code}\"" "$AWS_ENDPOINT_URL/$bucket_name"
|
||||
curl_command+=(curl -Iks -w "\"%{http_code}\"" "$AWS_ENDPOINT_URL/$bucket_name"
|
||||
-H "\"Authorization: AWS4-HMAC-SHA256 Credential=$aws_access_key_id/$year_month_day/$aws_region/s3/aws4_request,SignedHeaders=$param_list,Signature=$signature\"")
|
||||
curl_command+=("${header_fields[@]}")
|
||||
curl_command+=(-o "$OUTPUT_FILE")
|
||||
|
||||
28
tests/run.sh
28
tests/run.sh
@@ -34,10 +34,13 @@ show_help() {
|
||||
echo " mc-non-file-count Run non-file count tests with mc utility"
|
||||
echo " mc-file-count Run file count test with mc utility"
|
||||
echo " rest Run tests with rest cli"
|
||||
echo " rest-base Run REST base tasks"
|
||||
echo " rest-base Run REST base tests"
|
||||
echo " rest-acl Run REST ACL tests"
|
||||
echo " rest-chunked Run REST chunked upload tests"
|
||||
echo " rest-checksum Run REST checksum tests"
|
||||
echo " rest-create-bucket Run REST create bucket tests"
|
||||
echo " rest-head-bucket Run REST head bucket tests"
|
||||
echo " rest-list-buckets Run REST list-buckets tests"
|
||||
echo " rest-multipart Run REST multipart tests"
|
||||
echo " rest-versioning Run REST versioning tests"
|
||||
echo " rest-bucket Run REST bucket tests"
|
||||
@@ -49,7 +52,10 @@ handle_param() {
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
s3|s3-file-count|s3-non-file-count|s3api|s3cmd|s3cmd-user|s3cmd-non-user|s3cmd-file-count|mc|mc-non-file-count|mc-file-count|s3api-user|rest|s3api-policy|s3api-bucket|s3api-object|s3api-multipart|rest-base|rest-acl|rest-chunked|rest-checksum|rest-versioning|rest-bucket|rest-multipart)
|
||||
s3|s3-file-count|s3-non-file-count|s3api|s3cmd|s3cmd-user|s3cmd-non-user|\
|
||||
s3cmd-file-count|mc|mc-non-file-count|mc-file-count|s3api-user|rest|s3api-policy|\
|
||||
s3api-bucket|s3api-object|s3api-multipart|rest-base|rest-acl|rest-chunked|rest-checksum|\
|
||||
rest-create-bucket|rest-head-bucket|rest-list-buckets|rest-versioning|rest-bucket|rest-multipart)
|
||||
run_suite "$1"
|
||||
;;
|
||||
*) # Handle unrecognized options or positional arguments
|
||||
@@ -156,6 +162,12 @@ run_suite() {
|
||||
exit_code=1
|
||||
elif ! "$HOME"/bin/bats ./tests/test_rest_checksum.sh; then
|
||||
exit_code=1
|
||||
elif ! "$HOME"/bin/bats ./tests/test_rest_create_bucket.sh; then
|
||||
exit_code=1
|
||||
elif ! "$HOME"/bin/bats ./tests/test_rest_head_bucket.sh; then
|
||||
exit_code=1
|
||||
elif ! "$HOME"/bin/bats ./tests/test_rest_list_buckets.sh; then
|
||||
exit_code=1
|
||||
elif ! "$HOME"/bin/bats ./tests/test_rest_multipart.sh; then
|
||||
exit_code=1
|
||||
elif ! "$HOME"/bin/bats ./tests/test_rest_versioning.sh; then
|
||||
@@ -184,6 +196,18 @@ run_suite() {
|
||||
echo "Running REST checksum tests ..."
|
||||
"$HOME"/bin/bats ./tests/test_rest_checksum.sh || exit_code=$?
|
||||
;;
|
||||
rest-create-bucket)
|
||||
echo "Running REST create bucket tests ..."
|
||||
"$HOME"/bin/bats ./tests/test_rest_create_bucket.sh || exit_code=$?
|
||||
;;
|
||||
rest-head-bucket)
|
||||
echo "Running REST head bucket tests ..."
|
||||
"$HOME"/bin/bats ./tests/test_rest_head_bucket.sh || exit_code=$?
|
||||
;;
|
||||
rest-list-buckets)
|
||||
echo "Running REST list-buckets tests ..."
|
||||
"$HOME"/bin/bats ./tests/test_rest_list_buckets.sh || exit_code=$?
|
||||
;;
|
||||
rest-multipart)
|
||||
echo "Running REST multipart tests ..."
|
||||
"$HOME"/bin/bats ./tests/test_rest_multipart.sh || exit_code=$?
|
||||
|
||||
@@ -66,14 +66,6 @@ export RUN_USERS=true
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "test_rest_list_buckets" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run list_check_buckets_rest "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - get, put bucket ownership controls" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
@@ -175,20 +167,6 @@ export RUN_USERS=true
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - create bucket test" {
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "skip bucket create tests for static buckets"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run create_bucket_rest "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run list_check_buckets_rest "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - POST call on root endpoint" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1036"
|
||||
@@ -196,148 +174,3 @@ export RUN_USERS=true
|
||||
run delete_object_empty_bucket_check_error
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket w/invalid acl" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1379"
|
||||
fi
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "skip bucket create tests for static buckets"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
envs="ACL=public-reads OBJECT_OWNERSHIP=BucketOwnerPreferred"
|
||||
run create_bucket_rest_expect_error "$BUCKET_ONE_NAME" "$envs" "400" "InvalidArgument" ""
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-full-control - non-existent user" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1384"
|
||||
fi
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "skip bucket create tests for static buckets"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
id="id=$ACL_AWS_CANONICAL_ID"0
|
||||
else
|
||||
id="$AWS_ACCESS_KEY_ID"a
|
||||
fi
|
||||
envs="GRANT_FULL_CONTROL=$id OBJECT_OWNERSHIP=BucketOwnerPreferred"
|
||||
run create_bucket_rest_expect_error "$BUCKET_ONE_NAME" "$envs" "400" "InvalidArgument" "Invalid id"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-full-control - no ownership control change" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1387"
|
||||
fi
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "skip bucket create tests for static buckets"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
id="id=$ACL_AWS_CANONICAL_ID"
|
||||
else
|
||||
id="$AWS_ACCESS_KEY_ID"
|
||||
fi
|
||||
envs="GRANT_FULL_CONTROL=$id"
|
||||
run create_bucket_rest_expect_error "$BUCKET_ONE_NAME" "$envs" "400" "InvalidBucketAclWithObjectOwnership" "Bucket cannot have ACLs set"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-full-control - success" {
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "skip bucket create tests for static buckets"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE"
|
||||
assert_success
|
||||
user_canonical_id=${lines[1]}
|
||||
username=${lines[2]}
|
||||
password=${lines[3]}
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
id="id=$user_canonical_id"
|
||||
else
|
||||
id="$user_canonical_id"
|
||||
fi
|
||||
envs="GRANT_FULL_CONTROL=$id OBJECT_OWNERSHIP=BucketOwnerPreferred"
|
||||
run create_bucket_rest_expect_success "$BUCKET_ONE_NAME" "$envs"
|
||||
assert_success
|
||||
|
||||
test_file="test_file"
|
||||
run create_test_file "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object_rest_with_user "$username" "$password" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
assert_success
|
||||
|
||||
run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/${test_file}-copy"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - list buckets w/prefix" {
|
||||
run setup_buckets "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME"
|
||||
assert_success
|
||||
|
||||
run list_check_buckets_rest "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME"
|
||||
assert_success
|
||||
|
||||
run list_check_buckets_rest_with_prefix "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run list_check_buckets_rest_with_prefix "$BUCKET_TWO_NAME"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - list buckets - continuation token isn't bucket name" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1399"
|
||||
fi
|
||||
run setup_buckets "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME"
|
||||
assert_success
|
||||
|
||||
run check_continuation_token
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - list buckets - success" {
|
||||
run setup_buckets "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME"
|
||||
assert_success
|
||||
|
||||
run check_for_buckets_with_multiple_pages "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-full-control - success w/tests" {
|
||||
run setup_and_create_bucket_and_check_acl "GRANT_FULL_CONTROL"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-read" {
|
||||
run setup_and_create_bucket_and_check_acl "GRANT_READ"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-write" {
|
||||
run setup_and_create_bucket_and_check_acl "GRANT_WRITE"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-read-acp" {
|
||||
run setup_and_create_bucket_and_check_acl "GRANT_READ_ACP"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-write-acp" {
|
||||
run setup_and_create_bucket_and_check_acl "GRANT_WRITE_ACP"
|
||||
assert_success
|
||||
}
|
||||
|
||||
119
tests/test_rest_create_bucket.sh
Executable file
119
tests/test_rest_create_bucket.sh
Executable file
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# Copyright 2024 Versity Software
|
||||
# This file is licensed under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http:#www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
load ./bats-support/load
|
||||
load ./bats-assert/load
|
||||
|
||||
source ./tests/commands/list_buckets.sh
|
||||
source ./tests/drivers/create_bucket/create_bucket_rest.sh
|
||||
source ./tests/drivers/list_buckets/list_buckets_rest.sh
|
||||
source ./tests/setup.sh
|
||||
|
||||
export RUN_USERS=true
|
||||
|
||||
@test "REST - create bucket test" {
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "skip bucket create tests for static buckets"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run create_bucket_rest "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run list_check_buckets_rest "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket w/invalid acl" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1379"
|
||||
fi
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "skip bucket create tests for static buckets"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
envs="ACL=public-reads OBJECT_OWNERSHIP=BucketOwnerPreferred"
|
||||
run create_bucket_rest_expect_error "$BUCKET_ONE_NAME" "$envs" "400" "InvalidArgument" ""
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-full-control - non-existent user" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1384"
|
||||
fi
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "skip bucket create tests for static buckets"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
id="id=$ACL_AWS_CANONICAL_ID"0
|
||||
else
|
||||
id="$AWS_ACCESS_KEY_ID"a
|
||||
fi
|
||||
envs="GRANT_FULL_CONTROL=$id OBJECT_OWNERSHIP=BucketOwnerPreferred"
|
||||
run create_bucket_rest_expect_error "$BUCKET_ONE_NAME" "$envs" "400" "InvalidArgument" "Invalid id"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-full-control - no ownership control change" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1387"
|
||||
fi
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "skip bucket create tests for static buckets"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
id="id=$ACL_AWS_CANONICAL_ID"
|
||||
else
|
||||
id="$AWS_ACCESS_KEY_ID"
|
||||
fi
|
||||
envs="GRANT_FULL_CONTROL=$id"
|
||||
run create_bucket_rest_expect_error "$BUCKET_ONE_NAME" "$envs" "400" "InvalidBucketAclWithObjectOwnership" "Bucket cannot have ACLs set"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-full-control - success w/tests" {
|
||||
run setup_and_create_bucket_and_check_acl "GRANT_FULL_CONTROL"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-read" {
|
||||
run setup_and_create_bucket_and_check_acl "GRANT_READ"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-write" {
|
||||
run setup_and_create_bucket_and_check_acl "GRANT_WRITE"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-read-acp" {
|
||||
run setup_and_create_bucket_and_check_acl "GRANT_READ_ACP"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - CreateBucket - x-amz-grant-write-acp" {
|
||||
run setup_and_create_bucket_and_check_acl "GRANT_WRITE_ACP"
|
||||
assert_success
|
||||
}
|
||||
50
tests/test_rest_head_bucket.sh
Executable file
50
tests/test_rest_head_bucket.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# Copyright 2024 Versity Software
|
||||
# This file is licensed under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http:#www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
load ./bats-support/load
|
||||
load ./bats-assert/load
|
||||
|
||||
source ./tests/setup.sh
|
||||
|
||||
@test "REST - HeadBucket - mismatched owner" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1428"
|
||||
fi
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run head_bucket_rest_expect_error "$BUCKET_ONE_NAME" "EXPECTED_OWNER=012345678901" "403" "Forbidden"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - HeadBucket - invalid owner" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1428"
|
||||
fi
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run head_bucket_rest_expect_error "$BUCKET_ONE_NAME" "EXPECTED_OWNER=01234567890" "400" "Bad Request"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - HeadBucket - success" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run head_bucket_rest_expect_success "$BUCKET_ONE_NAME" "EXPECTED_OWNER=$AWS_USER_ID"
|
||||
assert_success
|
||||
}
|
||||
64
tests/test_rest_list_buckets.sh
Executable file
64
tests/test_rest_list_buckets.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# Copyright 2024 Versity Software
|
||||
# This file is licensed under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http:#www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
load ./bats-support/load
|
||||
load ./bats-assert/load
|
||||
|
||||
source ./tests/commands/list_buckets.sh
|
||||
source ./tests/drivers/list_buckets/list_buckets_rest.sh
|
||||
source ./tests/logger.sh
|
||||
source ./tests/setup.sh
|
||||
|
||||
@test "test_rest_list_buckets" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run list_check_buckets_rest "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - list buckets - continuation token isn't bucket name" {
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1399"
|
||||
fi
|
||||
run setup_buckets "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME"
|
||||
assert_success
|
||||
|
||||
run check_continuation_token
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - list buckets - success (multiple pages)" {
|
||||
run setup_buckets "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME"
|
||||
assert_success
|
||||
|
||||
run check_for_buckets_with_multiple_pages "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - list buckets w/prefix" {
|
||||
run setup_buckets "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME"
|
||||
assert_success
|
||||
|
||||
run list_check_buckets_rest "$BUCKET_ONE_NAME" "$BUCKET_TWO_NAME"
|
||||
assert_success
|
||||
|
||||
run list_check_buckets_rest_with_prefix "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run list_check_buckets_rest_with_prefix "$BUCKET_TWO_NAME"
|
||||
assert_success
|
||||
}
|
||||
Reference in New Issue
Block a user