mirror of
https://github.com/versity/versitygw.git
synced 2026-01-05 03:24:04 +00:00
505 lines
14 KiB
Bash
Executable File
505 lines
14 KiB
Bash
Executable File
#!/usr/bin/env bats
|
|
|
|
# Copyright 2024 Versity Software
|
|
# This file is licensed under the Apache License, Version 2.0
|
|
# (the "License"); you may not use this file except in compliance
|
|
# with the License. You may obtain a copy of the License at
|
|
#
|
|
# http:#www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing,
|
|
# software distributed under the License is distributed on an
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
# KIND, either express or implied. See the License for the
|
|
# specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
load ./bats-support/load
|
|
load ./bats-assert/load
|
|
|
|
source ./tests/commands/create_multipart_upload.sh
|
|
source ./tests/commands/delete_object_tagging.sh
|
|
source ./tests/commands/get_bucket_versioning.sh
|
|
source ./tests/commands/get_object.sh
|
|
source ./tests/commands/get_object_lock_configuration.sh
|
|
source ./tests/commands/get_object_retention.sh
|
|
source ./tests/commands/list_buckets.sh
|
|
source ./tests/commands/list_object_versions.sh
|
|
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_object_lock_config/get_object_lock_config_rest.sh
|
|
source ./tests/drivers/get_object_tagging/get_object_tagging.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/list_objects/list_objects_rest.sh
|
|
source ./tests/drivers/file.sh
|
|
source ./tests/drivers/xml.sh
|
|
source ./tests/logger.sh
|
|
source ./tests/setup.sh
|
|
source ./tests/util/util_delete_object.sh
|
|
source ./tests/util/util_legal_hold.sh
|
|
source ./tests/util/util_list_buckets.sh
|
|
source ./tests/util/util_list_objects.sh
|
|
source ./tests/util/util_list_parts.sh
|
|
source ./tests/util/util_lock_config.sh
|
|
source ./tests/util/util_multipart_before_completion.sh
|
|
source ./tests/util/util_object.sh
|
|
source ./tests/util/util_policy.sh
|
|
source ./tests/util/util_public_access_block.sh
|
|
source ./tests/util/util_rest.sh
|
|
source ./tests/util/util_time.sh
|
|
source ./tests/util/util_versioning.sh
|
|
|
|
export RUN_USERS=true
|
|
test_file="test_file"
|
|
|
|
@test "test_rest_list_objects" {
|
|
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_name" "$test_file"
|
|
assert_success
|
|
|
|
run list_check_objects_rest "$bucket_name"
|
|
assert_success
|
|
}
|
|
|
|
@test "test_rest_delete_object" {
|
|
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_name" "$test_file"
|
|
assert_success
|
|
|
|
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_name" "$test_file"
|
|
assert_success
|
|
|
|
run get_object "rest" "$bucket_name" "$test_file" "$TEST_FILE_FOLDER/$test_file-copy"
|
|
assert_failure
|
|
}
|
|
|
|
@test "test_rest_tagging" {
|
|
test_key="TestKey"
|
|
test_value="TestValue"
|
|
|
|
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_name" "$test_file"
|
|
assert_success
|
|
|
|
run put_object_tagging "rest" "$bucket_name" "$test_file" "$test_key" "$test_value"
|
|
assert_success
|
|
|
|
run check_verify_object_tags "rest" "$bucket_name" "$test_file" "$test_key" "$test_value"
|
|
assert_success
|
|
|
|
run delete_object_tagging "rest" "$bucket_name" "$test_file"
|
|
assert_success
|
|
|
|
run verify_no_object_tags "rest" "$bucket_name" "$test_file"
|
|
assert_success
|
|
}
|
|
|
|
@test "test_rest_retention" {
|
|
test_key="TestKey"
|
|
test_value="TestValue"
|
|
|
|
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_files "$test_file"
|
|
assert_success
|
|
|
|
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
|
|
log 2 "error getting future time"
|
|
return 1
|
|
fi
|
|
log 5 "later: $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" {
|
|
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_name" "$test_file"
|
|
assert_success
|
|
|
|
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
|
|
}
|
|
|
|
@test "REST - get object attributes" {
|
|
if [ "$DIRECT" != "true" ]; then
|
|
skip "https://github.com/versity/versitygw/issues/1001"
|
|
fi
|
|
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
|
|
file_size=$(stat -c %s "$TEST_FILE_FOLDER/$test_file" 2>/dev/null || stat -f %z "$TEST_FILE_FOLDER/$test_file" 2>/dev/null)
|
|
|
|
run split_file "$TEST_FILE_FOLDER/$test_file" 4
|
|
assert_success
|
|
|
|
run upload_and_check_attributes "$bucket_name" "$test_file" "$file_size"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - attributes - invalid param" {
|
|
if [ "$DIRECT" != "true" ]; then
|
|
skip "https://github.com/versity/versitygw/issues/1001"
|
|
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_name" "$test_file"
|
|
assert_success
|
|
|
|
run check_attributes_invalid_param "$bucket_name" "$test_file"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - attributes - checksum" {
|
|
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" "$bucket_name" "$test_file"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - list objects v2 - invalid continuation token" {
|
|
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_v2 "$bucket_name" "$test_file" "$test_file_two" "$test_file_three"
|
|
assert_success
|
|
|
|
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_name" "$test_file_two"
|
|
assert_success
|
|
|
|
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_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_name" "${continuation_token:0:${#continuation_token}-3}"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - list objects v1 - no NextMarker without delimiter" {
|
|
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_v2 "$bucket_name" "$test_file" "$test_file_two"
|
|
assert_success
|
|
|
|
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_name" "$test_file_two"
|
|
assert_success
|
|
|
|
run list_objects_v1_check_nextmarker_empty "$bucket_name"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - head object" {
|
|
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_name" "$test_file"
|
|
assert_success
|
|
|
|
run get_etag_rest "$bucket_name" "$test_file"
|
|
assert_success
|
|
expected_etag=$output
|
|
|
|
run get_etag_attribute_rest "$bucket_name" "$test_file" "$expected_etag"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - delete objects - no content-md5 header" {
|
|
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_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_v2 "$bucket_name" "$test_file" "$test_file_two"
|
|
assert_success
|
|
|
|
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_name" "$test_file_two"
|
|
assert_success
|
|
|
|
run verify_object_exists "$bucket_name" "$test_file"
|
|
assert_success
|
|
|
|
run verify_object_exists "$bucket_name" "$test_file_two"
|
|
assert_success
|
|
|
|
run delete_objects_verify_success "$bucket_name" "$test_file" "$test_file_two"
|
|
assert_success
|
|
|
|
run verify_object_not_found "$bucket_name" "$test_file"
|
|
assert_success
|
|
|
|
run verify_object_not_found "$bucket_name" "$test_file_two"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - PutObjectRetention - w/o request body" {
|
|
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 retention_rest_without_request_body "$bucket_name" "$test_file"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - PutObjectLegalHold - missing content-md5" {
|
|
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_content_md5 "$bucket_name" "$test_file"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - PutObjectLegalHold w/o payload" {
|
|
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_payload "$bucket_name" "$test_file"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - PutObjectLegalHold - success" {
|
|
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 rest_check_legal_hold "$bucket_name" "$test_file"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - copy object w/invalid copy source" {
|
|
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_name" "$test_file"
|
|
assert_success
|
|
|
|
run copy_object_invalid_copy_source "$bucket_name"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - copy object w/copy source and payload" {
|
|
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_name" "$test_file"
|
|
assert_success
|
|
|
|
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 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_name" "$test_file"
|
|
assert_success
|
|
|
|
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_v2 "$bucket_name" "$file_name"
|
|
assert_success
|
|
|
|
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_name" "$file_name/$file_name"
|
|
assert_success
|
|
|
|
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_name" "$file_name/$file_name"
|
|
assert_success
|
|
}
|
|
|
|
@test "REST - GetObject w/STREAMING-AWS4-HMAC-SHA256-PAYLOAD type" {
|
|
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_name" "$test_file"
|
|
assert_success
|
|
}
|