-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: REST acl public-read-write test, other acl test, cleanup
- Loading branch information
Showing
12 changed files
with
265 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/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/rest_scripts/rest.sh | ||
|
||
# Fields | ||
|
||
# shellcheck disable=SC2153 | ||
bucket_name="$BUCKET_NAME" | ||
# shellcheck disable=SC2153 | ||
key="$OBJECT_KEY" | ||
|
||
current_date_time=$(date -u +"%Y%m%dT%H%M%SZ") | ||
|
||
canonical_request="DELETE | ||
/$bucket_name/$key | ||
tagging= | ||
host:$host | ||
x-amz-content-sha256:UNSIGNED-PAYLOAD | ||
x-amz-date:$current_date_time | ||
host;x-amz-content-sha256;x-amz-date | ||
UNSIGNED-PAYLOAD" | ||
|
||
create_canonical_hash_sts_and_signature | ||
|
||
curl_command+=(curl -ks -w "\"%{http_code}\"" -X DELETE "$AWS_ENDPOINT_URL/$bucket_name/$key?tagging" | ||
-H "\"Authorization: AWS4-HMAC-SHA256 Credential=$aws_access_key_id/$year_month_day/$aws_region/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=$signature\"" | ||
-H "\"x-amz-content-sha256: UNSIGNED-PAYLOAD\"" | ||
-H "\"x-amz-date: $current_date_time\"" | ||
-o "$OUTPUT_FILE") | ||
|
||
# shellcheck disable=SC2154 | ||
eval "${curl_command[*]}" 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
#!/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/commands/put_object.sh | ||
source ./tests/logger.sh | ||
source ./tests/setup.sh | ||
source ./tests/util/util.sh | ||
source ./tests/util/util_acl.sh | ||
|
||
export RUN_USERS=true | ||
|
||
@test "REST - get ACL" { | ||
if [ "$DIRECT" != "true" ]; then | ||
skip "https://github.com/versity/versitygw/issues/971" | ||
fi | ||
run setup_bucket "s3api" "$BUCKET_ONE_NAME" | ||
assert_success | ||
|
||
run get_and_check_acl_rest "$BUCKET_ONE_NAME" | ||
assert_success | ||
} | ||
|
||
@test "REST - put ACL" { | ||
run setup_bucket "s3api" "$BUCKET_ONE_NAME" | ||
assert_success | ||
|
||
test_file="test_file" | ||
run create_test_files "$test_file" | ||
assert_success | ||
|
||
run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred" | ||
assert_success | ||
|
||
run put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" | ||
assert_success | ||
|
||
run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE" | ||
assert_success | ||
canonical_id=${lines[0]} | ||
user_canonical_id=${lines[1]} | ||
username=${lines[2]} | ||
password=${lines[3]} | ||
|
||
run setup_acl "$TEST_FILE_FOLDER/acl-file.txt" "$user_canonical_id" "READ" "$canonical_id" | ||
assert_success | ||
|
||
run list_objects_with_user_rest_verify_access_denied "$BUCKET_ONE_NAME" "$username" "$password" | ||
assert_success | ||
|
||
run put_acl_rest "$BUCKET_ONE_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" | ||
assert_success | ||
} | ||
|
||
@test "REST - put public-read canned acl" { | ||
run setup_bucket "s3api" "$BUCKET_ONE_NAME" | ||
assert_success | ||
|
||
test_file="test_file" | ||
run create_test_files "$test_file" | ||
assert_success | ||
|
||
run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred" | ||
assert_success | ||
|
||
run put_object "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" | ||
assert_success | ||
|
||
run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE" | ||
assert_success | ||
canonical_id=${lines[0]} | ||
user_canonical_id=${lines[1]} | ||
username=${lines[2]} | ||
password=${lines[3]} | ||
|
||
run list_objects_with_user_rest_verify_access_denied "$BUCKET_ONE_NAME" "$username" "$password" | ||
assert_success | ||
|
||
if [ "$DIRECT" == "true" ]; then | ||
run allow_public_access "$BUCKET_ONE_NAME" | ||
assert_success | ||
fi | ||
run put_canned_acl_rest "$BUCKET_ONE_NAME" "public-read" | ||
assert_success | ||
|
||
run list_objects_with_user_rest_verify_success "$BUCKET_ONE_NAME" "$username" "$password" "$test_file" | ||
assert_success | ||
} | ||
|
||
@test "REST - put invalid ACL" { | ||
if [ "$DIRECT" != "true" ]; then | ||
skip "https://github.com/versity/versitygw/issues/986" | ||
fi | ||
run setup_bucket "s3api" "$BUCKET_ONE_NAME" | ||
assert_success | ||
|
||
run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred" | ||
assert_success | ||
|
||
run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE" | ||
assert_success | ||
canonical_id=${lines[0]} | ||
user_canonical_id=${lines[1]} | ||
username=${lines[2]} | ||
password=${lines[3]} | ||
|
||
run setup_acl "$TEST_FILE_FOLDER/acl-file.txt" "$user_canonical_id" "READD" "$canonical_id" | ||
assert_success | ||
|
||
if [ "$DIRECT" == "true" ]; then | ||
run allow_public_access "$BUCKET_ONE_NAME" | ||
assert_success | ||
fi | ||
run put_invalid_acl_rest_verify_failure "$BUCKET_ONE_NAME" "$TEST_FILE_FOLDER/acl-file.txt" | ||
assert_success | ||
} | ||
|
||
@test "REST - put public-read-write canned acl" { | ||
run setup_bucket "s3api" "$BUCKET_ONE_NAME" | ||
assert_success | ||
|
||
test_file="test_file" | ||
run create_test_files "$test_file" | ||
assert_success | ||
|
||
run put_bucket_ownership_controls "$BUCKET_ONE_NAME" "BucketOwnerPreferred" | ||
assert_success | ||
|
||
run create_versitygw_acl_user_or_get_direct_user "$USERNAME_ONE" "$PASSWORD_ONE" | ||
assert_success | ||
canonical_id=${lines[0]} | ||
user_canonical_id=${lines[1]} | ||
username=${lines[2]} | ||
password=${lines[3]} | ||
|
||
run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$username" "$password" | ||
assert_failure | ||
|
||
if [ "$DIRECT" == "true" ]; then | ||
run allow_public_access "$BUCKET_ONE_NAME" | ||
assert_success | ||
fi | ||
run put_canned_acl_rest "$BUCKET_ONE_NAME" "public-read-write" | ||
assert_success | ||
|
||
run put_object_with_user "s3api" "$TEST_FILE_FOLDER/$test_file" "$BUCKET_ONE_NAME" "$test_file" "$username" "$password" | ||
assert_success | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.