@@ -22,7 +22,7 @@ set -o pipefail # don't hide errors within pipes
2222nginx_server_proto=" http"
2323nginx_server_host=" localhost"
2424nginx_server_port=" 8989"
25- minio_server= " http://localhost:9090 "
25+
2626test_server=" ${nginx_server_proto} ://${nginx_server_host} :${nginx_server_port} "
2727test_fail_exit_code=2
2828no_dep_exit_code=3
@@ -31,6 +31,12 @@ test_dir="${script_dir}/test"
3131test_compose_config=" ${test_dir} /docker-compose.yaml"
3232test_compose_project=" ngt"
3333
34+ minio_server=" http://localhost:9090"
35+ minio_user=" AKIAIOSFODNN7EXAMPLE"
36+ minio_passwd=" wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
37+ minio_name=" ${test_compose_project} _minio_1"
38+ minio_bucket=" bucket-1"
39+
3440is_windows=" 0"
3541if [ -z " ${OS} " ] && [ " ${OS} " == " Windows_NT" ]; then
3642 is_windows=" 1"
@@ -137,6 +143,12 @@ if ! [ -x "${curl_cmd}" ]; then
137143 exit ${no_dep_exit_code}
138144fi
139145
146+ mc_cmd=" $( command -v mc) "
147+ if ! [ -x " ${mc_cmd} " ]; then
148+ e " required dependency not found: mc not found in the path or not executable"
149+ exit ${no_dep_exit_code}
150+ fi
151+
140152wait_for_it_cmd=" $( command -v wait-for-it || true) "
141153if [ -x " ${wait_for_it_cmd} " ]; then
142154 wait_for_it_installed=1
@@ -168,16 +180,7 @@ compose() {
168180 ${docker_compose_cmd} -f " ${test_compose_config} " -p " ${test_compose_project} " " $@ "
169181}
170182
171- integration_test () {
172- printf " \033[34;1m▶\033[0m"
173- printf " \e[1m Integration test suite for v%s signatures\e[22m\n" " $1 "
174- printf " \033[34;1m▶\033[0m"
175- printf " \e[1m Integration test suite with ALLOW_DIRECTORY_LIST=%s\e[22m\n" " $2 "
176- printf " \033[34;1m▶\033[0m"
177- printf " \e[1m Integration test suite with PROVIDE_INDEX_PAGE=%s\e[22m\n" " $3 "
178- printf " \033[34;1m▶\033[0m"
179- printf " \e[1m Integration test suite with APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=%s\e[22m\n" " $4 "
180-
183+ integration_test_data () {
181184
182185 # Write problematic files to disk if we are not on Windows. Originally,
183186 # these files were checked in, but that prevented the git repository from
@@ -187,23 +190,10 @@ integration_test() {
187190 echo ' We are but selling water next to a river.' > " ${test_dir} " ' /data/bucket-1/a/%@!*()=$#^&|.txt'
188191 fi
189192
190- # See if Minio is already running, if it isn't then we don't need to build it
191- # COMPOSE_COMPATIBILITY=true Supports older style compose filenames with _ vs -
192-
193- if [ -z " $( docker ps -q -f name=${test_compose_project} _minio-_1) " ]; then
194- p " Building Docker Compose environment"
195- COMPOSE_COMPATIBILITY=true AWS_SIGS_VERSION=$1 ALLOW_DIRECTORY_LIST=$2 PROVIDE_INDEX_PAGE=$3 APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=$4 compose up --no-start
196-
197- p " Adding test data to container"
198- echo " Copying contents of ${test_dir} /data to Docker container ${test_compose_project} _minio_1:/"
199- " ${docker_cmd} " cp " ${test_dir} /data" " ${test_compose_project} " _minio_1:/
200- echo " Docker diff output:"
201- " ${docker_cmd} " diff " ${test_compose_project} " _minio_1
202- fi
203-
204193 p " Starting Docker Compose Environment"
205- COMPOSE_COMPATIBILITY=true AWS_SIGS_VERSION=$1 ALLOW_DIRECTORY_LIST=$2 PROVIDE_INDEX_PAGE=$3 APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=$4 compose up -d
206-
194+ # COMPOSE_COMPATIBILITY=true Supports older style compose filenames with _ vs -
195+ COMPOSE_COMPATIBILITY=true compose up -d
196+
207197 if [ " ${wait_for_it_installed} " ]; then
208198 # Hit minio's health check end point to see if it has started up
209199 for (( i= 1 ; i<= 3 ; i++ ))
@@ -216,7 +206,32 @@ integration_test() {
216206 sleep 2
217207 fi
218208 done
209+ fi
210+
211+ p " Adding test data to container"
212+ " ${mc_cmd} " alias set " $minio_name " " $minio_server " " $minio_user " " $minio_passwd "
213+ " ${mc_cmd} " mb " $minio_name /$minio_bucket "
214+ echo " Copying contents of ${test_dir} /data/$minio_bucket to Docker container $minio_name "
215+ " ${mc_cmd} " cp -r " ${test_dir} /data/$minio_bucket /" " $minio_name /"
216+ echo " Docker diff output:"
217+ " ${docker_cmd} " diff " $minio_name "
218+ }
219+
220+ integration_test () {
221+ printf " \033[34;1m▶\033[0m"
222+ printf " \e[1m Integration test suite for v%s signatures\e[22m\n" " $1 "
223+ printf " \033[34;1m▶\033[0m"
224+ printf " \e[1m Integration test suite with ALLOW_DIRECTORY_LIST=%s\e[22m\n" " $2 "
225+ printf " \033[34;1m▶\033[0m"
226+ printf " \e[1m Integration test suite with PROVIDE_INDEX_PAGE=%s\e[22m\n" " $3 "
227+ printf " \033[34;1m▶\033[0m"
228+ printf " \e[1m Integration test suite with APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=%s\e[22m\n" " $4 "
219229
230+ p " Starting Docker Compose Environment"
231+ # COMPOSE_COMPATIBILITY=true Supports older style compose filenames with _ vs -
232+ COMPOSE_COMPATIBILITY=true AWS_SIGS_VERSION=$1 ALLOW_DIRECTORY_LIST=$2 PROVIDE_INDEX_PAGE=$3 APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=$4 compose up -d
233+
234+ if [ " ${wait_for_it_installed} " ]; then
220235 if [ -x " ${wait_for_it_cmd} " ]; then
221236 " ${wait_for_it_cmd} " -h " ${nginx_server_host} " -p " ${nginx_server_port} "
222237 fi
@@ -247,7 +262,8 @@ finish() {
247262
248263 p " Cleaning up Docker compose environment"
249264 compose stop
250- compose rm -f
265+ compose rm -f -v
266+ " ${mc_cmd} " alias rm " $minio_name "
251267
252268 exit ${result}
253269}
@@ -352,6 +368,8 @@ runUnitTestWithSessionToken "s3gateway_test.js"
352368
353369# ## INTEGRATION TESTS
354370
371+ integration_test_data
372+
355373p " Testing API with AWS Signature V2 and allow directory listing off"
356374integration_test 2 0 0 0
357375
0 commit comments