mirror of
https://github.com/versity/versitygw.git
synced 2026-08-25 00:26:40 +00:00
test: temp
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2026 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.
|
||||
|
||||
compare_website_suffixes() {
|
||||
if ! check_param_count_v2 "data file, expected suffix" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
local data_file="$1" expected_suffix="$2"
|
||||
|
||||
if ! check_xml_element "$data_file" "$expected_suffix" "WebsiteConfiguration" "IndexDocument" "Suffix"; then
|
||||
log 2 "error checking xml element"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_index_document_suffix() {
|
||||
if ! check_param_count_v2 "bucket name, expected suffix" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
local bucket_name="$1" expected_suffix="$2"
|
||||
|
||||
if ! send_rest_go_command_callback "200" "compare_website_suffixes" "-bucketName" "$bucket_name" "-query" "website" "--" "$expected_suffix"; then
|
||||
log 2 "error sending get website command or comparing suffix"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@@ -24,29 +24,17 @@ create_website_with_random_string() {
|
||||
local bucket_name="$1"
|
||||
local response file_name test_string
|
||||
|
||||
if ! response=$(get_file_name 2>&1); then
|
||||
log 2 "error getting file name: $response"
|
||||
return 1
|
||||
fi
|
||||
file_name="$response"
|
||||
|
||||
if ! response=$(generate_random_string 8 10 2>&1); then
|
||||
log 2 "error generating random string: $response"
|
||||
return 1
|
||||
fi
|
||||
test_string="$response"
|
||||
echo "$test_string" > "$TEST_FILE_FOLDER/$file_name"
|
||||
|
||||
if ! response=$(put_object_rest "$TEST_FILE_FOLDER/$file_name" "$bucket_name" "$file_name" 2>&1); then
|
||||
log 2 "error putting random string file: $response"
|
||||
if ! response=$(put_object_with_random_alnum_string "$bucket_name" 2>&1); then
|
||||
log 2 "error putting object with random alnum string: $response"
|
||||
return 1
|
||||
fi
|
||||
read -r file_name test_string <<< "$response"
|
||||
|
||||
if ! response=$(send_rest_go_command "200" "-commandType" "putBucketWebsiteConfiguration" "-bucketName" "$bucket_name" \
|
||||
"-websiteConfiguration" "{\"IndexDocument\":{\"Suffix\":\"$file_name\"}}" 2>&1); then
|
||||
log 2 "error putting website configuration: $response"
|
||||
return 1
|
||||
fi
|
||||
printf '%s\n' "$test_string"
|
||||
printf '%s\n' "$file_name $test_string"
|
||||
return 0
|
||||
}
|
||||
@@ -525,3 +525,31 @@ put_objects() {
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
put_object_with_random_alnum_string() {
|
||||
if ! check_param_count_v2 "bucket name" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
local bucket_name="$1"
|
||||
local response file_name test_string
|
||||
|
||||
if ! response=$(get_file_name 2>&1); then
|
||||
log 2 "error getting file name: $response"
|
||||
return 1
|
||||
fi
|
||||
file_name="$response"
|
||||
|
||||
if ! response=$(generate_random_string 8 10 2>&1); then
|
||||
log 2 "error generating random string: $response"
|
||||
return 1
|
||||
fi
|
||||
test_string="$response"
|
||||
echo "$test_string" > "$TEST_FILE_FOLDER/$file_name"
|
||||
|
||||
if ! response=$(put_object_rest "$TEST_FILE_FOLDER/$file_name" "$bucket_name" "$file_name" 2>&1); then
|
||||
log 2 "error putting random string file: $response"
|
||||
return 1
|
||||
fi
|
||||
echo "$file_name" "$test_string"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ load ./bats-assert/load
|
||||
|
||||
source ./tests/commands/put_public_access_block.sh
|
||||
source ./tests/drivers/create_bucket/create_bucket_rest.sh
|
||||
source ./tests/drivers/get_bucket_website/get_bucket_website_rest.sh
|
||||
source ./tests/drivers/put_bucket_website/put_bucket_website_rest.sh
|
||||
source ./tests/drivers/cloudfront.sh
|
||||
source ./tests/drivers/string.sh
|
||||
@@ -103,7 +104,7 @@ source ./tests/setup.sh
|
||||
|
||||
run create_website_with_random_string "$bucket_name"
|
||||
assert_success
|
||||
random_string="$output"
|
||||
read -r _ random_string <<< "$output"
|
||||
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
run put_public_access_block "$bucket_name" "BlockPublicAcls=false,IgnorePublicAcls=false,BlockPublicPolicy=false,RestrictPublicBuckets=false"
|
||||
@@ -121,3 +122,29 @@ source ./tests/setup.sh
|
||||
assert_success
|
||||
assert_output "$random_string"
|
||||
}
|
||||
|
||||
@test "REST - GetBucketWebsite - IndexDocument Suffix, DeleteBucketWebsite" {
|
||||
local bucket_name test_file random_string
|
||||
|
||||
run setup_bucket_v3 "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run create_website_with_random_string "$bucket_name"
|
||||
assert_success
|
||||
read -r test_file random_string <<< "$output"
|
||||
|
||||
run check_index_document_suffix "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run send_rest_go_command "204" "-method" "DELETE" "-query" "website" "-bucketName" "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run send_rest_go_command_expect_error_with_specific_arg_name_value "404" "NoSuchWebsiteConfiguration" \
|
||||
"does not have a website configuration" "BucketName" "$bucket_name" "-query" "website" "-bucketName" "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - GetBucketWebsite - no HTTPS" {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user