Created
August 8, 2023 22:32
-
-
Save 4141done/49c218ef8b5fec97060c859d45a65ac5 to your computer and use it in GitHub Desktop.
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
diff --git a/test.sh b/test.sh | |
index d90f9ce..fbfd3b6 100755 | |
--- a/test.sh | |
+++ b/test.sh | |
@@ -247,10 +247,12 @@ integration_test() { | |
printf "\e[1m Integration test suite with PROVIDE_INDEX_PAGE=%s\e[22m\n" "$3" | |
printf "\033[34;1m▶\033[0m" | |
printf "\e[1m Integration test suite with APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=%s\e[22m\n" "$4" | |
+ printf "\033[34;1m▶\033[0m" | |
+ printf "\e[1m Integration test suite with STRIP_LEADING_DIRECTORY_PATH=%s\e[22m\n" "$5" | |
p "Starting Docker Compose Environment" | |
# COMPOSE_COMPATIBILITY=true Supports older style compose filenames with _ vs - | |
- COMPOSE_COMPATIBILITY=true AWS_SIGS_VERSION=$1 ALLOW_DIRECTORY_LIST=$2 PROVIDE_INDEX_PAGE=$3 APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=$4 compose up -d | |
+ COMPOSE_COMPATIBILITY=true AWS_SIGS_VERSION=$1 ALLOW_DIRECTORY_LIST=$2 PROVIDE_INDEX_PAGE=$3 APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=$4 STRIP_LEADING_DIRECTORY_PATH=$5 compose up -d | |
if [ "${wait_for_it_installed}" ]; then | |
if [ -x "${wait_for_it_cmd}" ]; then | |
@@ -259,8 +261,8 @@ integration_test() { | |
fi | |
p "Starting HTTP API tests (v$1 signatures)" | |
- echo " test/integration/test_api.sh \"$test_server\" \"$test_dir\" $1 $2 $3 $4" | |
- bash "${test_dir}/integration/test_api.sh" "${test_server}" "${test_dir}" "$1" "$2" "$3" "$4"; | |
+ echo " test/integration/test_api.sh \"$test_server\" \"$test_dir\" $1 $2 $3 $4 $5" | |
+ bash "${test_dir}/integration/test_api.sh" "${test_server}" "${test_dir}" "$1" "$2" "$3" "$4" "$5"; | |
# We check to see if NGINX is in fact using the correct version of AWS | |
# signatures as it was configured to do. | |
@@ -402,31 +404,36 @@ runUnitTestWithSessionToken "s3gateway_test.js" | |
integration_test_data | |
p "Testing API with AWS Signature V2 and allow directory listing off" | |
-integration_test 2 0 0 0 | |
+integration_test 2 0 0 0 "" | |
compose stop nginx-s3-gateway # Restart with new config | |
p "Testing API with AWS Signature V2 and allow directory listing on" | |
-integration_test 2 1 0 0 | |
+integration_test 2 1 0 0 "" | |
compose stop nginx-s3-gateway # Restart with new config | |
p "Testing API with AWS Signature V2 and static site on" | |
-integration_test 2 0 1 0 | |
+integration_test 2 0 1 0 "" | |
compose stop nginx-s3-gateway # Restart with new config | |
p "Test API with AWS Signature V4 and allow directory listing off" | |
-integration_test 4 0 0 0 | |
+integration_test 4 0 0 0 "" | |
compose stop nginx-s3-gateway # Restart with new config | |
p "Test API with AWS Signature V4 and allow directory listing on and appending /" | |
-integration_test 4 1 0 1 | |
+integration_test 4 1 0 1 "" | |
compose stop nginx-s3-gateway # Restart with new config | |
p "Test API with AWS Signature V4 and static site on appending /" | |
-integration_test 4 0 1 1 | |
+integration_test 4 0 1 1 "" | |
+ | |
+compose stop nginx-s3-gateway # Restart with new config | |
+ | |
+p "Testing API with AWS Signature V2 and allow directory listing off and prefix stripping on" | |
+integration_test 2 0 0 0 /my-bucket | |
p "All integration tests complete" | |
diff --git a/test/docker-compose.yaml b/test/docker-compose.yaml | |
index df54b0d..0a162f1 100644 | |
--- a/test/docker-compose.yaml | |
+++ b/test/docker-compose.yaml | |
@@ -26,6 +26,7 @@ services: | |
ALLOW_DIRECTORY_LIST: | |
PROVIDE_INDEX_PAGE: | |
APPEND_SLASH_FOR_POSSIBLE_DIRECTORY: | |
+ STRIP_LEADING_DIRECTORY_PATH: | |
AWS_SIGS_VERSION: | |
STATIC_SITE_HOSTING: | |
PROXY_CACHE_MAX_SIZE: "10g" | |
diff --git a/test/integration/test_api.sh b/test/integration/test_api.sh | |
old mode 100644 | |
new mode 100755 | |
index ec49f99..208f004 | |
--- a/test/integration/test_api.sh | |
+++ b/test/integration/test_api.sh | |
@@ -15,7 +15,6 @@ | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
- | |
set -o errexit # abort on nonzero exit status | |
set -o pipefail # don't hide errors within pipes | |
@@ -25,6 +24,7 @@ signature_version=$3 | |
allow_directory_list=$4 | |
index_page=$5 | |
append_slash=$6 | |
+strip_leading_directory=$7 | |
test_fail_exit_code=2 | |
no_dep_exit_code=3 | |
checksum_length=32 | |
@@ -33,7 +33,6 @@ checksum_length=32 | |
## I know there could be other windows machines that display OS differently or don't have the issue with UTF-8 | |
## but I don't have them to test. | |
## remove this once UTF-8 issue solved. | |
- | |
is_windows="0" | |
if [ -z "${OS}" ] && [ "${OS}" == "Windows_NT" ]; then | |
is_windows="1" | |
@@ -141,8 +140,10 @@ assertHttpRequestEquals() { | |
fi | |
} | |
+ | |
# Check to see if HTTP server is available | |
set +o errexit | |
+ | |
# Allow curl command to fail with a non-zero exit code for this block because | |
# we want to use it to test to see if the server is actually up. | |
for (( i=1; i<=3; i++ )); do | |
@@ -267,6 +268,10 @@ assertHttpRequestEquals "GET" "b/c/'(1).txt" "data/bucket-1/b/c/'(1).txt" | |
assertHttpRequestEquals "GET" "b/e.txt" "data/bucket-1/b/e.txt" | |
+if [ -n "${strip_leading_directory}" ]; then | |
+ assertHttpRequestEquals "GET" "/my-bucket/a.txt" "data/bucket-1/a.txt" | |
+fi | |
+ | |
# These URLs do not work unencoded | |
assertHttpRequestEquals "GET" 'a/plus%2Bplus.txt' "data/bucket-1/a/plus+plus.txt" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment