mirror of
https://github.com/versity/versitygw.git
synced 2026-01-24 20:12:01 +00:00
Compare commits
11 Commits
main
...
test/direc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e1b4d8011 | ||
|
|
82ea2723fa | ||
|
|
5e53c91090 | ||
|
|
bcc60bc933 | ||
|
|
3e8d81a2a9 | ||
|
|
38edfa2a73 | ||
|
|
2e9e6887b1 | ||
|
|
352cd5dc94 | ||
|
|
6ae48f709b | ||
|
|
3cd61859b8 | ||
|
|
4f78382ae6 |
29
.github/workflows/system.yml
vendored
29
.github/workflows/system.yml
vendored
@@ -39,6 +39,24 @@ jobs:
|
||||
RECREATE_BUCKETS: "true"
|
||||
DELETE_BUCKETS_AFTER_TEST: "true"
|
||||
BACKEND: "posix"
|
||||
- set: "REST, posix, static, base|acl|multipart|put-object, folder IAM"
|
||||
IAM_TYPE: folder
|
||||
RUN_SET: "rest-base,rest-acl,rest-multipart,rest-put-object"
|
||||
RECREATE_BUCKETS: "false"
|
||||
DELETE_BUCKETS_AFTER_TEST: "false"
|
||||
BACKEND: "posix"
|
||||
- set: "REST, posix, static, chunked|checksum|versioning|bucket, folder IAM"
|
||||
IAM_TYPE: folder
|
||||
RUN_SET: "rest-chunked,rest-checksum,rest-versioning,rest-bucket,rest-list-buckets,rest-create-bucket,rest-head-bucket"
|
||||
RECREATE_BUCKETS: "false"
|
||||
DELETE_BUCKETS_AFTER_TEST: "false"
|
||||
BACKEND: "posix"
|
||||
- set: "REST, posix, static, not implemented|rest-delete-bucket-ownership-controls|rest-delete-bucket-tagging, folder IAM"
|
||||
IAM_TYPE: folder
|
||||
RUN_SET: "rest-not-implemented,rest-delete-bucket-ownership-controls,rest-delete-bucket-tagging"
|
||||
RECREATE_BUCKETS: "false"
|
||||
DELETE_BUCKETS_AFTER_TEST: "false"
|
||||
BACKEND: "posix"
|
||||
- set: "s3, posix, non-file count, non-static, folder IAM"
|
||||
IAM_TYPE: folder
|
||||
RUN_SET: "s3-non-file-count"
|
||||
@@ -128,6 +146,12 @@ jobs:
|
||||
RECREATE_BUCKETS: "true"
|
||||
DELETE_BUCKETS_AFTER_TEST: "true"
|
||||
BACKEND: "posix"
|
||||
- set: "setup/remove static buckets scripts"
|
||||
IAM_TYPE: folder
|
||||
RUN_SET: "setup-remove-static"
|
||||
RECREATE_BUCKETS: "true"
|
||||
DELETE_BUCKETS_AFTER_TEST: "true"
|
||||
BACKEND: "posix"
|
||||
steps:
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v4
|
||||
@@ -229,7 +253,10 @@ jobs:
|
||||
BYPASS_ENV_FILE=true ${{ github.workspace }}/tests/run.sh $RUN_SET
|
||||
|
||||
- name: Time report
|
||||
run: cat ${{ github.workspace }}/time.log
|
||||
run: |
|
||||
if [ -e ${{ github.workspace }}/time.log ]; then
|
||||
cat ${{ github.workspace }}/time.log
|
||||
fi
|
||||
|
||||
- name: Coverage report
|
||||
run: |
|
||||
|
||||
@@ -22,6 +22,9 @@ RUN apt-get update && \
|
||||
bc \
|
||||
libxml2-utils \
|
||||
xmlstarlet \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
xxd \
|
||||
ca-certificates && \
|
||||
update-ca-certificates && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
@@ -63,6 +66,15 @@ RUN git clone https://github.com/bats-core/bats-core.git && \
|
||||
cd bats-core && \
|
||||
./install.sh /home/tester
|
||||
|
||||
# Create a shared venv & install Python deps there
|
||||
ENV VENV=/opt/venv
|
||||
RUN python3 -m venv "$VENV" \
|
||||
&& "$VENV/bin/python" -m pip install --upgrade pip \
|
||||
&& "$VENV/bin/pip" install --no-cache-dir awscrt
|
||||
|
||||
# Make the venv the default Python for all subsequent RUN/CMD/ENTRYPOINT
|
||||
ENV PATH="$VENV/bin:${PATH}"
|
||||
|
||||
USER tester
|
||||
COPY --chown=tester:tester . /home/tester
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ get_bucket_ownership_controls_rest() {
|
||||
if ! check_param_count "get_bucket_ownership_controls_rest" "bucket" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$BUCKET_ONE_NAME" OUTPUT_FILE="$TEST_FILE_FOLDER/ownershipControls.txt" ./tests/rest_scripts/get_bucket_ownership_controls.sh); then
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OUTPUT_FILE="$TEST_FILE_FOLDER/ownershipControls.txt" ./tests/rest_scripts/get_bucket_ownership_controls.sh); then
|
||||
log 2 "error getting bucket ownership controls: $result"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -66,10 +66,10 @@ get_object_legal_hold_rest_version_id() {
|
||||
log 2 "error getting object legal hold: $result"
|
||||
return 1
|
||||
fi
|
||||
legal_hold=$(cat "$TEST_FILE_FOLDER/legal_hold.txt")
|
||||
if [ "$result" != "200" ]; then
|
||||
log 2 "get-object-legal-hold returned code $result: $(cat "$TEST_FILE_FOLDER/legal_hold.txt")"
|
||||
log 2 "get-object-legal-hold returned code $result: $legal_hold)"
|
||||
return 1
|
||||
fi
|
||||
legal_hold=$(cat "$TEST_FILE_FOLDER/legal_hold.txt")
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -53,5 +53,6 @@ get_object_lock_configuration_rest() {
|
||||
return 1
|
||||
fi
|
||||
lock_config="$(cat "$TEST_FILE_FOLDER/object-lock-config.txt")"
|
||||
log 5 "lock config: $lock_config"
|
||||
return 0
|
||||
}
|
||||
@@ -69,7 +69,7 @@ reset_bucket_acl() {
|
||||
log 2 "error resetting direct ACL"
|
||||
return 1
|
||||
fi
|
||||
if ! put_bucket_acl_rest "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER/$acl_file"; then
|
||||
if ! put_bucket_acl_rest "$1" "$TEST_FILE_FOLDER/$acl_file"; then
|
||||
log 2 "error putting bucket acl (s3api)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -39,7 +39,7 @@ copy_object_invalid_copy_source() {
|
||||
log 2 "'copy_object_invalid_copy_source' requires bucket name"
|
||||
return 1
|
||||
fi
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$BUCKET_ONE_NAME" OBJECT_KEY="dummy-copy" COPY_SOURCE="dummy" OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" ./tests/rest_scripts/copy_object.sh); then
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OBJECT_KEY="dummy-copy" COPY_SOURCE="dummy" OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" ./tests/rest_scripts/copy_object.sh); then
|
||||
log 2 "error copying object: $result"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
source ./tests/drivers/delete_bucket/delete_bucket_rest.sh
|
||||
source ./tests/drivers/get_bucket_acl/get_bucket_acl_rest.sh
|
||||
source ./tests/drivers/get_object/get_object_rest.sh
|
||||
source ./tests/drivers/put_bucket_acl/put_bucket_acl_rest.sh
|
||||
@@ -47,8 +48,14 @@ setup_and_create_bucket_and_check_acl() {
|
||||
log 5 "username=$username, password=$password"
|
||||
envs="$1=$id OBJECT_OWNERSHIP=BucketOwnerPreferred"
|
||||
log 5 "envs: $envs"
|
||||
|
||||
if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then
|
||||
log 2 "error retrieving bucket name: $bucket_name"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
if ! create_bucket_and_check_acl "$BUCKET_ONE_NAME" "$envs" "$username" "$password" "$user_canonical_id" "$owner_canonical_id"; then
|
||||
if ! create_bucket_and_check_acl "$bucket_name" "$envs" "$username" "$password" "$user_canonical_id" "$owner_canonical_id"; then
|
||||
log 2 "error creating bucket and checking ACL"
|
||||
return 1
|
||||
fi
|
||||
@@ -111,4 +118,97 @@ create_bucket_and_check_acl() {
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
get_bucket_prefix() {
|
||||
if ! check_param_count_v2 "bucket prefix or name" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
if [ "$RECREATE_BUCKETS" == "true" ]; then
|
||||
# remove date/time suffix
|
||||
prefix="$(echo "$1" | awk '{print substr($0, 1, length($0)-15)}')"
|
||||
else
|
||||
prefix="$1"
|
||||
fi
|
||||
echo "$prefix"
|
||||
}
|
||||
|
||||
setup_bucket_v2() {
|
||||
if ! check_param_count_v2 "bucket prefix or name" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! prefix=$(get_bucket_prefix "$1" 2>&1); then
|
||||
log 2 "error getting prefix: $prefix"
|
||||
return 1
|
||||
fi
|
||||
if ! bucket_cleanup_if_bucket_exists_v2 "$prefix"; then
|
||||
log 2 "error cleaning up bucket(s), if it/they exist(s)"
|
||||
return 1
|
||||
fi
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
return 0
|
||||
fi
|
||||
if ! create_bucket_rest_expect_success "$1" ""; then
|
||||
log 2 "error creating bucket '$1'"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
get_bucket_name() {
|
||||
if ! check_param_count_v2 "bucket" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
echo "$1"
|
||||
fi
|
||||
echo "$1-$(date +%Y%m%d%H%M%S)"
|
||||
}
|
||||
|
||||
setup_bucket_object_lock_enabled_v2() {
|
||||
if ! check_param_count_v2 "bucket" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! prefix=$(get_bucket_prefix "$1" 2>&1); then
|
||||
log 2 "error getting prefix: $prefix"
|
||||
return 1
|
||||
fi
|
||||
if ! bucket_cleanup_if_bucket_exists_v2 "$prefix"; then
|
||||
log 2 "error cleaning up bucket"
|
||||
return 1
|
||||
fi
|
||||
if [ "$RECREATE_BUCKETS" == "true" ]; then
|
||||
if ! create_bucket_object_lock_enabled "$1"; then
|
||||
log 2 "error creating bucket '$1' with object lock enabled"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_bucket_object_lock_enabled() {
|
||||
if ! check_param_count "setup_bucket_object_lock_enabled" "bucket" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! bucket_cleanup_if_bucket_exists "$1"; then
|
||||
log 2 "error cleaning up bucket"
|
||||
return 1
|
||||
fi
|
||||
if [ "$DIRECT" == "true" ] && [ "$RECREATE_BUCKETS" == "true" ]; then
|
||||
log 2 "bucket not confirmed as deleted"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# in static bucket config, bucket will still exist
|
||||
if ! bucket_exists "$1"; then
|
||||
if ! create_bucket_object_lock_enabled "$1"; then
|
||||
log 2 "error creating bucket with object lock enabled"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
log 2 "bucket not confirmed as created"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
142
tests/drivers/delete_bucket/delete_bucket_rest.sh
Normal file
142
tests/drivers/delete_bucket/delete_bucket_rest.sh
Normal file
@@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# 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.
|
||||
|
||||
source ./tests/commands/list_buckets.sh
|
||||
source ./tests/drivers/list_buckets/list_buckets_rest.sh
|
||||
|
||||
delete_buckets_with_prefix() {
|
||||
if ! check_param_count_v2 "bucket prefix" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
if [ "$1" == "" ]; then
|
||||
log 2 "delete_buckets_with_prefix requires non-empty prefix"
|
||||
return 1
|
||||
fi
|
||||
if ! list_buckets_rest "PREFIX=$1" "parse_bucket_list"; then
|
||||
log 2 "error listing buckets with prefix"
|
||||
return 1
|
||||
fi
|
||||
# shellcheck disable=SC2154
|
||||
log 5 "buckets: ${bucket_array[*]}"
|
||||
for bucket in "${bucket_array[@]}"; do
|
||||
if ! delete_bucket_recursive "$bucket"; then
|
||||
log 2 "error with recursive bucket delete of bucket '$bucket'"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
cleanup_buckets() {
|
||||
if ! bucket_cleanup_if_bucket_exists_v2 "$BUCKET_ONE_NAME"; then
|
||||
log 3 "error deleting bucket $BUCKET_ONE_NAME or contents"
|
||||
fi
|
||||
if ! bucket_cleanup_if_bucket_exists_v2 "$BUCKET_TWO_NAME"; then
|
||||
log 3 "error deleting bucket $BUCKET_TWO_NAME or contents"
|
||||
fi
|
||||
}
|
||||
|
||||
# params: client, bucket name
|
||||
# return 0 for success, 1 for error
|
||||
bucket_cleanup() {
|
||||
log 6 "bucket_cleanup"
|
||||
if ! check_param_count "bucket_cleanup" "bucket name" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
if [[ $RECREATE_BUCKETS == "false" ]]; then
|
||||
if ! reset_bucket "$1"; then
|
||||
log 2 "error deleting bucket contents"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log 5 "bucket contents, policy, ACL deletion success"
|
||||
return 0
|
||||
fi
|
||||
if ! delete_bucket_recursive "$1"; then
|
||||
log 2 "error with recursive bucket delete"
|
||||
return 1
|
||||
fi
|
||||
log 5 "bucket deletion success"
|
||||
return 0
|
||||
}
|
||||
|
||||
# params: client, bucket name
|
||||
# return 0 for success, 1 for error
|
||||
bucket_cleanup_if_bucket_exists() {
|
||||
log 6 "bucket_cleanup_if_bucket_exists"
|
||||
if ! check_param_count_gt "bucket name, bucket known to exist (optional)" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$2" == "false" ]; then
|
||||
log 5 "skipping cleanup, since bucket doesn't exist"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "$2" == "true" ] || bucket_exists "$1"; then
|
||||
if ! bucket_cleanup "$1"; then
|
||||
log 2 "error deleting bucket and/or contents"
|
||||
return 1
|
||||
fi
|
||||
log 5 "bucket and/or bucket data deletion success"
|
||||
return 0
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
bucket_cleanup_if_bucket_exists_v2() {
|
||||
log 6 "bucket_cleanup_if_bucket_exists_v2"
|
||||
if ! check_param_count_gt "bucket name or prefix" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
if [[ "$RECREATE_BUCKETS" == "false" ]]; then
|
||||
if ! bucket_exists "$1"; then
|
||||
log 2 "When RECREATE_BUCKETS isn't set to \"true\", bucket with full env name should be pre-created by user"
|
||||
return 1
|
||||
fi
|
||||
if ! reset_bucket "$1"; then
|
||||
log 2 "error resetting bucket before tests"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
else
|
||||
if ! delete_buckets_with_prefix "$1"; then
|
||||
log 2 "error deleting buckets with prefix '$1'"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# params: bucket name
|
||||
# return 0 if able to delete recursively, 1 if not
|
||||
delete_bucket_recursive() {
|
||||
log 6 "delete_bucket_recursive '$1'"
|
||||
if ! check_param_count "delete_bucket_recursive_s3api" "bucket" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! reset_bucket "$1"; then
|
||||
log 2 "error clearing bucket (s3api)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! delete_bucket_rest "$1"; then
|
||||
log 2 "error deleting bucket"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@@ -36,14 +36,14 @@ list_and_delete_objects() {
|
||||
fi
|
||||
done
|
||||
|
||||
if ! delete_old_versions "$1"; then
|
||||
if ! delete_old_versions_base64 "$1"; then
|
||||
log 2 "error deleting old version"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
delete_old_versions() {
|
||||
delete_old_versions_base64() {
|
||||
if ! check_param_count "delete_old_versions" "bucket" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
@@ -53,45 +53,52 @@ delete_old_versions() {
|
||||
fi
|
||||
# shellcheck disable=SC2154
|
||||
log 5 "versions: $versions"
|
||||
version_keys=()
|
||||
version_ids=()
|
||||
|
||||
if ! parse_version_data_by_type "rest" "$2"; then
|
||||
if ! parse_base64_versions_rest; then
|
||||
log 2 "error parsing version data"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log 5 "version keys: ${version_keys[*]}"
|
||||
log 5 "version IDs: ${version_ids[*]}"
|
||||
for idx in "${!version_keys[@]}"; do
|
||||
if ! delete_object_version_with_or_without_retention "$1"; then
|
||||
log 5 "base64 versions: ${base64_pairs[*]}"
|
||||
for pair in "${base64_pairs[@]}"; do
|
||||
log 5 "pair: $pair"
|
||||
if ! delete_object_version_with_or_without_retention_base64 "$1" "$pair"; then
|
||||
log 2 "error deleting version with or without retention"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
delete_object_version_with_or_without_retention() {
|
||||
if ! check_param_count "delete_object_version_with_or_without_retention" "bucket" 1 $#; then
|
||||
delete_object_version_with_or_without_retention_base64() {
|
||||
if ! check_param_count_v2 "bucket, key/value pair" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
IFS=":" read -ra key_and_id <<< "$2"
|
||||
log 5 "key and ID: ${key_and_id[*]}"
|
||||
if ! key=$(printf '%s' "${key_and_id[0]}" | base64 --decode 2>&1); then
|
||||
log 2 "error decoding key: $key"
|
||||
return 1
|
||||
fi
|
||||
if ! id=$(printf '%s' "${key_and_id[1]}" | base64 --decode 2>&1); then
|
||||
log 2 "error decoding ID: $id"
|
||||
return 1
|
||||
fi
|
||||
log 5 "idx: $idx"
|
||||
log 5 "version ID: ${version_ids[$idx]}"
|
||||
# shellcheck disable=SC2154
|
||||
if [ "$lock_config_exists" == "true" ]; then
|
||||
if ! check_remove_legal_hold_versions "$1" "${version_keys[$idx]}" "${version_ids[$idx]}"; then
|
||||
if ! check_remove_legal_hold_versions "$1" "$key" "$id"; then
|
||||
log 2 "error checking, removing legal hold versions"
|
||||
return 1
|
||||
fi
|
||||
if ! delete_object_version_rest_bypass_retention "$1" "${version_keys[$idx]}" "${version_ids[$idx]}"; then
|
||||
if ! delete_object_version_rest_bypass_retention "$1" "$key" "$id"; then
|
||||
log 2 "error deleting object version, bypassing retention"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
if ! delete_object_version_rest "$1" "${version_keys[$idx]}" "${version_ids[$idx]}"; then
|
||||
if ! delete_object_version_rest "$1" "$key" "$id"; then
|
||||
log 2 "error deleting object version"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
log 5 "successfully deleted version with key '${version_keys[$idx]}', id '${version_ids[$idx]}'"
|
||||
log 5 "successfully deleted version with key '$key', id '$id'"
|
||||
return 0
|
||||
}
|
||||
|
||||
124
tests/drivers/file.sh
Normal file
124
tests/drivers/file.sh
Normal file
@@ -0,0 +1,124 @@
|
||||
#!/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.
|
||||
|
||||
source ./tests/drivers/params.sh
|
||||
|
||||
setup_bucket_and_file() {
|
||||
if ! check_param_count_v2 "bucket, file name" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket_and_file_base "$1" "setup_bucket_and_files" "$2"; then
|
||||
log 2 "error setting up bucket and file"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_bucket_and_file_v2() {
|
||||
if ! check_param_count_v2 "bucket, file name" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket_and_file_base "$1" "setup_bucket_and_files_v2" "$2"; then
|
||||
log 2 "error setting up bucket and files"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_bucket_and_file_base() {
|
||||
if ! check_param_count_v2 "bucket, function, file name" 3 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! "$2" "$1" "$3"; then
|
||||
log 2 "error setting up bucket and file"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_bucket_and_files() {
|
||||
if ! check_param_count_gt "bucket, file name" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket_and_files_base "$1" "setup_bucket" "${@:2}"; then
|
||||
log 2 "error setting up bucket and files"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_bucket_and_files_v2() {
|
||||
if ! check_param_count_gt "bucket, file name" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket_and_files_base "$1" "setup_bucket_v2" "${@:2}"; then
|
||||
log 2 "error setting up bucket and files"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_bucket_and_files_base() {
|
||||
if ! check_param_count_gt "bucket, setup bucket function, file name" 3 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! "$2" "$1"; then
|
||||
log 2 "error setting up bucket"
|
||||
return 1
|
||||
fi
|
||||
if ! create_test_files "${@:3}"; then
|
||||
log 2 "error creating test files"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_bucket_and_large_file_base() {
|
||||
if ! check_param_count "setup_bucket_and_large_file" "bucket, file name, function" 3 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! "$3" "$1"; then
|
||||
log 2 "error setting up bucket"
|
||||
return 1
|
||||
fi
|
||||
if ! create_large_file "$2"; then
|
||||
log 2 "error creating large file"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_bucket_and_large_file() {
|
||||
if ! check_param_count "setup_bucket_and_large_file" "bucket, file name" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket_and_large_file "$1" "$2" "setup_bucket"; then
|
||||
log 2 "error setting up bucket and large file"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_bucket_and_large_file_v2() {
|
||||
if ! check_param_count "setup_bucket_and_large_file" "bucket, file name" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket_and_large_file_base "$1" "$2" "setup_bucket_v2"; then
|
||||
log 2 "error setting up bucket and large file"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@@ -100,14 +100,3 @@ get_check_acl_after_second_put() {
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_direct_display_name() {
|
||||
if ! display_name=$(echo "$owner" | xmllint --xpath '//*[local-name()="DisplayName"]/text()' - 2>&1); then
|
||||
log 2 "error getting display name: $display_name"
|
||||
return 1
|
||||
fi
|
||||
if [ "$display_name" != "$DIRECT_DISPLAY_NAME" ]; then
|
||||
log 2 "display name mismatch (expected '$DIRECT_DISPLAY_NAME', actual '$display_name')"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -116,3 +116,14 @@ get_and_check_acl_rest() {
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_direct_display_name() {
|
||||
if ! display_name=$(echo "$owner" | xmllint --xpath '//*[local-name()="DisplayName"]/text()' - 2>&1); then
|
||||
log 2 "error getting display name: $display_name"
|
||||
return 1
|
||||
fi
|
||||
if [ "$display_name" != "$DIRECT_DISPLAY_NAME" ]; then
|
||||
log 2 "display name mismatch (expected '$DIRECT_DISPLAY_NAME', actual '$display_name')"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1,23 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# 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.
|
||||
|
||||
upload_and_check_attributes() {
|
||||
if [ $# -ne 2 ]; then
|
||||
log 2 "'upload_and_check_attributes' requires test file, file size"
|
||||
if ! check_param_count_v2 "bucket, test file, file size" 3 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! perform_multipart_upload_rest "$BUCKET_ONE_NAME" "$1" "$TEST_FILE_FOLDER/$1-0" "$TEST_FILE_FOLDER/$1-1" \
|
||||
"$TEST_FILE_FOLDER/$1-2" "$TEST_FILE_FOLDER/$1-3"; then
|
||||
if ! perform_multipart_upload_rest "$1" "$2" "$TEST_FILE_FOLDER/$2-0" "$TEST_FILE_FOLDER/$2-1" \
|
||||
"$TEST_FILE_FOLDER/$2-2" "$TEST_FILE_FOLDER/$2-3"; then
|
||||
log 2 "error uploading and checking parts"
|
||||
return 1
|
||||
fi
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$BUCKET_ONE_NAME" OBJECT_KEY="$1" ATTRIBUTES="ETag,StorageClass,ObjectParts,ObjectSize" OUTPUT_FILE="$TEST_FILE_FOLDER/attributes.txt" ./tests/rest_scripts/get_object_attributes.sh); then
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OBJECT_KEY="$2" ATTRIBUTES="ETag,StorageClass,ObjectParts,ObjectSize" OUTPUT_FILE="$TEST_FILE_FOLDER/attributes.txt" ./tests/rest_scripts/get_object_attributes.sh); then
|
||||
log 2 "error listing object attributes: $result"
|
||||
return 1
|
||||
fi
|
||||
if ! check_attributes_after_upload "$2"; then
|
||||
if ! check_attributes_after_upload "$3"; then
|
||||
log 2 "error checking attributes after upload"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_attributes_after_upload() {
|
||||
@@ -59,11 +73,10 @@ check_attributes_after_upload() {
|
||||
}
|
||||
|
||||
check_attributes_invalid_param() {
|
||||
if [ $# -ne 1 ]; then
|
||||
log 2 "'check_attributes_invalid_param' requires test file"
|
||||
if ! check_param_count_v2 "bucket name, test file" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$BUCKET_ONE_NAME" OBJECT_KEY="$1" ATTRIBUTES="ETags" OUTPUT_FILE="$TEST_FILE_FOLDER/attributes.txt" ./tests/rest_scripts/get_object_attributes.sh); then
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OBJECT_KEY="$2" ATTRIBUTES="ETags" OUTPUT_FILE="$TEST_FILE_FOLDER/attributes.txt" ./tests/rest_scripts/get_object_attributes.sh); then
|
||||
log 2 "error listing object attributes: $result"
|
||||
return 1
|
||||
fi
|
||||
@@ -83,24 +96,23 @@ check_attributes_invalid_param() {
|
||||
}
|
||||
|
||||
add_and_check_checksum() {
|
||||
if [ $# -ne 2 ]; then
|
||||
log 2 "'add_and_check_checksum' requires data file, key"
|
||||
if ! check_param_count_v2 "data file, bucket, key" 3 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" DATA_FILE="$1" BUCKET_NAME="$BUCKET_ONE_NAME" OBJECT_KEY="$2" CHECKSUM_TYPE="sha256" OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" ./tests/rest_scripts/put_object.sh); then
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" DATA_FILE="$1" BUCKET_NAME="$2" OBJECT_KEY="$3" CHECKSUM_TYPE="sha256" OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" ./tests/rest_scripts/put_object.sh); then
|
||||
log 2 "error sending object file: $result"
|
||||
return 1
|
||||
fi
|
||||
if [ "$result" != "200" ]; then
|
||||
log 2 "expected response code of '200', was '$result' (output: $(cat "$TEST_FILE_FOLDER/result.txt")"
|
||||
log 2 "expected response code of '200', was '$result' (output: $(cat "$TEST_FILE_FOLDER/result.txt"))"
|
||||
return 1
|
||||
fi
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$BUCKET_ONE_NAME" OBJECT_KEY="$2" ATTRIBUTES="Checksum" OUTPUT_FILE="$TEST_FILE_FOLDER/attributes.txt" ./tests/rest_scripts/get_object_attributes.sh); then
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$2" OBJECT_KEY="$3" ATTRIBUTES="Checksum" OUTPUT_FILE="$TEST_FILE_FOLDER/attributes.txt" ./tests/rest_scripts/get_object_attributes.sh); then
|
||||
log 2 "error listing object attributes: $result (output: $(cat "$TEST_FILE_FOLDER/attributes.txt")"
|
||||
return 1
|
||||
fi
|
||||
if [ "$result" != "200" ]; then
|
||||
log 2 "expected response code of '200', was '$result'"
|
||||
log 2 "expected response code of '200', was '$result' ($(cat "$TEST_FILE_FOLDER/attributes.txt"))"
|
||||
return 1
|
||||
fi
|
||||
log 5 "attributes: $(cat "$TEST_FILE_FOLDER/attributes.txt")"
|
||||
@@ -129,4 +141,4 @@ get_etag_attribute_rest() {
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ check_object_lock_config() {
|
||||
lock_config_exists=true
|
||||
if ! get_object_lock_configuration "rest" "$1"; then
|
||||
# shellcheck disable=SC2154
|
||||
log 5 "lock config error: $get_object_lock_config_err"
|
||||
if [[ "$get_object_lock_config_err" == *"does not exist"* ]]; then
|
||||
# shellcheck disable=SC2034
|
||||
lock_config_exists=false
|
||||
|
||||
@@ -64,9 +64,13 @@ parse_bucket_list() {
|
||||
bucket_list=$(xmllint --xpath '//*[local-name()="Bucket"]/*[local-name()="Name"]/text()' "$1")
|
||||
bucket_array=()
|
||||
while read -r bucket; do
|
||||
bucket_array+=("$bucket")
|
||||
if [ -n "$bucket" ]; then
|
||||
log 5 "reading bucket '$bucket'"
|
||||
bucket_array+=("$bucket")
|
||||
fi
|
||||
done <<< "$bucket_list"
|
||||
log 5 "bucket array: ${bucket_array[*]}"
|
||||
log 5 "bucket array length: ${#bucket_array[@]}"
|
||||
}
|
||||
|
||||
parse_buckets_and_continuation_token() {
|
||||
|
||||
@@ -64,7 +64,7 @@ check_ownership_rule_and_reset_acl() {
|
||||
return 1
|
||||
fi
|
||||
if ! object_ownership_rule=$(get_bucket_ownership_controls_rest "$1" 2>&1); then
|
||||
log 2 "error getting bucket ownership controls"
|
||||
log 2 "error getting bucket ownership controls: $object_ownership_rule"
|
||||
return 1
|
||||
fi
|
||||
log 5 "ownership rule: $object_ownership_rule"
|
||||
|
||||
@@ -158,8 +158,9 @@ send_rest_command_expect_success_callback() {
|
||||
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"))"
|
||||
response_code="$(echo "$result" | tail -n 1)"
|
||||
if [ "$response_code" != "$3" ]; then
|
||||
log 2 "expected '$3', was '$response_code' ($(cat "$TEST_FILE_FOLDER/output.txt"))"
|
||||
return 1
|
||||
fi
|
||||
if [ "$4" != "" ] && ! "$4" "$TEST_FILE_FOLDER/output.txt"; then
|
||||
|
||||
@@ -68,7 +68,7 @@ setup_bucket_and_user_v2() {
|
||||
if ! check_param_count_v2 "bucket, username, password" 3 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket "$1"; then
|
||||
if ! setup_bucket_v2 "$1"; then
|
||||
log 2 "error setting up bucket"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -18,31 +18,32 @@ source ./tests/setup.sh
|
||||
source ./tests/util/util_object.sh
|
||||
|
||||
delete_bucket_if_exists() {
|
||||
if [[ $# -ne 2 ]]; then
|
||||
log 2 "delete_bucket_if_exists command missing command type, name"
|
||||
if [[ $# -ne 1 ]]; then
|
||||
log 2 "delete_bucket_if_exists command missing bucket name"
|
||||
return 1
|
||||
fi
|
||||
bucket_exists "$1" "$2" || local exists_result=$?
|
||||
bucket_exists "$1" || local exists_result=$?
|
||||
if [[ $exists_result -eq 2 ]]; then
|
||||
log 2 "error checking if bucket exists"
|
||||
return 1
|
||||
fi
|
||||
if [[ $exists_result -eq 1 ]]; then
|
||||
echo "bucket '$2' doesn't exist, skipping"
|
||||
echo "bucket '$1' doesn't exist, skipping"
|
||||
return 0
|
||||
fi
|
||||
if ! delete_bucket_recursive "$1" "$2"; then
|
||||
log 5 "attempting to delete bucket '$1'"
|
||||
if ! delete_bucket_recursive "$1"; then
|
||||
log 2 "error deleting bucket"
|
||||
return 1
|
||||
fi
|
||||
echo "bucket '$2' successfully deleted"
|
||||
echo "bucket '$1' successfully deleted"
|
||||
return 0
|
||||
}
|
||||
|
||||
base_setup
|
||||
if ! RECREATE_BUCKETS=true delete_bucket_if_exists "s3api" "$BUCKET_ONE_NAME"; then
|
||||
if ! RECREATE_BUCKETS=true delete_bucket_if_exists "$BUCKET_ONE_NAME"; then
|
||||
log 2 "error deleting static bucket one"
|
||||
elif ! RECREATE_BUCKETS=true delete_bucket_if_exists "s3api" "$BUCKET_TWO_NAME"; then
|
||||
elif ! RECREATE_BUCKETS=true delete_bucket_if_exists "$BUCKET_TWO_NAME"; then
|
||||
log 2 "error deleting static bucket two"
|
||||
fi
|
||||
if ! stop_versity; then
|
||||
|
||||
@@ -21,7 +21,7 @@ source ./tests/rest_scripts/rest.sh
|
||||
# shellcheck disable=SC2153
|
||||
bucket_name="$BUCKET_NAME"
|
||||
# shellcheck disable=SC2154
|
||||
key="$OBJECT_KEY"
|
||||
key="$(echo -n "$OBJECT_KEY" | jq -sRr 'split("/") | map(@uri) | join("/")')"
|
||||
# shellcheck disable=SC2153,SC2154
|
||||
version_id="$VERSION_ID"
|
||||
|
||||
@@ -48,4 +48,5 @@ curl_command+=(-H "\"Authorization: AWS4-HMAC-SHA256 Credential=$aws_access_key_
|
||||
curl_command+=("${header_fields[@]}")
|
||||
curl_command+=(-o "$OUTPUT_FILE")
|
||||
# shellcheck disable=SC2154
|
||||
log_rest 5 "curl command: ${curl_command[*]}"
|
||||
eval "${curl_command[*]}" 2>&1
|
||||
@@ -61,7 +61,7 @@ handle_param() {
|
||||
s3api-bucket|s3api-object|s3api-multipart|rest-base|rest-acl|rest-chunked|rest-checksum|\
|
||||
rest-create-bucket|rest-head-bucket|rest-list-buckets|rest-not-implemented|\
|
||||
rest-put-object|rest-versioning|rest-bucket|rest-multipart|rest-delete-bucket-ownership-controls|\
|
||||
rest-delete-bucket-tagging)
|
||||
rest-delete-bucket-tagging|setup-remove-static)
|
||||
run_suite "$1"
|
||||
;;
|
||||
*) # Handle unrecognized options or positional arguments
|
||||
@@ -247,8 +247,13 @@ run_suite() {
|
||||
s3api-user)
|
||||
echo "Running s3api user tests ..."
|
||||
"$HOME"/bin/bats ./tests/test_user_aws.sh || exit_code=$?
|
||||
;;
|
||||
setup-remove-static)
|
||||
echo "Testing setup/remove static bucket scripts ..."
|
||||
VERSITYGW_TEST_ENV="$VERSITYGW_TEST_ENV" ./tests/test_setup_remove_static.sh || exit_code=$?
|
||||
;;
|
||||
esac
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
if [ "$exit_code" -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
source ./tests/env.sh
|
||||
source ./tests/report.sh
|
||||
source ./tests/setup_mc.sh
|
||||
source ./tests/drivers/delete_bucket/delete_bucket_rest.sh
|
||||
source ./tests/util/util_object.sh
|
||||
source ./tests/versity.sh
|
||||
|
||||
@@ -146,14 +147,9 @@ post_versity_cleanup() {
|
||||
teardown() {
|
||||
# shellcheck disable=SC2154
|
||||
log 4 "********** BEGIN TEARDOWN **********"
|
||||
if [ "$DELETE_BUCKETS_AFTER_TEST" != "false" ]; then
|
||||
log 5 "deleting or clearing buckets"
|
||||
if ! bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"; then
|
||||
log 3 "error deleting bucket $BUCKET_ONE_NAME or contents"
|
||||
fi
|
||||
if ! bucket_cleanup_if_bucket_exists "$BUCKET_TWO_NAME"; then
|
||||
log 3 "error deleting bucket $BUCKET_TWO_NAME or contents"
|
||||
fi
|
||||
if [ "$DELETE_BUCKETS_AFTER_TEST" != "false" ] && ! cleanup_buckets; then
|
||||
log 3 "error cleaning up buckets after test"
|
||||
return 1
|
||||
fi
|
||||
if [ "$SKIP_USERS_TESTS" != "true" ]; then
|
||||
if [ -n "$USERNAME_ONE" ]; then
|
||||
|
||||
@@ -29,13 +29,15 @@ source ./tests/commands/put_bucket_versioning.sh
|
||||
source ./tests/commands/put_object.sh
|
||||
source ./tests/commands/put_object_retention.sh
|
||||
source ./tests/commands/put_object_tagging.sh
|
||||
source ./tests/drivers/create_bucket/create_bucket_rest.sh
|
||||
source ./tests/drivers/copy_object/copy_object_rest.sh
|
||||
source ./tests/drivers/get_object_attributes/get_object_attributes_rest.sh
|
||||
source ./tests/drivers/get_bucket_ownership_controls/get_bucket_ownership_controls_rest.sh
|
||||
source ./tests/drivers/head_object/head_object_rest.sh
|
||||
source ./tests/drivers/file.sh
|
||||
source ./tests/drivers/xml.sh
|
||||
source ./tests/logger.sh
|
||||
source ./tests/setup.sh
|
||||
source ./tests/util/util_attributes.sh
|
||||
source ./tests/util/util_chunked_upload.sh
|
||||
source ./tests/util/util_delete_object.sh
|
||||
source ./tests/util/util_legal_hold.sh
|
||||
@@ -57,30 +59,38 @@ export RUN_USERS=true
|
||||
test_file="test_file"
|
||||
|
||||
@test "test_rest_list_objects" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run list_check_objects_rest "$BUCKET_ONE_NAME"
|
||||
run list_check_objects_rest "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "test_rest_delete_object" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_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"
|
||||
run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"
|
||||
assert_success
|
||||
|
||||
run delete_object "rest" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run delete_object "rest" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run get_object "rest" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"
|
||||
run get_object "rest" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@@ -88,22 +98,26 @@ test_file="test_file"
|
||||
test_key="TestKey"
|
||||
test_value="TestValue"
|
||||
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object_tagging "rest" "$BUCKET_ONE_NAME" "$test_file" "$test_key" "$test_value"
|
||||
run put_object_tagging "rest" "$bucket_name" "$test_file" "$test_key" "$test_value"
|
||||
assert_success
|
||||
|
||||
run check_verify_object_tags "rest" "$BUCKET_ONE_NAME" "$test_file" "$test_key" "$test_value"
|
||||
run check_verify_object_tags "rest" "$bucket_name" "$test_file" "$test_key" "$test_value"
|
||||
assert_success
|
||||
|
||||
run delete_object_tagging "rest" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run delete_object_tagging "rest" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run verify_no_object_tags "rest" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run verify_no_object_tags "rest" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -111,18 +125,17 @@ test_file="test_file"
|
||||
test_key="TestKey"
|
||||
test_value="TestValue"
|
||||
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_object_lock_enabled_v2 "$bucket_name"
|
||||
assert_success
|
||||
# in static bucket config, bucket will still exist
|
||||
if ! bucket_exists "$BUCKET_ONE_NAME"; then
|
||||
run create_bucket_object_lock_enabled "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
fi
|
||||
|
||||
run create_test_files "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
if ! five_seconds_later=$(get_time_seconds_in_future 5 "%z"); then
|
||||
@@ -130,18 +143,43 @@ test_file="test_file"
|
||||
return 1
|
||||
fi
|
||||
log 5 "later: $five_seconds_later"
|
||||
run put_object_retention_rest "$BUCKET_ONE_NAME" "$test_file" "GOVERNANCE" "$five_seconds_later"
|
||||
run put_object_retention_rest "$bucket_name" "$test_file" "GOVERNANCE" "$five_seconds_later"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - legal hold, get without config" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "test requires object lock not to be enabled"
|
||||
fi
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run check_legal_hold_without_lock_enabled "$BUCKET_ONE_NAME" "$test_file"
|
||||
run check_legal_hold_without_lock_enabled "$bucket_name" "$test_file" "InvalidRequest"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - legal hold, object lock enabled w/o specific object lock set" {
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_object_lock_enabled_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run create_test_file "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run check_legal_hold_without_lock_enabled "$bucket_name" "$test_file" "NoSuchObjectLockConfiguration"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -149,7 +187,11 @@ test_file="test_file"
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1001"
|
||||
fi
|
||||
run setup_bucket_and_large_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_large_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
@@ -158,7 +200,7 @@ test_file="test_file"
|
||||
run split_file "$TEST_FILE_FOLDER/$test_file" 4
|
||||
assert_success
|
||||
|
||||
run upload_and_check_attributes "$test_file" "$file_size"
|
||||
run upload_and_check_attributes "$bucket_name" "$test_file" "$file_size"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -166,21 +208,29 @@ test_file="test_file"
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1001"
|
||||
fi
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run check_attributes_invalid_param "$test_file"
|
||||
run check_attributes_invalid_param "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - attributes - checksum" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run add_and_check_checksum "$TEST_FILE_FOLDER/$test_file" "$test_file"
|
||||
run add_and_check_checksum "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -188,26 +238,30 @@ test_file="test_file"
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/993"
|
||||
fi
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
test_file_two="test_file_2"
|
||||
test_file_three="test_file_3"
|
||||
run setup_bucket_and_files "$BUCKET_ONE_NAME" "$test_file" "$test_file_two" "$test_file_three"
|
||||
run setup_bucket_and_files_v2 "$bucket_name" "$test_file" "$test_file_two" "$test_file_three"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file_two" "$BUCKET_ONE_NAME" "$test_file_two"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file_two" "$bucket_name" "$test_file_two"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file_three" "$BUCKET_ONE_NAME" "$test_file_three"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file_three" "$bucket_name" "$test_file_three"
|
||||
assert_success
|
||||
|
||||
run list_objects_check_params_get_token "$BUCKET_ONE_NAME" "$test_file" "$test_file_two" "TRUE"
|
||||
run list_objects_check_params_get_token "$bucket_name" "$test_file" "$test_file_two" "TRUE"
|
||||
assert_success
|
||||
continuation_token=$output
|
||||
|
||||
# interestingly, AWS appears to accept continuation tokens that are a few characters off, so have to remove three chars
|
||||
run list_objects_check_continuation_error "$BUCKET_ONE_NAME" "${continuation_token:0:${#continuation_token}-3}"
|
||||
run list_objects_check_continuation_error "$bucket_name" "${continuation_token:0:${#continuation_token}-3}"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -215,32 +269,40 @@ test_file="test_file"
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/999"
|
||||
fi
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
test_file_two="test_file_2"
|
||||
run setup_bucket_and_files "$BUCKET_ONE_NAME" "$test_file" "$test_file_two"
|
||||
run setup_bucket_and_files_v2 "$bucket_name" "$test_file" "$test_file_two"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file_two" "$BUCKET_ONE_NAME" "$test_file_two"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file_two" "$bucket_name" "$test_file_two"
|
||||
assert_success
|
||||
|
||||
run list_objects_v1_check_nextmarker_empty "$BUCKET_ONE_NAME"
|
||||
run list_objects_v1_check_nextmarker_empty "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - head object" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run get_etag_rest "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_etag_rest "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
expected_etag=$output
|
||||
|
||||
run get_etag_attribute_rest "$BUCKET_ONE_NAME" "$test_file" "$expected_etag"
|
||||
run get_etag_attribute_rest "$bucket_name" "$test_file" "$expected_etag"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -248,51 +310,63 @@ test_file="test_file"
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1040"
|
||||
fi
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run delete_objects_no_content_md5_header "$BUCKET_ONE_NAME"
|
||||
run delete_objects_no_content_md5_header "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - delete objects command" {
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
test_file_two="test_file_two"
|
||||
run setup_bucket_and_files "$BUCKET_ONE_NAME" "$test_file" "$test_file_two"
|
||||
run setup_bucket_and_files_v2 "$bucket_name" "$test_file" "$test_file_two"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file_two" "$BUCKET_ONE_NAME" "$test_file_two"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file_two" "$bucket_name" "$test_file_two"
|
||||
assert_success
|
||||
|
||||
run verify_object_exists "$BUCKET_ONE_NAME" "$test_file"
|
||||
run verify_object_exists "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run verify_object_exists "$BUCKET_ONE_NAME" "$test_file_two"
|
||||
run verify_object_exists "$bucket_name" "$test_file_two"
|
||||
assert_success
|
||||
|
||||
run delete_objects_verify_success "$BUCKET_ONE_NAME" "$test_file" "$test_file_two"
|
||||
run delete_objects_verify_success "$bucket_name" "$test_file" "$test_file_two"
|
||||
assert_success
|
||||
|
||||
run verify_object_not_found "$BUCKET_ONE_NAME" "$test_file"
|
||||
run verify_object_not_found "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run verify_object_not_found "$BUCKET_ONE_NAME" "$test_file_two"
|
||||
run verify_object_not_found "$bucket_name" "$test_file_two"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - PutObjectRetention - w/o request body" {
|
||||
run setup_bucket_object_lock_enabled "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_object_lock_enabled_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run create_test_file "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run retention_rest_without_request_body "$BUCKET_ONE_NAME" "$test_file"
|
||||
run retention_rest_without_request_body "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -300,55 +374,71 @@ test_file="test_file"
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1311"
|
||||
fi
|
||||
run setup_bucket_object_lock_enabled "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_object_lock_enabled_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run create_test_file "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run check_legal_hold_without_content_md5 "$BUCKET_ONE_NAME" "$test_file"
|
||||
run check_legal_hold_without_content_md5 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - PutObjectLegalHold w/o payload" {
|
||||
run setup_bucket_object_lock_enabled "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_object_lock_enabled_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run create_test_file "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run check_legal_hold_without_payload "$BUCKET_ONE_NAME" "$test_file"
|
||||
run check_legal_hold_without_payload "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - PutObjectLegalHold - success" {
|
||||
run setup_bucket_object_lock_enabled "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_object_lock_enabled_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run create_test_file "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run rest_check_legal_hold "$BUCKET_ONE_NAME" "$test_file"
|
||||
run rest_check_legal_hold "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - copy object w/invalid copy source" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run copy_object_invalid_copy_source "$BUCKET_ONE_NAME"
|
||||
run copy_object_invalid_copy_source "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -356,52 +446,68 @@ test_file="test_file"
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1242"
|
||||
fi
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run copy_object_copy_source_and_payload "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file"
|
||||
run copy_object_copy_source_and_payload "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - range download and compare" {
|
||||
run setup_bucket_and_large_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_large_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_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" 2000000
|
||||
run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy" 2000000
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - put, get object, encoded name" {
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
file_name=" \"<>\\^\`{}|+&?%"
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$file_name"
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$file_name"
|
||||
assert_success
|
||||
|
||||
run put_object_rest_special_chars "$TEST_FILE_FOLDER/$file_name" "$BUCKET_ONE_NAME" "$file_name/$file_name"
|
||||
run put_object_rest_special_chars "$TEST_FILE_FOLDER/$file_name" "$bucket_name" "$file_name/$file_name"
|
||||
assert_success
|
||||
|
||||
run list_check_single_object "$BUCKET_ONE_NAME" "$file_name/$file_name"
|
||||
run list_check_single_object "$bucket_name" "$file_name/$file_name"
|
||||
assert_success
|
||||
|
||||
run get_object_rest_special_chars "$BUCKET_ONE_NAME" "$file_name/$file_name" "$TEST_FILE_FOLDER/${file_name}-copy"
|
||||
run get_object_rest_special_chars "$bucket_name" "$file_name/$file_name" "$TEST_FILE_FOLDER/${file_name}-copy"
|
||||
assert_success
|
||||
|
||||
run compare_files "$TEST_FILE_FOLDER/$file_name" "$TEST_FILE_FOLDER/${file_name}-copy"
|
||||
assert_success
|
||||
|
||||
run delete_object_rest "$BUCKET_ONE_NAME" "$file_name/$file_name"
|
||||
run delete_object_rest "$bucket_name" "$file_name/$file_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - GetObject w/STREAMING-AWS4-HMAC-SHA256-PAYLOAD type" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run get_object_rest_with_invalid_streaming_type "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_object_rest_with_invalid_streaming_type "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ load ./bats-support/load
|
||||
load ./bats-assert/load
|
||||
|
||||
source ./tests/commands/put_object.sh
|
||||
source ./tests/drivers/file.sh
|
||||
source ./tests/drivers/create_bucket/create_bucket_rest.sh
|
||||
source ./tests/drivers/get_bucket_acl/get_bucket_acl_rest.sh
|
||||
source ./tests/logger.sh
|
||||
@@ -34,22 +35,30 @@ if [ "$SKIP_ACL_TESTING" == "true" ] || [ "$SKIP_USERS_TESTS" == "true" ]; then
|
||||
fi
|
||||
|
||||
@test "REST - get ACL" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run get_and_check_acl_rest "$BUCKET_ONE_NAME"
|
||||
run get_and_check_acl_rest "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - put ACL" {
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
test_file="test_file"
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred"
|
||||
run put_bucket_ownership_controls "$bucket_name" "BucketOwnerPreferred"
|
||||
assert_success
|
||||
|
||||
run put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE"
|
||||
@@ -62,29 +71,33 @@ fi
|
||||
run setup_acl "$TEST_FILE_FOLDER/acl-file.txt" "CanonicalUser" "$user_canonical_id" "READ" "$canonical_id"
|
||||
assert_success
|
||||
|
||||
run list_objects_with_user_rest_verify_access_denied "$BUCKET_ONE_NAME" "$username" "$password"
|
||||
run list_objects_with_user_rest_verify_access_denied "$bucket_name" "$username" "$password"
|
||||
assert_success
|
||||
|
||||
run put_bucket_acl_rest "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER/acl-file.txt"
|
||||
run put_bucket_acl_rest "$bucket_name" "$TEST_FILE_FOLDER/acl-file.txt"
|
||||
assert_success
|
||||
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
run list_objects_with_user_rest_verify_success "$BUCKET_ONE_NAME" "$username" "$password" "$test_file"
|
||||
run list_objects_with_user_rest_verify_success "$bucket_name" "$username" "$password" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - put public-read canned acl" {
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
test_file="test_file"
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred"
|
||||
run put_bucket_ownership_controls "$bucket_name" "BucketOwnerPreferred"
|
||||
assert_success
|
||||
|
||||
run put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE"
|
||||
@@ -94,25 +107,29 @@ fi
|
||||
username=${lines[2]}
|
||||
password=${lines[3]}
|
||||
|
||||
run list_objects_with_user_rest_verify_access_denied "$BUCKET_ONE_NAME" "$username" "$password"
|
||||
run list_objects_with_user_rest_verify_access_denied "$bucket_name" "$username" "$password"
|
||||
assert_success
|
||||
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
run allow_public_access "$BUCKET_ONE_NAME"
|
||||
run allow_public_access "$bucket_name"
|
||||
assert_success
|
||||
fi
|
||||
run put_canned_acl_rest "$BUCKET_ONE_NAME" "public-read"
|
||||
run put_canned_acl_rest "$bucket_name" "public-read"
|
||||
assert_success
|
||||
|
||||
run list_objects_with_user_rest_verify_success "$BUCKET_ONE_NAME" "$username" "$password" "$test_file"
|
||||
run list_objects_with_user_rest_verify_success "$bucket_name" "$username" "$password" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - put invalid ACL" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred"
|
||||
run put_bucket_ownership_controls "$bucket_name" "BucketOwnerPreferred"
|
||||
assert_success
|
||||
|
||||
run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE"
|
||||
@@ -126,19 +143,23 @@ fi
|
||||
assert_success
|
||||
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
run allow_public_access "$BUCKET_ONE_NAME"
|
||||
run allow_public_access "$bucket_name"
|
||||
assert_success
|
||||
fi
|
||||
run put_invalid_acl_rest_verify_failure "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER/acl-file.txt"
|
||||
run put_invalid_acl_rest_verify_failure "$bucket_name" "$TEST_FILE_FOLDER/acl-file.txt"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - put public-read-write canned acl" {
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
test_file="test_file"
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred"
|
||||
run put_bucket_ownership_controls "$bucket_name" "BucketOwnerPreferred"
|
||||
assert_success
|
||||
|
||||
run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE"
|
||||
@@ -148,17 +169,17 @@ fi
|
||||
username=${lines[2]}
|
||||
password=${lines[3]}
|
||||
|
||||
run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$username" "$password"
|
||||
run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$username" "$password"
|
||||
assert_failure
|
||||
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
run allow_public_access "$BUCKET_ONE_NAME"
|
||||
run allow_public_access "$bucket_name"
|
||||
assert_success
|
||||
fi
|
||||
run put_canned_acl_rest "$BUCKET_ONE_NAME" "public-read-write"
|
||||
run put_canned_acl_rest "$bucket_name" "public-read-write"
|
||||
assert_success
|
||||
|
||||
run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$username" "$password"
|
||||
run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$username" "$password"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -166,14 +187,18 @@ fi
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1367"
|
||||
fi
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
test_file="test_file"
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred"
|
||||
run put_bucket_ownership_controls "$bucket_name" "BucketOwnerPreferred"
|
||||
assert_success
|
||||
|
||||
run put_bucket_acl_rest_canned_invalid "$BUCKET_ONE_NAME" "privatee"
|
||||
run put_bucket_acl_rest_canned_invalid "$bucket_name" "privatee"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -181,6 +206,10 @@ fi
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1407"
|
||||
fi
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE"
|
||||
assert_success
|
||||
canonical_id=${lines[0]}
|
||||
@@ -188,7 +217,7 @@ fi
|
||||
username=${lines[2]}
|
||||
password=${lines[3]}
|
||||
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
run bucket_cleanup_if_bucket_exists "$bucket_name"
|
||||
assert_success
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
id="id=$user_canonical_id"
|
||||
@@ -197,9 +226,9 @@ fi
|
||||
fi
|
||||
|
||||
envs="GRANT_READ_ACP=$id OBJECT_OWNERSHIP=BucketOwnerPreferred"
|
||||
run create_bucket_rest_expect_success "$BUCKET_ONE_NAME" "$envs"
|
||||
run create_bucket_rest_expect_success "$bucket_name" "$envs"
|
||||
assert_success
|
||||
|
||||
run get_bucket_acl_rest "$BUCKET_ONE_NAME" "" "check_that_acl_xml_does_not_have_owner_permission"
|
||||
run get_bucket_acl_rest "$bucket_name" "" "check_that_acl_xml_does_not_have_owner_permission"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -37,23 +37,31 @@ source ./tests/util/util_tags.sh
|
||||
export RUN_USERS=true
|
||||
|
||||
@test "REST - HeadBucket" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run head_bucket_rest "$BUCKET_ONE_NAME"
|
||||
run head_bucket_rest "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - HeadBucket - doesn't exist" {
|
||||
run head_bucket_rest "$BUCKET_ONE_NAME"
|
||||
run head_bucket_rest "$BUCKET_ONE_NAME-$(uuidgen)"
|
||||
assert_failure 1
|
||||
}
|
||||
|
||||
@test "REST - bucket tagging - no tags" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run verify_no_bucket_tags_rest "$BUCKET_ONE_NAME"
|
||||
run verify_no_bucket_tags_rest "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -61,44 +69,54 @@ export RUN_USERS=true
|
||||
test_key="testKey"
|
||||
test_value="testValue"
|
||||
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run add_verify_bucket_tags_rest "$BUCKET_ONE_NAME" "$test_key" "$test_value"
|
||||
run add_verify_bucket_tags_rest "$bucket_name" "$test_key" "$test_value"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - get, put bucket ownership controls" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run get_and_check_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerEnforced"
|
||||
run get_and_check_ownership_controls "$bucket_name" "BucketOwnerEnforced"
|
||||
assert_success
|
||||
|
||||
run put_bucket_ownership_controls_rest "$BUCKET_ONE_NAME" "BucketOwnerPreferred"
|
||||
run put_bucket_ownership_controls_rest "$bucket_name" "BucketOwnerPreferred"
|
||||
assert_success
|
||||
|
||||
run get_and_check_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred"
|
||||
run get_and_check_ownership_controls "$bucket_name" "BucketOwnerPreferred"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "test_rest_set_get_lock_config" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run check_no_object_lock_config_rest "$BUCKET_ONE_NAME"
|
||||
run check_no_object_lock_config_rest "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_two_name="$output"
|
||||
|
||||
run setup_bucket_object_lock_enabled_v2 "$bucket_two_name"
|
||||
assert_success
|
||||
|
||||
# in static bucket config, bucket will still exist
|
||||
if ! bucket_exists "$BUCKET_ONE_NAME"; then
|
||||
run create_bucket_object_lock_enabled "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
fi
|
||||
|
||||
run check_object_lock_config_enabled_rest "$BUCKET_ONE_NAME"
|
||||
run check_object_lock_config_enabled_rest "$bucket_two_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -106,14 +124,18 @@ export RUN_USERS=true
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1300"
|
||||
fi
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run put_bucket_versioning_rest "$BUCKET_ONE_NAME" "Enabled"
|
||||
run put_bucket_versioning_rest "$bucket_name" "Enabled"
|
||||
assert_success
|
||||
|
||||
# this enables object lock without a specific retention policy
|
||||
run remove_retention_policy_rest "$BUCKET_ONE_NAME"
|
||||
run remove_retention_policy_rest "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -121,21 +143,15 @@ export RUN_USERS=true
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1301"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_object_lock_enabled_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
# in static bucket config, bucket will still exist
|
||||
if ! bucket_exists "$BUCKET_ONE_NAME"; then
|
||||
run create_bucket_object_lock_enabled "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
fi
|
||||
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
# this enables object lock without a specific retention policy
|
||||
run put_object_lock_config_without_content_md5 "$BUCKET_ONE_NAME"
|
||||
run put_object_lock_config_without_content_md5 "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -143,11 +159,14 @@ export RUN_USERS=true
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/959"
|
||||
fi
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run get_and_check_no_policy_error "$BUCKET_ONE_NAME"
|
||||
run get_and_check_no_policy_error "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -155,20 +174,24 @@ export RUN_USERS=true
|
||||
if [ "$SKIP_USERS_TESTS" == "true" ]; then
|
||||
skip
|
||||
fi
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run setup_user_versitygw_or_direct "$USERNAME_ONE" "$PASSWORD_ONE" "user" "$BUCKET_ONE_NAME"
|
||||
run setup_user_versitygw_or_direct "$USERNAME_ONE" "$PASSWORD_ONE" "user" "$bucket_name"
|
||||
assert_success
|
||||
log 5 "username: ${lines[1]}"
|
||||
log 5 "password: ${lines[2]}"
|
||||
|
||||
sleep 5
|
||||
|
||||
run setup_policy_with_single_statement "$TEST_FILE_FOLDER/policy_file.txt" "2012-10-17" "Allow" "$USERNAME_ONE" "s3:PutBucketTagging" "arn:aws:s3:::$BUCKET_ONE_NAME"
|
||||
run setup_policy_with_single_statement "$TEST_FILE_FOLDER/policy_file.txt" "2012-10-17" "Allow" "$USERNAME_ONE" "s3:PutBucketTagging" "arn:aws:s3:::$bucket_name"
|
||||
assert_success
|
||||
|
||||
run put_and_check_policy_rest "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER/policy_file.txt" "Allow" "$USERNAME_ONE" "s3:PutBucketTagging" "arn:aws:s3:::$BUCKET_ONE_NAME"
|
||||
run put_and_check_policy_rest "$bucket_name" "$TEST_FILE_FOLDER/policy_file.txt" "Allow" "$USERNAME_ONE" "s3:PutBucketTagging" "arn:aws:s3:::$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -184,18 +207,26 @@ export RUN_USERS=true
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1521"
|
||||
fi
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run send_rest_go_command_expect_error "400" "InvalidRequest" "Missing required header" "-bucketName" "$BUCKET_ONE_NAME" "-query" "tagging=" "-method" "PUT"
|
||||
run send_rest_go_command_expect_error "400" "InvalidRequest" "Missing required header" "-bucketName" "$bucket_name" "-query" "tagging=" "-method" "PUT"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - PutBucketTagging - invalid Content-MD5" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run send_rest_go_command_expect_error "400" "InvalidDigest" "you specified" "-bucketName" "$BUCKET_ONE_NAME" "-query" "tagging=" "-method" "PUT" "-signedParams" "Content-MD5:dummy" \
|
||||
run send_rest_go_command_expect_error "400" "InvalidDigest" "you specified" "-bucketName" "$bucket_name" "-query" "tagging=" "-method" "PUT" "-signedParams" "Content-MD5:dummy" \
|
||||
"-payload" "<Tagging xmlms=\\\"http://s3.amazonaws.com/doc/2006-03-01/\\\"><TagSet><Tag><Key>key</Key><Value>value</Value></Tag></TagSet></Tagging>"
|
||||
assert_success
|
||||
}
|
||||
@@ -204,10 +235,14 @@ export RUN_USERS=true
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1526"
|
||||
fi
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run send_put_bucket_tagging_command_check_invalid_content_md5 "$BUCKET_ONE_NAME"
|
||||
run send_put_bucket_tagging_command_check_invalid_content_md5 "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -215,10 +250,14 @@ export RUN_USERS=true
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1525"
|
||||
fi
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run send_rest_go_command_expect_error "400" "BadDigest" "did not match" "-bucketName" "$BUCKET_ONE_NAME" "-query" "tagging=" "-method" "PUT" "-incorrectContentMD5" \
|
||||
run send_rest_go_command_expect_error "400" "BadDigest" "did not match" "-bucketName" "$bucket_name" "-query" "tagging=" "-method" "PUT" "-incorrectContentMD5" \
|
||||
"-payload" "<Tagging xmlms=\\\"http://s3.amazonaws.com/doc/2006-03-01/\\\"><TagSet><Tag><Key>key</Key><Value>value</Value></Tag></TagSet></Tagging>"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
load ./bats-support/load
|
||||
load ./bats-assert/load
|
||||
|
||||
source ./tests/drivers/file.sh
|
||||
source ./tests/drivers/create_bucket/create_bucket_rest.sh
|
||||
source ./tests/setup.sh
|
||||
source ./tests/util/util_setup.sh
|
||||
|
||||
@@ -24,10 +26,14 @@ export RUN_USERS=true
|
||||
test_file="test_file"
|
||||
|
||||
@test "REST - invalid checksum type" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run check_invalid_checksum_type "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run check_invalid_checksum_type "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -47,13 +53,17 @@ test_file="test_file"
|
||||
}
|
||||
|
||||
@test "REST - HeadObject returns x-amz-checksum-sha256" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object_rest_checksum "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "sha256"
|
||||
run put_object_rest_checksum "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "sha256"
|
||||
assert_success
|
||||
|
||||
run check_checksum_rest_sha256 "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file"
|
||||
run check_checksum_rest_sha256 "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -73,13 +83,17 @@ test_file="test_file"
|
||||
}
|
||||
|
||||
@test "REST - crc32 checksum - HeadObject" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object_rest_checksum "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "crc32"
|
||||
run put_object_rest_checksum "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "crc32"
|
||||
assert_success
|
||||
|
||||
run check_checksum_rest_crc32 "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file"
|
||||
run check_checksum_rest_crc32 "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -129,23 +143,31 @@ test_file="test_file"
|
||||
}
|
||||
|
||||
@test "REST - attempt to get checksum without checksum mode" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run add_correct_checksum "sha256"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run head_object_without_and_with_checksum "$BUCKET_ONE_NAME" "$test_file"
|
||||
run head_object_without_and_with_checksum "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - HeadObject - default crc64nvme checksum" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run check_default_checksum "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file"
|
||||
run check_default_checksum "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -19,101 +19,131 @@ load ./bats-assert/load
|
||||
|
||||
source ./tests/logger.sh
|
||||
source ./tests/setup.sh
|
||||
source ./tests/drivers/file.sh
|
||||
source ./tests/drivers/create_bucket/create_bucket_rest.sh
|
||||
source ./tests/util/util_bucket.sh
|
||||
source ./tests/util/util_chunked_upload.sh
|
||||
source ./tests/util/util_file.sh
|
||||
source ./tests/util/util_setup.sh
|
||||
|
||||
@test "REST - chunked upload, no content length" {
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
test_file="test-file"
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run attempt_seed_signature_without_content_length "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run attempt_seed_signature_without_content_length "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - chunked upload, signature error" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
test_file="test-file"
|
||||
run create_test_file "$test_file" 8192
|
||||
assert_success
|
||||
|
||||
run attempt_chunked_upload_with_bad_first_signature "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run attempt_chunked_upload_with_bad_first_signature "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - chunked upload, final signature error" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
test_file="test-file"
|
||||
run create_test_file "$test_file" 0
|
||||
assert_success
|
||||
|
||||
run attempt_chunked_upload_with_bad_final_signature "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run attempt_chunked_upload_with_bad_final_signature "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - chunked upload, success (file with just a's)" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
test_file="test-file"
|
||||
run create_file_single_char "$test_file" 8192 'a'
|
||||
assert_success
|
||||
|
||||
run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$bucket_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"
|
||||
run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - chunked upload, success (null bytes)" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
test_file="test-file"
|
||||
run create_file_single_char "$test_file" 8192 '\0'
|
||||
assert_success
|
||||
|
||||
run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$bucket_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"
|
||||
run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - chunked upload, success (random bytes)" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
test_file="test-file"
|
||||
run create_test_file "$test_file" 10000
|
||||
assert_success
|
||||
|
||||
run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$bucket_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"
|
||||
run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - chunked upload, success (zero-byte file)" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
test_file="test-file"
|
||||
run create_test_file "$test_file" 0
|
||||
assert_success
|
||||
|
||||
run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run chunked_upload_success "$TEST_FILE_FOLDER/$test_file" "$bucket_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"
|
||||
run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -143,11 +173,15 @@ source ./tests/util/util_setup.sh
|
||||
}
|
||||
|
||||
@test "test - REST chunked upload - invalid trailer" {
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
test_file="test-file"
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run setup_bucket_and_file "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_chunked_upload_trailer_invalid "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_chunked_upload_trailer_invalid "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -202,16 +236,20 @@ source ./tests/util/util_setup.sh
|
||||
}
|
||||
|
||||
@test "REST chunked upload - smaller chunk size" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket "$bucket_name"
|
||||
assert_success
|
||||
|
||||
test_file="test-file"
|
||||
run create_test_file "$test_file" 200000
|
||||
assert_success
|
||||
|
||||
run chunked_upload_trailer_different_chunk_size "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "sha256"
|
||||
run chunked_upload_trailer_different_chunk_size "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "sha256"
|
||||
assert_success
|
||||
|
||||
run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"
|
||||
run download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -28,13 +28,14 @@ export RUN_USERS=true
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "skip bucket create tests for static buckets"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run create_bucket_rest "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
run list_check_buckets_rest "$BUCKET_ONE_NAME"
|
||||
run list_check_buckets_rest "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -45,11 +46,15 @@ export RUN_USERS=true
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "skip bucket create tests for static buckets"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run bucket_cleanup_if_bucket_exists_v2 "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
envs="ACL=public-reads OBJECT_OWNERSHIP=BucketOwnerPreferred"
|
||||
run create_bucket_rest_expect_error "$BUCKET_ONE_NAME" "$envs" "400" "InvalidArgument" ""
|
||||
run create_bucket_rest_expect_error "$bucket_name" "$envs" "400" "InvalidArgument" ""
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -77,7 +82,7 @@ export RUN_USERS=true
|
||||
if [ "$RECREATE_BUCKETS" == "false" ]; then
|
||||
skip "skip bucket create tests for static buckets"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
run bucket_cleanup_if_bucket_exists_v2 "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
|
||||
if [ "$DIRECT" == "true" ]; then
|
||||
@@ -86,7 +91,12 @@ export RUN_USERS=true
|
||||
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"
|
||||
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run create_bucket_rest_expect_error "$bucket_name" "$envs" "400" "InvalidBucketAclWithObjectOwnership" "Bucket cannot have ACLs set"
|
||||
assert_success
|
||||
}
|
||||
|
||||
|
||||
@@ -18,54 +18,67 @@ load ./bats-support/load
|
||||
load ./bats-assert/load
|
||||
|
||||
source ./tests/setup.sh
|
||||
source ./tests/drivers/create_bucket/create_bucket_rest.sh
|
||||
source ./tests/drivers/delete_object/delete_object_rest.sh
|
||||
source ./tests/drivers/put_object/put_object_rest.sh
|
||||
|
||||
@test "REST - DeleteBucket - can delete with partial multipart upload" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run create_multipart_upload_rest "$BUCKET_ONE_NAME" "test_file" ""
|
||||
run create_multipart_upload_rest "$bucket_name" "test_file" "" ""
|
||||
assert_success
|
||||
|
||||
run delete_bucket_rest "$BUCKET_ONE_NAME"
|
||||
run delete_bucket_rest "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - DeleteBucket - file - non-versioning" {
|
||||
run setup_bucket_and_add_file "$BUCKET_ONE_NAME" "test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_add_file "$bucket_name" "test_file"
|
||||
assert_success
|
||||
|
||||
run delete_bucket_rest_expect_error "$BUCKET_ONE_NAME" "" "409" "BucketNotEmpty" "is not empty"
|
||||
run delete_bucket_rest_expect_error "$bucket_name" "" "409" "BucketNotEmpty" "is not empty"
|
||||
assert_success
|
||||
|
||||
run delete_object_rest "$BUCKET_ONE_NAME" "test_file"
|
||||
run delete_object_rest "$bucket_name" "test_file"
|
||||
assert_success
|
||||
|
||||
run delete_bucket_rest "$BUCKET_ONE_NAME"
|
||||
run delete_bucket_rest "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - DeleteBucket - file - versioning" {
|
||||
run setup_bucket_and_add_file "$BUCKET_ONE_NAME" "test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_add_file "$bucket_name" "test_file"
|
||||
assert_success
|
||||
|
||||
run put_bucket_versioning_rest "$BUCKET_ONE_NAME" "Enabled"
|
||||
run put_bucket_versioning_rest "$bucket_name" "Enabled"
|
||||
assert_success
|
||||
|
||||
run delete_bucket_rest_expect_error "$BUCKET_ONE_NAME" "" "409" "BucketNotEmpty" "is not empty"
|
||||
run delete_bucket_rest_expect_error "$bucket_name" "" "409" "BucketNotEmpty" "is not empty"
|
||||
assert_success
|
||||
|
||||
run delete_object_rest "$BUCKET_ONE_NAME" "test_file"
|
||||
run delete_object_rest "$bucket_name" "test_file"
|
||||
assert_success
|
||||
|
||||
run delete_bucket_rest_expect_error "$BUCKET_ONE_NAME" "" "409" "BucketNotEmpty" "is not empty"
|
||||
run delete_bucket_rest_expect_error "$bucket_name" "" "409" "BucketNotEmpty" "is not empty"
|
||||
assert_success
|
||||
|
||||
run delete_old_versions "$BUCKET_ONE_NAME"
|
||||
run delete_old_versions_base64 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run delete_bucket_rest "$BUCKET_ONE_NAME"
|
||||
run delete_bucket_rest "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -73,10 +86,14 @@ source ./tests/drivers/put_object/put_object_rest.sh
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1428"
|
||||
fi
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run send_rest_go_command_expect_error "400" "InvalidBucketOwnerAWSAccountID" "value of the expected bucket owner" "-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-signedParams" "x-amz-expected-bucket-owner:01234567890"
|
||||
run send_rest_go_command_expect_error "400" "InvalidBucketOwnerAWSAccountID" "value of the expected bucket owner" "-method" "DELETE" "-bucketName" "$bucket_name" "-signedParams" "x-amz-expected-bucket-owner:01234567890"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -84,17 +101,25 @@ source ./tests/drivers/put_object/put_object_rest.sh
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1428"
|
||||
fi
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run send_rest_go_command_expect_error "403" "AccessDenied" "Access Denied" "-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-signedParams" "x-amz-expected-bucket-owner:012345678901"
|
||||
run send_rest_go_command_expect_error "403" "AccessDenied" "Access Denied" "-method" "DELETE" "-bucketName" "$bucket_name" "-signedParams" "x-amz-expected-bucket-owner:012345678901"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - DeleteBucket - correct x-amz-expected-bucket-owner" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run send_rest_go_command "204" "-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-signedParams" "x-amz-expected-bucket-owner:$AWS_USER_ID"
|
||||
run send_rest_go_command "204" "-method" "DELETE" "-bucketName" "$bucket_name" "-signedParams" "x-amz-expected-bucket-owner:$AWS_USER_ID"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
load ./bats-support/load
|
||||
load ./bats-assert/load
|
||||
|
||||
source ./tests/drivers/create_bucket/create_bucket_rest.sh
|
||||
source ./tests/drivers/get_bucket_ownership_controls/get_bucket_ownership_controls_rest.sh
|
||||
source ./tests/drivers/user.sh
|
||||
source ./tests/setup.sh
|
||||
@@ -27,14 +28,19 @@ export RUN_USERS=true
|
||||
if [ "$SKIP_USERS_TESTS" == "true" ]; then
|
||||
skip
|
||||
fi
|
||||
run setup_bucket_and_user_v2 "$BUCKET_ONE_NAME" "$USERNAME_ONE" "$PASSWORD_ONE"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
username=${lines[2]}
|
||||
password=${lines[3]}
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_user_v2 "$bucket_name" "$USERNAME_ONE" "$PASSWORD_ONE"
|
||||
assert_success
|
||||
username=${lines[${#lines[@]}-2]}
|
||||
password=${lines[${#lines[@]}-1]}
|
||||
log 5 "output: $output"
|
||||
log 5 "username: $username, password: $password"
|
||||
|
||||
run send_rest_go_command_expect_error "403" "AccessDenied" "Access Denied" "-awsAccessKeyId" "$username" "-awsSecretAccessKey" "$password" \
|
||||
"-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-query" "ownershipControls="
|
||||
"-method" "DELETE" "-bucketName" "$bucket_name" "-query" "ownershipControls="
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -42,33 +48,41 @@ export RUN_USERS=true
|
||||
if [ "$SKIP_USERS_TESTS" == "true" ]; then
|
||||
skip
|
||||
fi
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
username="invalid with spaces"
|
||||
password="dummy"
|
||||
|
||||
run send_rest_go_command_expect_error "403" "InvalidAccessKeyId" "does not exist in our records" "-awsAccessKeyId" "$username" "-awsSecretAccessKey" "$password" \
|
||||
"-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-query" "ownershipControls="
|
||||
"-method" "DELETE" "-bucketName" "$bucket_name" "-query" "ownershipControls="
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "REST - DeleteBucketOwnershipControls - success" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run put_bucket_ownership_controls_rest "$BUCKET_ONE_NAME" "BucketOwnerPreferred"
|
||||
run put_bucket_ownership_controls_rest "$bucket_name" "BucketOwnerPreferred"
|
||||
assert_success
|
||||
|
||||
run get_bucket_ownership_controls_rest "$BUCKET_ONE_NAME"
|
||||
run get_bucket_ownership_controls_rest "$bucket_name"
|
||||
assert_success
|
||||
rule=${output[${#output[@]}-1]}
|
||||
assert_equal "$rule" "BucketOwnerPreferred"
|
||||
|
||||
run send_rest_go_command "204" "-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-query" "ownershipControls="
|
||||
run send_rest_go_command "204" "-method" "DELETE" "-bucketName" "$bucket_name" "-query" "ownershipControls="
|
||||
assert_success
|
||||
|
||||
run get_bucket_ownership_controls_rest "$BUCKET_ONE_NAME"
|
||||
run get_bucket_ownership_controls_rest "$bucket_name"
|
||||
assert_success
|
||||
rule=${output[${#output[@]}-1]}
|
||||
assert_equal "$rule" ""
|
||||
@@ -78,15 +92,19 @@ export RUN_USERS=true
|
||||
if [ "$DIRECT" != "true" ]; then
|
||||
skip "https://github.com/versity/versitygw/issues/1493"
|
||||
fi
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket "$bucket_name"
|
||||
assert_success
|
||||
|
||||
if ! send_rest_go_command "204" \
|
||||
"-method" "DELETE" "-bucketName" "$BUCKET_ONE_NAME" "-query" "ownershipControls="; then
|
||||
"-method" "DELETE" "-bucketName" "$bucket_name" "-query" "ownershipControls="; then
|
||||
log 2 "error deleting ownership controls"
|
||||
return 1
|
||||
fi
|
||||
|
||||
run get_bucket_ownership_controls_check_error_after_deletion "$BUCKET_ONE_NAME"
|
||||
run get_bucket_ownership_controls_check_error_after_deletion "$bucket_name"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ load ./bats-assert/load
|
||||
source ./tests/setup.sh
|
||||
source ./tests/drivers/rest.sh
|
||||
source ./tests/drivers/complete_multipart_upload/complete_multipart_upload_rest.sh
|
||||
source ./tests/drivers/list_buckets/list_buckets_rest.sh
|
||||
source ./tests/drivers/upload_part/upload_part_rest.sh
|
||||
source ./tests/util/util_file.sh
|
||||
source ./tests/util/util_list_parts.sh
|
||||
|
||||
@@ -20,87 +20,103 @@ load ./bats-assert/load
|
||||
source ./tests/setup.sh
|
||||
source ./tests/commands/get_object.sh
|
||||
source ./tests/commands/put_object.sh
|
||||
source ./tests/drivers/create_bucket/create_bucket_rest.sh
|
||||
source ./tests/drivers/list_buckets/list_buckets_rest.sh
|
||||
source ./tests/util/util_rest.sh
|
||||
source ./tests/util/util_setup.sh
|
||||
|
||||
test_file="test_file"
|
||||
|
||||
@test "REST - check, enable, suspend versioning" {
|
||||
run setup_bucket "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
log 5 "get versioning"
|
||||
|
||||
run check_versioning_status_rest "$BUCKET_ONE_NAME" ""
|
||||
run check_versioning_status_rest "$bucket_name" ""
|
||||
assert_success
|
||||
|
||||
run put_bucket_versioning_rest "$BUCKET_ONE_NAME" "Enabled"
|
||||
run put_bucket_versioning_rest "$bucket_name" "Enabled"
|
||||
assert_success
|
||||
|
||||
run check_versioning_status_rest "$BUCKET_ONE_NAME" "Enabled"
|
||||
run check_versioning_status_rest "$bucket_name" "Enabled"
|
||||
assert_success
|
||||
|
||||
run put_bucket_versioning_rest "$BUCKET_ONE_NAME" "Suspended"
|
||||
run put_bucket_versioning_rest "$bucket_name" "Suspended"
|
||||
assert_success
|
||||
|
||||
run check_versioning_status_rest "$BUCKET_ONE_NAME" "Suspended"
|
||||
run check_versioning_status_rest "$bucket_name" "Suspended"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "test_rest_versioning" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run get_and_check_versions_rest "$BUCKET_ONE_NAME" "$test_file" "1" "true" "true"
|
||||
run get_and_check_versions_rest "$bucket_name" "$test_file" "1" "true" "true"
|
||||
assert_success
|
||||
|
||||
run put_bucket_versioning "s3api" "$BUCKET_ONE_NAME" "Enabled"
|
||||
run put_bucket_versioning_rest "$bucket_name" "Enabled"
|
||||
assert_success
|
||||
|
||||
run get_and_check_versions_rest "$BUCKET_ONE_NAME" "$test_file" "1" "true" "true"
|
||||
run get_and_check_versions_rest "$bucket_name" "$test_file" "1" "true" "true"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run get_and_check_versions_rest "$BUCKET_ONE_NAME" "$test_file" "2" "true" "false" "false" "true"
|
||||
run get_and_check_versions_rest "$bucket_name" "$test_file" "2" "true" "false" "false" "true"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "versioning - add version, then delete and check for marker" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_bucket_versioning "s3api" "$BUCKET_ONE_NAME" "Enabled"
|
||||
run put_bucket_versioning_rest "$bucket_name" "Enabled"
|
||||
assert_success
|
||||
|
||||
run delete_object_rest "$BUCKET_ONE_NAME" "$test_file"
|
||||
run delete_object_rest "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run check_versions_after_file_deletion "$BUCKET_ONE_NAME" "$test_file"
|
||||
run check_versions_after_file_deletion "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "versioning - retrieve after delete" {
|
||||
run setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
run setup_bucket_and_file_v2 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_bucket_versioning "s3api" "$BUCKET_ONE_NAME" "Enabled"
|
||||
run put_bucket_versioning_rest "$bucket_name" "Enabled"
|
||||
assert_success
|
||||
|
||||
run delete_object "s3api" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run delete_object "s3api" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run get_object "s3api" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"
|
||||
run get_object "s3api" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@@ -108,25 +124,23 @@ test_file="test_file"
|
||||
if [ "$RECREATE_BUCKETS" == "false" ] || [[ ( -z "$VERSIONING_DIR" ) && ( "$DIRECT" != "true" ) ]]; then
|
||||
skip "test isn't valid for this configuration"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
# in static bucket config, bucket will still exist
|
||||
if ! bucket_exists "$BUCKET_ONE_NAME"; then
|
||||
run create_bucket_object_lock_enabled "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
fi
|
||||
run setup_bucket_object_lock_enabled_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run create_test_files "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run delete_object "s3api" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run delete_object "s3api" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run verify_object_not_found "$BUCKET_ONE_NAME" "$test_file"
|
||||
run verify_object_not_found "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -134,24 +148,22 @@ test_file="test_file"
|
||||
if [ "$RECREATE_BUCKETS" == "false" ] || [[ ( -z "$VERSIONING_DIR" ) && ( "$DIRECT" != "true" ) ]]; then
|
||||
skip "test isn't valid for this configuration"
|
||||
fi
|
||||
run bucket_cleanup_if_bucket_exists "$BUCKET_ONE_NAME"
|
||||
run get_bucket_name "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
bucket_name="$output"
|
||||
|
||||
# in static bucket config, bucket will still exist
|
||||
if ! bucket_exists "$BUCKET_ONE_NAME"; then
|
||||
run create_bucket_object_lock_enabled "$BUCKET_ONE_NAME"
|
||||
assert_success
|
||||
fi
|
||||
run setup_bucket_object_lock_enabled_v2 "$bucket_name"
|
||||
assert_success
|
||||
|
||||
run create_test_files "$test_file"
|
||||
assert_success
|
||||
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run put_object "rest" "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run delete_object "s3api" "$BUCKET_ONE_NAME" "$test_file"
|
||||
run delete_object "s3api" "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
|
||||
run get_delete_marker_and_verify_405 "$BUCKET_ONE_NAME" "$test_file"
|
||||
run get_delete_marker_and_verify_405 "$bucket_name" "$test_file"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ source ./tests/commands/put_object_retention.sh
|
||||
source ./tests/commands/put_public_access_block.sh
|
||||
source ./tests/commands/select_object_content.sh
|
||||
source ./tests/drivers/copy_object/copy_object_rest.sh
|
||||
source ./tests/drivers/list_buckets/list_buckets_rest.sh
|
||||
|
||||
export RUN_USERS=true
|
||||
|
||||
|
||||
57
tests/test_setup_remove_static.sh
Executable file
57
tests/test_setup_remove_static.sh
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# 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.
|
||||
|
||||
source ./tests/logger.sh
|
||||
|
||||
if [ -z "$VERSITYGW_TEST_ENV" ]; then
|
||||
echo "VERSITYGW_TEST_ENV variable missing"
|
||||
return 1
|
||||
fi
|
||||
# shellcheck disable=SC1090
|
||||
source "$VERSITYGW_TEST_ENV"
|
||||
if [ "$RECREATE_BUCKETS" != "true" ] || [ "$DELETE_BUCKETS_AFTER_TEST" != "true" ]; then
|
||||
echo "for this test 'RECREATE_BUCKETS' and 'DELETE_BUCKETS_AFTER_TEST' must be set to true"
|
||||
exit 1
|
||||
fi
|
||||
# try to remove buckets if already there, don't worry if they're not
|
||||
./tests/remove_static.sh
|
||||
echo "AFTER FIRST REMOVAL"
|
||||
if ! result=$(./tests/setup_static.sh 2>&1); then
|
||||
echo "error setting up buckets: $result"
|
||||
exit 1
|
||||
fi
|
||||
echo "RESULT: $result"
|
||||
if [[ "$result" != *"bucket '$BUCKET_ONE_NAME' successfully created"* ]]; then
|
||||
echo "error creating bucket '$BUCKET_ONE_NAME'"
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$result" != *"bucket '$BUCKET_TWO_NAME' successfully created"* ]]; then
|
||||
echo "error creating bucket '$BUCKET_TWO_NAME'"
|
||||
exit 1
|
||||
fi
|
||||
if ! result=$(./tests/remove_static.sh 2>&1); then
|
||||
echo "error removing buckets: $result"
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$result" != *"bucket '$BUCKET_ONE_NAME' successfully deleted"* ]]; then
|
||||
echo "error deleting bucket '$BUCKET_ONE_NAME'"
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$result" != *"bucket '$BUCKET_TWO_NAME' successfully deleted"* ]]; then
|
||||
echo "error deleting bucket '$BUCKET_TWO_NAME'"
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
@@ -16,6 +16,7 @@ reset_bucket() {
|
||||
if ! check_param_count "reset_bucket" "bucket" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
log 6 "reset bucket '$1'"
|
||||
|
||||
if [[ $LOG_LEVEL_INT -ge 5 ]] && ! log_bucket_policy "$1"; then
|
||||
log 3 "error logging bucket policy"
|
||||
@@ -63,26 +64,6 @@ reset_bucket() {
|
||||
fi
|
||||
}
|
||||
|
||||
# params: bucket name
|
||||
# return 0 if able to delete recursively, 1 if not
|
||||
delete_bucket_recursive() {
|
||||
log 6 "delete_bucket_recursive_s3api"
|
||||
if ! check_param_count "delete_bucket_recursive_s3api" "bucket" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! reset_bucket "$1"; then
|
||||
log 2 "error clearing bucket (s3api)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! delete_bucket_rest "$1"; then
|
||||
log 2 "error deleting bucket"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# check if bucket exists
|
||||
# param: bucket name
|
||||
# return 0 for true, 1 for false, 2 for error
|
||||
@@ -104,70 +85,6 @@ bucket_exists() {
|
||||
return 1
|
||||
}
|
||||
|
||||
direct_wait_for_bucket() {
|
||||
if ! check_param_count "direct_wait_for_bucket" "bucket" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
bucket_verification_start_time=$(date +%s)
|
||||
while ! bucket_exists "$1"; do
|
||||
bucket_verification_end_time=$(date +%s)
|
||||
if [ $((bucket_verification_end_time-bucket_verification_start_time)) -ge 60 ]; then
|
||||
log 2 "bucket existence check timeout"
|
||||
return 1
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
# params: client, bucket name
|
||||
# return 0 for success, 1 for error
|
||||
bucket_cleanup() {
|
||||
log 6 "bucket_cleanup"
|
||||
if ! check_param_count "bucket_cleanup" "bucket name" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
if [[ $RECREATE_BUCKETS == "false" ]]; then
|
||||
if ! reset_bucket "$1"; then
|
||||
log 2 "error deleting bucket contents"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log 5 "bucket contents, policy, ACL deletion success"
|
||||
return 0
|
||||
fi
|
||||
if ! delete_bucket_recursive "$1"; then
|
||||
log 2 "error with recursive bucket delete"
|
||||
return 1
|
||||
fi
|
||||
log 5 "bucket deletion success"
|
||||
return 0
|
||||
}
|
||||
|
||||
# params: client, bucket name
|
||||
# return 0 for success, 1 for error
|
||||
bucket_cleanup_if_bucket_exists() {
|
||||
log 6 "bucket_cleanup_if_bucket_exists"
|
||||
if ! check_param_count_gt "bucket name, bucket known to exist (optional)" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$2" == "false" ]; then
|
||||
log 5 "skipping cleanup, since bucket doesn't exist"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "$2" == "true" ] || bucket_exists "$1"; then
|
||||
if ! bucket_cleanup "$1"; then
|
||||
log 2 "error deleting bucket and/or contents"
|
||||
return 1
|
||||
fi
|
||||
log 5 "bucket and/or bucket data deletion success"
|
||||
return 0
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# params: client, bucket name(s)
|
||||
# return 0 for success, 1 for failure
|
||||
setup_buckets() {
|
||||
@@ -215,11 +132,6 @@ setup_bucket() {
|
||||
log 5 "skipping bucket re-creation"
|
||||
fi
|
||||
|
||||
# bucket creation and resets take longer to propagate in direct mode
|
||||
if [ "$DIRECT" == "true" ] && ! direct_wait_for_bucket "$1"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ $1 == "s3cmd" ]]; then
|
||||
log 5 "putting bucket ownership controls"
|
||||
if bucket_exists "$1" && ! put_bucket_ownership_controls "$1" "BucketOwnerPreferred"; then
|
||||
|
||||
@@ -44,28 +44,31 @@ attempt_chunked_upload_with_bad_first_signature() {
|
||||
log 2 "error sending command via openssl"
|
||||
return 1
|
||||
fi
|
||||
response_code="$(echo "$result" | grep "HTTP" | awk '{print $2}')"
|
||||
log 5 "response code: $response_code"
|
||||
if [ "$response_code" != "403" ]; then
|
||||
log 2 "expected code '403', was '$response_code'"
|
||||
return 1
|
||||
fi
|
||||
log 5 "result: $result"
|
||||
response_data="$(echo "$result" | grep "<Error>")"
|
||||
response_data="${response_data/---/}"
|
||||
log 5 "response data: $response_data"
|
||||
log 5 "END"
|
||||
echo -n "$response_data" > "$TEST_FILE_FOLDER/response_data.txt"
|
||||
if ! check_xml_element "$TEST_FILE_FOLDER/response_data.txt" "SignatureDoesNotMatch" "Error" "Code"; then
|
||||
log 2 "error checking XML element"
|
||||
echo -n "$result" > "$TEST_FILE_FOLDER/result.txt"
|
||||
if ! get_xml_data "$TEST_FILE_FOLDER/result.txt" "$TEST_FILE_FOLDER/error_data.txt"; then
|
||||
log 2 "error parsing XML data from result"
|
||||
return 1
|
||||
fi
|
||||
response_code="$(echo "$result" | grep "HTTP" | awk '{print $2}')"
|
||||
if ! check_rest_expected_error "$response_code" "$TEST_FILE_FOLDER/error_data.txt" "403" "SignatureDoesNotMatch" "does not match"; then
|
||||
log 2 "error checking expected REST error"
|
||||
return 1
|
||||
fi
|
||||
#response_data="$(echo "$result" | grep "<Error>")"
|
||||
#response_data="${response_data/---/}"
|
||||
#log 5 "response data: $response_data"
|
||||
#log 5 "END"
|
||||
#echo -n "$response_data" > "$TEST_FILE_FOLDER/response_data.txt"
|
||||
#if ! check_xml_element "$TEST_FILE_FOLDER/response_data.txt" "SignatureDoesNotMatch" "Error" "Code"; then
|
||||
# log 2 "error checking XML element"
|
||||
# return 1
|
||||
#fi
|
||||
return 0
|
||||
}
|
||||
|
||||
chunked_upload_success() {
|
||||
if [ $# -ne 3 ]; then
|
||||
log 2 "'chunked_upload_success_as' requires data file, bucket name, key"
|
||||
if ! check_param_count_v2 "data file, bucket name, key" 3 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" \
|
||||
@@ -191,7 +194,11 @@ chunked_upload_trailer_success() {
|
||||
log 2 "'chunked_upload_trailer_success' requires checksum"
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket "$BUCKET_ONE_NAME"; then
|
||||
if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then
|
||||
log 2 "error getting bucket name: $bucket_name"
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket "$bucket_name"; then
|
||||
log 2 "error setting up bucket"
|
||||
return 1
|
||||
fi
|
||||
@@ -200,11 +207,11 @@ chunked_upload_trailer_success() {
|
||||
log 2 "error creating test file"
|
||||
return 1
|
||||
fi
|
||||
if ! put_object_chunked_trailer_success "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$1"; then
|
||||
if ! put_object_chunked_trailer_success "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$1"; then
|
||||
log 2 "error performing chunked upload w/trailer"
|
||||
return 1
|
||||
fi
|
||||
if ! download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"; then
|
||||
if ! download_and_compare_file "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"; then
|
||||
log 2 "error downloading and comparing file"
|
||||
return 1
|
||||
fi
|
||||
@@ -216,7 +223,11 @@ chunked_upload_trailer_invalid_checksum() {
|
||||
log 2 "'chunked_upload_trailer_invalid_checksum' requires checksum"
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket "$BUCKET_ONE_NAME"; then
|
||||
if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then
|
||||
log 2 "error getting bucket name: $bucket_name"
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket "$bucket_name"; then
|
||||
log 2 "error setting up bucket"
|
||||
return 1
|
||||
fi
|
||||
@@ -231,7 +242,7 @@ chunked_upload_trailer_invalid_checksum() {
|
||||
AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \
|
||||
AWS_ENDPOINT_URL="$AWS_ENDPOINT_URL" \
|
||||
DATA_FILE="$TEST_FILE_FOLDER/$test_file" \
|
||||
BUCKET_NAME="$BUCKET_ONE_NAME" \
|
||||
BUCKET_NAME="$bucket_name" \
|
||||
OBJECT_KEY="$test_file" CHUNK_SIZE=8192 TEST_MODE=false TRAILER="x-amz-checksum-$1" CHECKSUM="a" TEST_FILE_FOLDER="$TEST_FILE_FOLDER" COMMAND_FILE="$TEST_FILE_FOLDER/command.txt" ./tests/rest_scripts/put_object_openssl_chunked_trailer_example.sh 2>&1); then
|
||||
log 2 "error creating command: $result"
|
||||
return 1
|
||||
@@ -248,7 +259,11 @@ chunked_upload_trailer_incorrect_checksum() {
|
||||
log 2 "'chunked_upload_trailer_invalid_checksum' requires checksum"
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket "$BUCKET_ONE_NAME"; then
|
||||
if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then
|
||||
log 2 "error getting bucket name: $bucket_name"
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket "$bucket_name"; then
|
||||
log 2 "error setting up bucket"
|
||||
return 1
|
||||
fi
|
||||
@@ -267,7 +282,7 @@ chunked_upload_trailer_incorrect_checksum() {
|
||||
AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \
|
||||
AWS_ENDPOINT_URL="$AWS_ENDPOINT_URL" \
|
||||
DATA_FILE="$TEST_FILE_FOLDER/$test_file" \
|
||||
BUCKET_NAME="$BUCKET_ONE_NAME" \
|
||||
BUCKET_NAME="$bucket_name" \
|
||||
OBJECT_KEY="$test_file" CHUNK_SIZE=8192 TEST_MODE=false TRAILER="x-amz-checksum-$1" CHECKSUM="$checksum" TEST_FILE_FOLDER="$TEST_FILE_FOLDER" COMMAND_FILE="$TEST_FILE_FOLDER/command.txt" ./tests/rest_scripts/put_object_openssl_chunked_trailer_example.sh 2>&1); then
|
||||
log 2 "error creating command: $result"
|
||||
return 1
|
||||
|
||||
@@ -37,7 +37,7 @@ get_and_check_legal_hold() {
|
||||
}
|
||||
|
||||
check_legal_hold_without_lock_enabled() {
|
||||
if ! check_param_count "check_legal_hold_without_lock_enabled" "bucket, key" 2 $#; then
|
||||
if ! check_param_count_v2 "bucket, key, expected error" 3 $#; then
|
||||
return 1
|
||||
fi
|
||||
if get_object_legal_hold_rest "$1" "$2"; then
|
||||
@@ -49,8 +49,8 @@ check_legal_hold_without_lock_enabled() {
|
||||
log 2 "error getting error code: $code"
|
||||
return 1
|
||||
fi
|
||||
if [ "$code" != "InvalidRequest" ]; then
|
||||
log 2 "code mismatch (expected 'InvalidRequest', actual '$code')"
|
||||
if [ "$code" != "$3" ]; then
|
||||
log 2 "code mismatch (expected '$3', actual '$code')"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
@@ -62,7 +62,8 @@ check_remove_legal_hold_versions() {
|
||||
fi
|
||||
if ! get_object_legal_hold_rest_version_id "$1" "$2" "$3"; then
|
||||
# shellcheck disable=SC2154
|
||||
if [[ "$legal_hold" != *"MethodNotAllowed"* ]]; then
|
||||
log 5 "legal hold: $legal_hold"
|
||||
if [[ "$legal_hold" != *"MethodNotAllowed"* ]] && [[ "$legal_hold" != *"NoSuchObjectLockConfiguration"* ]]; then
|
||||
log 2 "error getting object legal hold status with version id"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -350,7 +350,7 @@ get_delete_marker_and_verify_405() {
|
||||
fi
|
||||
log 5 "xml val: $version_id"
|
||||
|
||||
if ! result=$(OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$BUCKET_ONE_NAME" OBJECT_KEY="$2" VERSION_ID="$version_id" ./tests/rest_scripts/head_object.sh); then
|
||||
if ! result=$(OUTPUT_FILE="$TEST_FILE_FOLDER/result.txt" COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OBJECT_KEY="$2" VERSION_ID="$version_id" ./tests/rest_scripts/head_object.sh); then
|
||||
log 2 "error getting result: $result"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -64,7 +64,7 @@ check_part_list_rest() {
|
||||
|
||||
perform_multipart_upload_rest() {
|
||||
if [ $# -ne 6 ]; then
|
||||
log 2 "'upload_check_parts' requires bucket, key, part list"
|
||||
log 2 "'upload_check_parts' requires bucket, key, part list (4 parts)"
|
||||
return 1
|
||||
fi
|
||||
if ! create_multipart_upload_rest "$1" "$2" "" "parse_upload_id"; then
|
||||
@@ -93,7 +93,7 @@ perform_multipart_upload_rest() {
|
||||
return 1
|
||||
fi
|
||||
parts_payload+="<Part><ETag>$etag</ETag><PartNumber>4</PartNumber></Part>"
|
||||
if ! complete_multipart_upload_rest "$1" "$2" "$3" "$4"; then
|
||||
if ! complete_multipart_upload_rest "$1" "$2" "$upload_id" "$parts_payload"; then
|
||||
log 2 "error completing multipart upload"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -264,12 +264,18 @@ check_checksum_rest_invalid() {
|
||||
if ! check_param_count "check_checksum_rest_invalid" "checksum type" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then
|
||||
log 2 "error getting bucket name: $bucket_name"
|
||||
return 1
|
||||
fi
|
||||
|
||||
test_file="test_file"
|
||||
if ! setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"; then
|
||||
if ! setup_bucket_and_file_v2 "$bucket_name" "$test_file"; then
|
||||
log 2 "error setting up bucket and file"
|
||||
return 1
|
||||
fi
|
||||
if ! check_checksum_invalid_or_incorrect "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$1" "dummy" "Value for x-amz-checksum-$1 header is invalid."; then
|
||||
if ! check_checksum_invalid_or_incorrect "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$1" "dummy" "Value for x-amz-checksum-$1 header is invalid."; then
|
||||
log 2 "error checking checksum"
|
||||
return 1
|
||||
fi
|
||||
@@ -280,8 +286,14 @@ check_checksum_rest_incorrect() {
|
||||
if ! check_param_count "check_checksum_rest_incorrect" "checksum type" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then
|
||||
log 2 "error getting bucket name: $bucket_name"
|
||||
return 1
|
||||
fi
|
||||
|
||||
test_file="test_file"
|
||||
if ! setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"; then
|
||||
if ! setup_bucket_and_file "$bucket_name" "$test_file"; then
|
||||
log 2 "error setting up bucket and file"
|
||||
return 1
|
||||
fi
|
||||
@@ -291,7 +303,7 @@ check_checksum_rest_incorrect() {
|
||||
log 2 "error calculating incorrect checksum"
|
||||
return 1
|
||||
fi
|
||||
if ! check_checksum_invalid_or_incorrect "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$1" "$incorrect_checksum" "$error_message"; then
|
||||
if ! check_checksum_invalid_or_incorrect "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$1" "$incorrect_checksum" "$error_message"; then
|
||||
log 2 "error checking checksum"
|
||||
return 1
|
||||
fi
|
||||
@@ -302,6 +314,7 @@ calculate_incorrect_checksum() {
|
||||
if ! check_param_count "calculate_incorrect_checksum" "checksum type, data file" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! checksum=$(DATA_FILE="$2" CHECKSUM_TYPE="$1" TEST_FILE_FOLDER="$TEST_FILE_FOLDER" ./tests/rest_scripts/calculate_checksum.sh 2>&1); then
|
||||
log 2 "error calculating checksum: $checksum"
|
||||
return 1
|
||||
@@ -334,13 +347,18 @@ add_correct_checksum() {
|
||||
if ! check_param_count "add_correct_checksum" "checksum type" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! bucket_name=$(get_bucket_name "$BUCKET_ONE_NAME" 2>&1); then
|
||||
log 2 "error getting bucket name: $bucket_name"
|
||||
return 1
|
||||
fi
|
||||
|
||||
test_file="test_file"
|
||||
if ! setup_bucket_and_file "$BUCKET_ONE_NAME" "$test_file"; then
|
||||
if ! setup_bucket_and_file "$bucket_name" "$test_file"; then
|
||||
log 2 "error setting up bucket and file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! put_object_rest_checksum "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$1"; then
|
||||
if ! put_object_rest_checksum "$TEST_FILE_FOLDER/$test_file" "$bucket_name" "$test_file" "$1"; then
|
||||
log 2 "error adding file with checksum to s3"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -1,48 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./tests/drivers/params.sh
|
||||
|
||||
setup_bucket_and_file() {
|
||||
if ! check_param_count "setup_bucket_and_file" "bucket, file name" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket_and_files "$1" "$2"; then
|
||||
log 2 "error setting up bucket and file"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_bucket_and_files() {
|
||||
if ! check_param_count_gt "bucket, file name" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket "$1"; then
|
||||
log 2 "error setting up bucket"
|
||||
return 1
|
||||
fi
|
||||
if ! create_test_files "${@:2}"; then
|
||||
log 2 "error creating test files"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_bucket_and_large_file() {
|
||||
if ! check_param_count "setup_bucket_and_large_file" "bucket, file name" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! setup_bucket "$1"; then
|
||||
log 2 "error setting up bucket"
|
||||
return 1
|
||||
fi
|
||||
if ! create_large_file "$2"; then
|
||||
log 2 "error creating large file"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_bucket_file_and_user() {
|
||||
if ! check_param_count "setup_bucket_file_and_user" "bucket, file, username, password, user type" 5 $#; then
|
||||
return 1
|
||||
@@ -67,6 +24,10 @@ setup_bucket_object_lock_enabled() {
|
||||
log 2 "error cleaning up bucket"
|
||||
return 1
|
||||
fi
|
||||
if [ "$DIRECT" == "true" ] && [ "$RECREATE_BUCKETS" == "true" ] && ! direct_wait_for_bucket_deletion "$1"; then
|
||||
log 2 "bucket not confirmed as deleted"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# in static bucket config, bucket will still exist
|
||||
if ! bucket_exists "$1"; then
|
||||
@@ -75,5 +36,9 @@ setup_bucket_object_lock_enabled() {
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ "$DIRECT" == "true" ] && ! direct_wait_for_bucket "$1"; then
|
||||
log 2 "bucket not confirmed as created"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ add_verify_bucket_tags_rest() {
|
||||
log 2 "expected response code of '204', was '$result' (error: $(cat "$TEST_FILE_FOLDER/result.txt"))"
|
||||
return 1
|
||||
fi
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$BUCKET_ONE_NAME" OUTPUT_FILE="$TEST_FILE_FOLDER/bucket_tagging.txt" ./tests/rest_scripts/get_bucket_tagging.sh); then
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OUTPUT_FILE="$TEST_FILE_FOLDER/bucket_tagging.txt" ./tests/rest_scripts/get_bucket_tagging.sh); then
|
||||
log 2 "error listing bucket tags: $result"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -74,7 +74,7 @@ check_versioning_status_rest() {
|
||||
if ! check_param_count "check_versioning_status_rest" "bucket, expected value" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! get_bucket_versioning_rest "$BUCKET_ONE_NAME"; then
|
||||
if ! get_bucket_versioning_rest "$1"; then
|
||||
log 2 "error getting bucket versioning"
|
||||
return 1
|
||||
fi
|
||||
@@ -102,7 +102,7 @@ check_versioning_status_rest() {
|
||||
}
|
||||
|
||||
echo_versions() {
|
||||
if ! check_param_count "echo_versions" "'Version' or 'DeleteMarker', 'Key' or 'VersionId'" 2 $#; then
|
||||
if ! check_param_count_v2 "'Version' or 'DeleteMarker', 'Key' or 'VersionId', file" 3 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! keys=$(echo -n "$versions" | xmllint --xpath "//*[local-name()=\"$1\"]/*[local-name()=\"$2\"]/text()" - | xmlstarlet unesc 2>&1); then
|
||||
@@ -113,32 +113,64 @@ echo_versions() {
|
||||
return 1
|
||||
fi
|
||||
log 5 "keys to append: ${keys[*]}"
|
||||
if ! result=$(truncate -s 0 "$3" 2>&1); then
|
||||
log 2 "error truncating file: $result"
|
||||
fi
|
||||
for key in "${keys[@]}"; do
|
||||
echo "$key" >> "$3"
|
||||
done
|
||||
echo "${keys[*]}"
|
||||
}
|
||||
|
||||
parse_versions_rest() {
|
||||
if ! check_param_count "parse_versions_rest" "versions variable" 1 $#; then
|
||||
get_base64_version_keys_and_ids() {
|
||||
if ! check_param_count_v2 "'Version' or 'DeleteMarker'" 1 $#; then
|
||||
return 1
|
||||
fi
|
||||
if ! keys=$(echo_versions "Version" "Key"); then
|
||||
while IFS= read -r key && IFS= read -r vid; do
|
||||
log 5 "key: $key, vid: $vid"
|
||||
b_key="$(printf '%s' "$key" | base64 -w0)"
|
||||
b_vid="$(printf '%s' "$vid" | base64 -w0)"
|
||||
base64_pairs+=("$b_key:$b_vid")
|
||||
done < <(xmlstarlet sel -t \
|
||||
-m '//*[local-name()='"\"$1\""']' \
|
||||
-v '*[local-name()="Key"]' -n \
|
||||
-v '*[local-name()="VersionId"]' -n \
|
||||
<<<"$versions" | xmlstarlet unesc)
|
||||
}
|
||||
|
||||
parse_base64_versions_rest() {
|
||||
base64_pairs=()
|
||||
if ! get_base64_version_keys_and_ids "Version"; then
|
||||
log 2 "error getting version base64 keys and IDs"
|
||||
return 1
|
||||
fi
|
||||
if ! get_base64_version_keys_and_ids "DeleteMarker"; then
|
||||
log 2 "error getting version base64 keys and IDs"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
parse_versions_rest() {
|
||||
base64_pairs=()
|
||||
if ! keys=$(echo_versions "Version" "Key" "$TEST_FILE_FOLDER/version_keys.txt"); then
|
||||
log 2 "error getting Version Key values: $keys"
|
||||
return 1
|
||||
fi
|
||||
# shellcheck disable=SC2206
|
||||
version_keys+=($keys)
|
||||
if ! ids=$(echo_versions "Version" "VersionId"); then
|
||||
if ! ids=$(echo_versions "Version" "VersionId" "$TEST_FILE_FOLDER/version_ids.txt"); then
|
||||
log 2 "error getting Version VersionId values: $ids"
|
||||
return 1
|
||||
fi
|
||||
# shellcheck disable=SC2206
|
||||
version_ids+=($ids)
|
||||
if ! keys=$(echo_versions "DeleteMarker" "Key"); then
|
||||
if ! keys=$(echo_versions "DeleteMarker" "Key" "$TEST_FILE_FOLDER/delete_marker_keys.txt"); then
|
||||
log 2 "error getting DeleteMarker Key values: $keys"
|
||||
return 1
|
||||
fi
|
||||
# shellcheck disable=SC2206
|
||||
version_keys+=($keys)
|
||||
if ! ids=$(echo_versions "DeleteMarker" "VersionId"); then
|
||||
if ! ids=$(echo_versions "DeleteMarker" "VersionId" "$TEST_FILE_FOLDER/delete_marker_ids.txt"); then
|
||||
log 2 "error getting DeleteMarker VersionId values: $ids"
|
||||
return 1
|
||||
fi
|
||||
@@ -146,6 +178,7 @@ parse_versions_rest() {
|
||||
version_ids+=($ids)
|
||||
log 5 "version keys: ${version_keys[*]}"
|
||||
log 5 "version IDs: ${version_ids[*]}"
|
||||
log 5 "base64 pairs: ${base64_pairs[*]}"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user