test: static bucket init fix, github-actions enhancements

This commit is contained in:
Luke McCrone
2024-09-13 13:58:21 -03:00
parent 53a7abf82f
commit ae1c566656
11 changed files with 359 additions and 267 deletions

View File

@@ -8,7 +8,7 @@ jobs:
fail-fast: false
matrix:
include:
- set: 1
- set: "s3cmd, posix"
LOCAL_FOLDER: /tmp/gw1
BUCKET_ONE_NAME: versity-gwtest-bucket-one-1
BUCKET_TWO_NAME: versity-gwtest-bucket-two-1
@@ -19,7 +19,7 @@ jobs:
RECREATE_BUCKETS: "true"
PORT: 7070
BACKEND: "posix"
- set: 2
- set: "s3, posix"
LOCAL_FOLDER: /tmp/gw2
BUCKET_ONE_NAME: versity-gwtest-bucket-one-2
BUCKET_TWO_NAME: versity-gwtest-bucket-two-2
@@ -30,7 +30,7 @@ jobs:
RECREATE_BUCKETS: "true"
PORT: 7071
BACKEND: "posix"
- set: 3
- set: "s3api, posix"
LOCAL_FOLDER: /tmp/gw3
BUCKET_ONE_NAME: versity-gwtest-bucket-one-3
BUCKET_TWO_NAME: versity-gwtest-bucket-two-3
@@ -41,7 +41,7 @@ jobs:
RECREATE_BUCKETS: "true"
PORT: 7072
BACKEND: "posix"
- set: 4
- set: "mc, posix"
LOCAL_FOLDER: /tmp/gw4
BUCKET_ONE_NAME: versity-gwtest-bucket-one-4
BUCKET_TWO_NAME: versity-gwtest-bucket-two-4
@@ -52,40 +52,40 @@ jobs:
RECREATE_BUCKETS: "true"
PORT: 7073
BACKEND: "posix"
- set: 5
- set: "s3api-user, posix, s3 IAM"
LOCAL_FOLDER: /tmp/gw5
BUCKET_ONE_NAME: versity-gwtest-bucket-one-5
BUCKET_TWO_NAME: versity-gwtest-bucket-two-5
IAM_TYPE: s3
USERS_BUCKET: versity-gwtest-iam
AWS_ENDPOINT_URL: https://127.0.0.1:7074
RUN_SET: "aws-user"
RUN_SET: "s3api-user"
RECREATE_BUCKETS: "true"
PORT: 7074
BACKEND: "posix"
- set: 6
- set: "s3api non-policy, static buckets"
LOCAL_FOLDER: /tmp/gw6
BUCKET_ONE_NAME: versity-gwtest-bucket-one-6
BUCKET_TWO_NAME: versity-gwtest-bucket-two-6
IAM_TYPE: folder
USERS_FOLDER: /tmp/iam6
AWS_ENDPOINT_URL: https://127.0.0.1:7075
RUN_SET: "aws"
RUN_SET: "s3api-non-policy"
RECREATE_BUCKETS: "false"
PORT: 7075
BACKEND: "posix"
- set: 7
- set: "s3api, s3 backend"
LOCAL_FOLDER: /tmp/gw7
BUCKET_ONE_NAME: versity-gwtest-bucket-one-7
BUCKET_TWO_NAME: versity-gwtest-bucket-two-7
IAM_TYPE: folder
USERS_FOLDER: /tmp/iam7
AWS_ENDPOINT_URL: https://127.0.0.1:7076
RUN_SET: "aws"
RUN_SET: "s3api"
RECREATE_BUCKETS: "true"
PORT: 7076
BACKEND: "s3"
- set: 8
- set: "REST, posix"
LOCAL_FOLDER: /tmp/gw8
BUCKET_ONE_NAME: versity-gwtest-bucket-one-7
BUCKET_TWO_NAME: versity-gwtest-bucket-two-7
@@ -96,6 +96,28 @@ jobs:
RECREATE_BUCKETS: "true"
PORT: 7077
BACKEND: "posix"
- set: "s3api policy, static buckets"
LOCAL_FOLDER: /tmp/gw9
BUCKET_ONE_NAME: versity-gwtest-bucket-one-8
BUCKET_TWO_NAME: versity-gwtest-bucket-two-8
IAM_TYPE: folder
USERS_FOLDER: /tmp/iam9
AWS_ENDPOINT_URL: https://127.0.0.1:7078
RUN_SET: "s3api-policy"
RECREATE_BUCKETS: "false"
PORT: 7078
BACKEND: "posix"
- set: "s3api user, static buckets"
LOCAL_FOLDER: /tmp/gw10
BUCKET_ONE_NAME: versity-gwtest-bucket-one-9
BUCKET_TWO_NAME: versity-gwtest-bucket-two-9
IAM_TYPE: folder
USERS_FOLDER: /tmp/iam10
AWS_ENDPOINT_URL: https://127.0.0.1:7079
RUN_SET: "s3api-user"
RECREATE_BUCKETS: "false"
PORT: 7079
BACKEND: "posix"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

View File

@@ -24,7 +24,10 @@ source ./tests/report.sh
head_bucket() {
log 6 "head_bucket"
record_command "head-bucket" "client:$1"
assert [ $# -eq 2 ]
if [ $# -ne 2 ]; then
log 2 "'head_bucket' command requires client, bucket name"
return 1
fi
local exit_code=0
if [[ $1 == "aws" ]] || [[ $1 == 's3api' ]] || [[ $1 == 's3' ]]; then
bucket_info=$(aws --no-verify-ssl s3api head-bucket --bucket "$2" 2>&1) || exit_code=$?

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bats
#!/usr/bin/env bash
# Copyright 2024 Versity Software
# This file is licensed under the Apache License, Version 2.0
@@ -14,24 +14,32 @@
# specific language governing permissions and limitations
# under the License.
load ./bats-support/load
load ./bats-assert/load
source ./tests/versity.sh
base_setup() {
check_env_vars
if [ "$RUN_VERSITYGW" == "true" ]; then
run_versity_app
fi
}
check_env_vars() {
check_universal_vars
#if ! check_universal_vars; then
# log 2 "error checking universal params"
# return 1
#fi
if [[ $RUN_VERSITYGW == "true" ]]; then
check_versity_vars
fi
if [[ $RUN_S3CMD == "true" ]]; then
assert [ -n "$S3CMD_CONFIG" ]
if [ -z "$S3CMD_CONFIG" ]; then
log 1 "S3CMD_CONFIG param missing"
exit 1
fi
export S3CMD_CONFIG
fi
if [[ $RUN_MC == "true" ]]; then
assert [ -n "$MC_ALIAS" ]
if [ -z "$MC_ALIAS" ]; then
log 1 "MC_ALIAS param missing"
exit 1
fi
export MC_ALIAS
fi
return 0
@@ -66,37 +74,80 @@ check_universal_vars() {
export LOG_LEVEL_INT=$LOG_LEVEL
fi
assert [ -n "$AWS_ACCESS_KEY_ID" ]
assert [ -n "$AWS_SECRET_ACCESS_KEY" ]
assert [ -n "$AWS_REGION" ]
assert [ -n "$AWS_PROFILE" ]
if [ -z "$AWS_ACCESS_KEY_ID" ]; then
log 1 "AWS_ACCESS_KEY_ID missing"
exit 1
fi
if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then
log 1 "AWS_SECRET_ACCESS_KEY missing"
exit 1
fi
if [ -z "$AWS_REGION" ]; then
log 1 "AWS_REGION missing"
exit 1
fi
if [ -z "$AWS_PROFILE" ]; then
log 1 "AWS_PROFILE missing"
exit 1
fi
if [ "$DIRECT" != "true" ]; then
assert [ -n "$AWS_ENDPOINT_URL" ]
if [ -z "$AWS_ENDPOINT_URL" ]; then
log 1 "AWS_ENDPOINT_URL missing"
exit 1
fi
fi
if [ "$RUN_VERSITYGW" != "true" ] && [ "$RUN_VERSITYGW" != "false" ]; then
fail "RUN_VERSITYGW must be 'true' or 'false'"
fi
assert [ -n "$BUCKET_ONE_NAME" ]
assert [ -n "$BUCKET_TWO_NAME" ]
assert [ -n "$RECREATE_BUCKETS" ]
if [ "$RECREATE_BUCKETS" != "true" ] && [ "$RECREATE_BUCKETS" != "false" ]; then
fail "RECREATE_BUCKETS must be 'true' or 'false'"
if [ -z "$BUCKET_ONE_NAME" ]; then
log 1 "BUCKET_ONE_NAME missing"
exit 1
fi
if [ -z "$BUCKET_TWO_NAME" ]; then
log 1 "BUCKET_TWO_NAME missing"
exit 1
fi
if [ -z "$RECREATE_BUCKETS" ]; then
log 1 "RECREATE_BUCKETS missing"
exit 1
fi
if [ "$RECREATE_BUCKETS" != "true" ] && [ "$RECREATE_BUCKETS" != "false" ]; then
log 1 "RECREATE_BUCKETS must be 'true' or 'false'"
exit 1
fi
if [ -z "$TEST_FILE_FOLDER" ]; then
log 1 "TEST_FILE_FOLDER missing"
exit 1
fi
assert [ -n "$TEST_FILE_FOLDER" ]
# exporting these since they're needed for subshells
export AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_REGION AWS_PROFILE AWS_ENDPOINT_URL
}
check_versity_vars() {
assert [ -n "$LOCAL_FOLDER" ]
assert [ -n "$VERSITY_EXE" ]
assert [ -n "$BACKEND" ]
if [ -z "$LOCAL_FOLDER" ]; then
log 1 "LOCAL_FOLDER missing"
exit 1
fi
if [ -z "$VERSITY_EXE" ]; then
log 1 "VERSITY_EXE missing"
exit 1
fi
if [ -z "$BACKEND" ]; then
log 1 "BACKEND missing"
exit 1
fi
export LOCAL_FOLDER VERSITY_EXE BACKEND
if [ "$BACKEND" == 's3' ]; then
assert [ -n "$AWS_ACCESS_KEY_ID_TWO" ]
assert [ -n "$AWS_SECRET_ACCESS_KEY_TWO" ]
if [ -z "$AWS_ACCESS_KEY_ID_TWO" ]; then
log 1 "AWS_ACCESS_KEY_ID_TWO missing"
exit 1
fi
if [ -z "$AWS_SECRET_ACCESS_KEY_TWO" ]; then
log 1 "AWS_SECRET_ACCESS_KEY_TWO missing"
exit 1
fi
export AWS_ACCESS_KEY_ID_TWO AWS_SECRET_ACCESS_KEY_TWO
fi
@@ -110,31 +161,52 @@ check_versity_vars() {
}
check_user_vars() {
assert [ -n "$USERNAME_ONE" ]
assert [ -n "$PASSWORD_ONE" ]
assert [ -n "$USERNAME_TWO" ]
assert [ -n "$PASSWORD_TWO" ]
if [ -z "$USERNAME_ONE" ]; then
log 1 "USERNAME_ONE missing"
exit 1
fi
if [ -z "$PASSWORD_ONE" ]; then
log 1 "PASSWORD_ONE missing"
exit 1
fi
if [ -z "$USERNAME_TWO" ]; then
log 1 "USERNAME_TWO missing"
exit 1
fi
if [ -z "$PASSWORD_TWO" ]; then
log 1 "PASSWORD_TWO missing"
exit 1
fi
if [[ -z "$IAM_TYPE" ]]; then
export IAM_TYPE="folder"
fi
if [[ "$IAM_TYPE" == "folder" ]]; then
assert [ -n "$USERS_FOLDER" ]
if [ -z "$USERS_FOLDER" ]; then
log 1 "USERS_FOLDER missing"
exit 1
fi
if [ ! -d "$USERS_FOLDER" ]; then
mkdir_error=$(mkdir "$USERS_FOLDER" 2>&1)
assert_success "error creating users folder: $mkdir_error"
if ! mkdir_error=$(mkdir "$USERS_FOLDER" 2>&1); then
log 1 "error creating users folder: $mkdir_error"
exit 1
fi
fi
IAM_PARAMS="--iam-dir=$USERS_FOLDER"
export IAM_PARAMS
return 0
fi
if [[ $IAM_TYPE == "s3" ]]; then
assert [ -n "$USERS_BUCKET" ]
if [ -z "$USERS_BUCKET" ]; then
log 1 "error creating USERS_BUCKET"
exit 1
fi
IAM_PARAMS="--s3-iam-access $AWS_ACCESS_KEY_ID --s3-iam-secret $AWS_SECRET_ACCESS_KEY \
--s3-iam-region us-east-1 --s3-iam-bucket $USERS_BUCKET --s3-iam-endpoint $AWS_ENDPOINT_URL \
--s3-iam-noverify"
export IAM_PARAMS
return 0
fi
fail "unrecognized IAM_TYPE value: $IAM_TYPE"
log 1 "unrecognized IAM_TYPE value: $IAM_TYPE"
exit 1
}

View File

@@ -19,13 +19,14 @@ show_help() {
echo "Usage: $0 [option...]"
echo " -h, --help Display this help message and exit"
echo " -s, --static Don't remove buckets between tests"
echo " aws Run tests with aws (s3api) cli"
echo " s3api Run tests with s3api cli"
echo " s3api-non-policy Run policy tests with s3api cli"
echo " s3api-policy Run policy tests with s3api cli"
echo " s3 Run tests with s3 cli"
echo " s3cmd Run tests with s3cmd utility"
echo " mc Run tests with mc utility"
echo " rest Run tests with rest cli"
echo " aws-user Run user tests with aws cli"
echo " s3api-user Run user tests with aws cli"
}
handle_param() {
@@ -34,7 +35,7 @@ handle_param() {
show_help
exit 0
;;
s3|s3api|aws|s3cmd|mc|aws-user|rest)
s3|s3api|s3cmd|mc|s3api-user|rest|s3api-policy|s3api-non-policy)
set_command_type "$1"
;;
*) # Handle unrecognized options or positional arguments
@@ -63,14 +64,26 @@ if [[ -z "$VERSITYGW_TEST_ENV" ]] && [[ $BYPASS_ENV_FILE != "true" ]]; then
exit 1
fi
exit_code=0
case $command_type in
s3api|aws)
echo "Running aws tests ..."
s3api)
echo "Running all s3api tests ..."
"$HOME"/bin/bats ./tests/test_s3api.sh || exit_code=$?
if [[ $exit_code -eq 0 ]]; then
"$HOME"/bin/bats ./tests/test_s3api_policy.sh || exit_code=$?
fi
if [[ $exit_code -eq 0 ]]; then
"$HOME"/bin/bats ./tests/test_user_aws.sh || exit_code=$?
fi
;;
s3api-policy)
echo "Running s3api policy tests ..."
"$HOME"/bin/bats ./tests/test_s3api_policy.sh || exit_code=$?
;;
s3api-non-policy)
echo "Running s3api non-policy tests ..."
"$HOME"/bin/bats ./tests/test_s3api.sh || exit_code=$?
;;
s3)
echo "Running s3 tests ..."
"$HOME"/bin/bats ./tests/test_s3.sh || exit_code=$?
@@ -90,8 +103,8 @@ case $command_type in
echo "Running rest tests ..."
"$HOME"/bin/bats ./tests/test_rest.sh || exit_code=$?
;;
aws-user)
echo "Running aws user tests ..."
s3api-user)
echo "Running s3api user tests ..."
"$HOME"/bin/bats ./tests/test_user_aws.sh || exit_code=$?
esac

View File

@@ -21,7 +21,7 @@ fi
status=0
for cmd in aws s3 s3cmd mc rest; do
for cmd in s3api s3 s3cmd mc rest; do
if ! ./tests/run.sh "$cmd"; then
status=1
fi

View File

@@ -14,20 +14,18 @@
# specific language governing permissions and limitations
# under the License.
load ./bats-support/load
load ./bats-assert/load
source ./tests/env.sh
source ./tests/report.sh
source ./tests/setup_mc.sh
source ./tests/util.sh
source ./tests/versity.sh
# bats setup function
setup() {
check_env_vars
if [ "$RUN_VERSITYGW" == "true" ]; then
if ! run_versity_app; then
log 2 "error starting versity apps"
return 1
fi
fi
base_setup
log 4 "Running test $BATS_TEST_NAME"
if [[ $LOG_LEVEL -ge 5 ]]; then
@@ -44,10 +42,7 @@ setup() {
fi
if [[ $RUN_MC == true ]]; then
if ! check_add_mc_alias; then
log 2 "mc alias check/add failed"
return 1
fi
check_add_mc_alias
fi
export AWS_PROFILE

View File

@@ -14,7 +14,7 @@
# specific language governing permissions and limitations
# under the License.
source ./tests/setup.sh
source ./tests/env.sh
source ./tests/util.sh
source ./tests/commands/create_bucket.sh
@@ -40,15 +40,15 @@ create_bucket_if_not_exists() {
return 0
}
if ! setup; then
log 2 "error starting versity to set up static buckets"
exit 1
fi
base_setup
if ! create_bucket_if_not_exists "s3api" "$BUCKET_ONE_NAME"; then
log 2 "error creating static bucket one"
elif ! create_bucket_if_not_exists "s3api" "$BUCKET_TWO_NAME"; then
log 2 "error creating static bucket two"
fi
if ! teardown; then
# shellcheck disable=SC2034
RECREATE_BUCKETS=false
if ! stop_versity; then
log 2 "error stopping versity"
fi

View File

@@ -17,7 +17,7 @@
source ./tests/setup.sh
source ./tests/util.sh
if ! setup; then
if ! base_setup; then
log 2 "error starting versity to set up static buckets"
exit 1
fi
@@ -27,6 +27,6 @@ elif ! delete_bucket_recursive "s3" "$BUCKET_TWO_NAME"; then
log 2 "error creating static bucket two"
fi
log 4 "buckets deleted successfully"
if ! teardown; then
if ! stop_versity; then
log 2 "error stopping versity"
fi

View File

@@ -14,19 +14,17 @@
# specific language governing permissions and limitations
# under the License.
load ./bats-support/load
load ./bats-assert/load
source ./tests/setup.sh
source ./tests/util.sh
source ./tests/util_aws.sh
source ./tests/util_create_bucket.sh
source ./tests/util_file.sh
source ./tests/util_lock_config.sh
source ./tests/util_multipart.sh
source ./tests/util_tags.sh
source ./tests/util_users.sh
source ./tests/test_aws_root_inner.sh
source ./tests/test_common.sh
source ./tests/test_s3api_policy.sh
source ./tests/commands/copy_object.sh
source ./tests/commands/delete_bucket_policy.sh
source ./tests/commands/delete_object_tagging.sh
@@ -325,104 +323,6 @@ export RUN_USERS=true
delete_test_files $folder_name
}
@test "test_put_policy_invalid_action" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_invalid_action
}
@test "test_policy_get_object_with_user" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_object_with_user
}
@test "test_policy_get_object_specific_file" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_object_specific_file
}
@test "test_policy_get_object_file_wildcard" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_object_file_wildcard
}
@test "test_policy_get_object_folder_wildcard" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_object_folder_wildcard
}
@test "test_policy_allow_deny" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_allow_deny
}
@test "test_policy_deny" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_deny
}
@test "test_policy_put_wildcard" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_put_wildcard
}
@test "test_policy_delete" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_delete
}
@test "test_policy_get_bucket_policy" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_bucket_policy
}
@test "test_policy_list_multipart_uploads" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_list_multipart_uploads
}
@test "test_policy_put_bucket_policy" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_put_bucket_policy
}
@test "test_policy_delete_bucket_policy" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_delete_bucket_policy
}
@test "test_policy_get_bucket_acl" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_bucket_acl
}
# ensure that lists of files greater than a size of 1000 (pagination) are returned properly
#@test "test_list_objects_file_count" {
# test_common_list_objects_file_count "aws"
@@ -497,48 +397,6 @@ export RUN_USERS=true
delete_test_files "$object_one"
}
@test "test_policy_abort_multipart_upload" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_abort_multipart_upload
}
@test "test_policy_two_principals" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_two_principals
}
@test "test_policy_put_bucket_tagging" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_put_bucket_tagging
}
@test "test_policy_get_bucket_tagging" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_bucket_tagging
}
@test "test_policy_list_upload_parts" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_list_upload_parts
}
@test "test_policy_put_acl" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_put_acl
}
@test "test_put_object_lock_configuration" {
bucket_name=$BUCKET_ONE_NAME
if [[ $RECREATE_BUCKETS == "true" ]]; then

151
tests/test_s3api_policy.sh Normal file → Executable file
View File

@@ -14,10 +14,161 @@
# specific language governing permissions and limitations
# under the License.
source ./tests/logger.sh
source ./tests/setup.sh
source ./tests/util_multipart.sh
source ./tests/util_file.sh
source ./tests/util_policy.sh
source ./tests/util_tags.sh
source ./tests/util_users.sh
source ./tests/commands/get_bucket_policy.sh
source ./tests/commands/get_bucket_tagging.sh
source ./tests/commands/get_object.sh
source ./tests/commands/put_bucket_policy.sh
source ./tests/commands/put_bucket_tagging.sh
source ./tests/commands/put_object.sh
export RUN_USERS=true
@test "test_put_policy_invalid_action" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_invalid_action
}
@test "test_policy_get_object_with_user" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_object_with_user
}
@test "test_policy_get_object_specific_file" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_object_specific_file
}
@test "test_policy_get_object_file_wildcard" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_object_file_wildcard
}
@test "test_policy_get_object_folder_wildcard" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_object_folder_wildcard
}
@test "test_policy_allow_deny" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_allow_deny
}
@test "test_policy_deny" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_deny
}
@test "test_policy_put_wildcard" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_put_wildcard
}
@test "test_policy_delete" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_delete
}
@test "test_policy_get_bucket_policy" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_bucket_policy
}
@test "test_policy_list_multipart_uploads" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_list_multipart_uploads
}
@test "test_policy_put_bucket_policy" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_put_bucket_policy
}
@test "test_policy_delete_bucket_policy" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_delete_bucket_policy
}
@test "test_policy_get_bucket_acl" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_bucket_acl
}
@test "test_policy_abort_multipart_upload" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_abort_multipart_upload
}
@test "test_policy_two_principals" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_two_principals
}
@test "test_policy_put_bucket_tagging" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_put_bucket_tagging
}
@test "test_policy_get_bucket_tagging" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_get_bucket_tagging
}
@test "test_policy_list_upload_parts" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_list_upload_parts
}
@test "test_policy_put_acl" {
if [[ -n $SKIP_POLICY ]]; then
skip "will not test policy actions with SKIP_POLICY set"
fi
test_s3api_policy_put_acl
}
test_s3api_policy_invalid_action() {
policy_file="policy_file"

View File

@@ -18,12 +18,12 @@ source ./tests/util_file.sh
start_versity_process() {
if [[ $# -ne 1 ]]; then
log 2 "start versity process function requires number"
return 1
log 1 "start versity process function requires number"
exit 1
fi
if ! create_test_file_folder; then
log 2 "error creating test log folder"
return 1
log 1 "error creating test log folder"
exit 1
fi
IFS=' ' read -r -a full_command <<< "${base_command[@]}"
log 5 "versity command: ${full_command[*]}"
@@ -36,9 +36,10 @@ start_versity_process() {
if [[ $? -ne 0 ]]; then
sleep 1
if [ -n "$VERSITY_LOG_FILE" ]; then
log 2 "error running versitygw command: $(cat "$VERSITY_LOG_FILE")"
log 1 "error running versitygw command: $(cat "$VERSITY_LOG_FILE")"
exit 1
fi
return 1
exit 1
fi
eval versitygw_pid_"$1"=$!
if [ -n "$VERSITY_LOG_FILE" ]; then
@@ -51,19 +52,19 @@ start_versity_process() {
sleep 1
if ! check_result=$(kill -0 "$pid" 2>&1); then
log 2 "versitygw failed to start: $check_result"
log 1 "versitygw failed to start: $check_result"
if [ -n "$VERSITY_LOG_FILE" ]; then
log 2 "log data: $(cat "$VERSITY_LOG_FILE")"
log 1 "log data: $(cat "$VERSITY_LOG_FILE")"
fi
return 1
exit 1
fi
export versitygw_pid_"$1"
}
run_versity_app_posix() {
if [[ $# -ne 3 ]]; then
log 2 "run versity app w/posix command requires access ID, secret key, process number"
return 1
log 1 "run versity app w/posix command requires access ID, secret key, process number"
exit 1
fi
base_command=("$VERSITY_EXE" --access="$1" --secret="$2" --region="$AWS_REGION")
if [ -n "$RUN_USERS" ]; then
@@ -80,17 +81,14 @@ run_versity_app_posix() {
base_command+=(posix "$LOCAL_FOLDER")
export base_command
if ! start_versity_process "$3"; then
log 2 "error starting versity process"
return 1
fi
start_versity_process "$3"
return 0
}
run_versity_app_scoutfs() {
if [[ $# -ne 3 ]]; then
echo "run versity app w/scoutfs command requires access ID, secret key, process number"
return 1
log 1 "run versity app w/scoutfs command requires access ID, secret key, process number"
exit 1
fi
base_command=("$VERSITY_EXE" --access="$1" --secret="$2" --region="$AWS_REGION" --iam-dir="$USERS_FOLDER")
if [ -n "$CERT" ] && [ -n "$KEY" ]; then
@@ -102,19 +100,14 @@ run_versity_app_scoutfs() {
base_command+=(scoutfs "$LOCAL_FOLDER")
export base_command
local versity_result
start_versity_process "$3" || versity_result=$?
if [[ $versity_result -ne 0 ]]; then
echo "error starting versity process"
return 1
fi
start_versity_process "$3"
return 0
}
run_versity_app_s3() {
if [[ $# -ne 1 ]]; then
log 2 "run versity app w/s3 command requires process number"
return 1
log 1 "run versity app w/s3 command requires process number"
exit 1
fi
base_command=("$VERSITY_EXE" --access="$AWS_ACCESS_KEY_ID" --secret="$AWS_SECRET_ACCESS_KEY")
if [ -n "$CERT" ] && [ -n "$KEY" ]; then
@@ -128,43 +121,28 @@ run_versity_app_s3() {
base_command+=(s3 --access="$AWS_ACCESS_KEY_ID_TWO" --secret="$AWS_SECRET_ACCESS_KEY_TWO" --region="$AWS_REGION" --endpoint=https://s3.amazonaws.com)
export base_command
if ! start_versity_process "$1"; then
log 2 "error starting versity process"
return 1
fi
start_versity_process "$1"
return 0
}
run_versity_app() {
if [[ $BACKEND == 'posix' ]]; then
if ! run_versity_app_posix "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "1"; then
log 2 "error starting versity app"
return 1
fi
run_versity_app_posix "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "1"
elif [[ $BACKEND == 'scoutfs' ]]; then
run_versity_app_scoutfs "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "1" || result_one=$?
if [[ $result_one -ne 0 ]]; then
echo "error starting versity app"
return 1
fi
run_versity_app_scoutfs "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "1"
elif [[ $BACKEND == 's3' ]]; then
if ! run_versity_app_posix "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "1"; then
log 2 "error starting versity app"
return 1
fi
if ! run_versity_app_s3 "2"; then
log 2 "error starting second versity app"
return 1
fi
run_versity_app_posix "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "1"
run_versity_app_s3 "2"
else
log 2 "unrecognized backend type $BACKEND"
return 1
log 1 "unrecognized backend type $BACKEND"
exit 1
fi
if [[ $IAM_TYPE == "s3" ]]; then
if ! bucket_exists "s3api" "$USERS_BUCKET"; then
if ! create_bucket "s3api" "$USERS_BUCKET"; then
log 2 "error creating IAM bucket"
return 1
log 1 "error creating IAM bucket"
teardown
exit 1
fi
fi
fi