@@ -26,8 +26,19 @@ if ! [ -x "$(command -v jq)" ]; then
2626 sudo apt -y install jq
2727fi
2828
29- message " Build image "
30- docker build -t mendhak/http-https-echo:latest .
29+ message " Check if we're in Github Actions or local run "
30+ if [ -n " ${GITHUB_ACTIONS:- } " ]; then
31+ echo " Github Actions. Image should already be built."
32+ docker images
33+ if [ -z " $( docker images -q mendhak/http-https-echo:testing 2> /dev/null) " ]; then
34+ echo " Docker image mendhak/http-https-echo:testing not found. Exiting."
35+ exit 1
36+ fi
37+ else
38+ echo " Local run. Build image "
39+ docker build -t mendhak/http-https-echo:testing .
40+ fi
41+
3142
3243mkdir -p testarea
3344pushd testarea
@@ -36,7 +47,7 @@ message " Cleaning up from previous test run "
3647docker ps -aq --filter " name=http-echo-tests" | grep -q . && docker stop http-echo-tests && docker rm -f http-echo-tests
3748
3849message " Start container normally "
39- docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
50+ docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
4051sleep 5
4152
4253
@@ -149,7 +160,7 @@ docker stop http-echo-tests
149160sleep 5
150161
151162message " Start container with different internal ports "
152- docker run -d --rm -e HTTP_PORT=8888 -e HTTPS_PORT=9999 --name http-echo-tests -p 8080:8888 -p 8443:9999 -t mendhak/http-https-echo
163+ docker run -d --rm -e HTTP_PORT=8888 -e HTTPS_PORT=9999 --name http-echo-tests -p 8080:8888 -p 8443:9999 -t mendhak/http-https-echo:testing
153164sleep 5
154165
155166message " Make http(s) request, and test the path, method and header. "
@@ -183,7 +194,7 @@ docker stop http-echo-tests
183194sleep 5
184195
185196message " Start container with empty responses "
186- docker run -d --rm -e ECHO_BACK_TO_CLIENT=false --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
197+ docker run -d --rm -e ECHO_BACK_TO_CLIENT=false --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
187198sleep 5
188199REQUEST=$( curl -s -k http://localhost:8080/a/b/c)
189200if [[ -z ${REQUEST} ]]
@@ -200,7 +211,7 @@ docker stop http-echo-tests
200211sleep 5
201212
202213message " Start container with response body only "
203- docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
214+ docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
204215sleep 5
205216RESPONSE=$( curl -s -k -X POST -d ' cauliflower' http://localhost:8080/a/b/c? response_body_only=true)
206217if [[ ${RESPONSE} == " cauliflower" ]]
@@ -218,7 +229,7 @@ docker stop http-echo-tests
218229sleep 5
219230
220231message " Start container with JWT_HEADER "
221- docker run -d --rm -e JWT_HEADER=Authentication --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
232+ docker run -d --rm -e JWT_HEADER=Authentication --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
222233sleep 5
223234
224235REQUEST=$( curl -s -k -H " Authentication: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" https://localhost:8443/ )
@@ -239,7 +250,7 @@ sleep 5
239250
240251
241252message " Start container with LOG_IGNORE_PATH "
242- docker run -d --rm -e LOG_IGNORE_PATH=/ping --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
253+ docker run -d --rm -e LOG_IGNORE_PATH=/ping --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
243254sleep 5
244255curl -s -k -X POST -d " banana" https://localhost:8443/ping > /dev/null
245256
@@ -259,7 +270,7 @@ docker stop http-echo-tests
259270sleep 5
260271
261272message " Start container with DISABLE_REQUEST_LOGS "
262- docker run -d --rm -e DISABLE_REQUEST_LOGS=true --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
273+ docker run -d --rm -e DISABLE_REQUEST_LOGS=true --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
263274sleep 5
264275curl -s -k -X GET https://localhost:8443/strawberry > /dev/null
265276if [ $( docker logs http-echo-tests | grep -c " GET /strawberry HTTP/1.1" ) -eq 0 ]
@@ -278,7 +289,7 @@ sleep 5
278289message " Start container with CORS_CONFIG"
279290docker run -d --rm \
280291 -e CORS_ALLOW_ORIGIN=" http://example.com" -e CORS_ALLOW_HEADERS=" x-custom-test-header" \
281- --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
292+ --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
282293sleep 5
283294# Check if the expected CORS headers are present in the response
284295if curl -s -i http://localhost:8080/ 2>&1 | grep -q -E \
@@ -297,7 +308,7 @@ docker stop http-echo-tests
297308sleep 5
298309
299310message " Start container with LOG_WITHOUT_NEWLINE "
300- docker run -d --rm -e LOG_WITHOUT_NEWLINE=1 --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
311+ docker run -d --rm -e LOG_WITHOUT_NEWLINE=1 --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
301312sleep 5
302313curl -s -k -X POST -d " tiramisu" https://localhost:8443/ > /dev/null
303314
@@ -317,7 +328,7 @@ docker stop http-echo-tests
317328sleep 5
318329
319330message " Check that container is running as a NON ROOT USER by default"
320- docker run -d --name http-echo-tests --rm mendhak/http-https-echo
331+ docker run -d --name http-echo-tests --rm mendhak/http-https-echo:testing
321332
322333WHOAMI=$( docker exec http-echo-tests whoami)
323334
@@ -334,9 +345,9 @@ docker stop http-echo-tests
334345sleep 5
335346
336347message " Check that container is running as user different that the user defined in image"
337- IMAGE_USER=" $( docker image inspect mendhak/http-https-echo -f ' {{ .Config.User }}' ) "
348+ IMAGE_USER=" $( docker image inspect mendhak/http-https-echo:testing -f ' {{ .Config.User }}' ) "
338349CONTAINER_USER=" $(( IMAGE_USER + 1000000 )) "
339- docker run -d --name http-echo-tests --rm -u " ${CONTAINER_USER} " -p 8080:8080 mendhak/http-https-echo
350+ docker run -d --name http-echo-tests --rm -u " ${CONTAINER_USER} " -p 8080:8080 mendhak/http-https-echo:testing
340351sleep 5
341352curl -s http://localhost:8080 > /dev/null
342353
@@ -359,7 +370,7 @@ message " Check that mTLS server responds with client certificate details"
359370openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout privkey.pem -out fullchain.pem \
360371 -subj " /CN=client.example.net" \
361372 -addext " subjectAltName=DNS:client.example.net"
362- docker run -d --rm -e MTLS_ENABLE=1 --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
373+ docker run -d --rm -e MTLS_ENABLE=1 --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
363374sleep 5
364375COMMON_NAME=" $( curl -sk --cert fullchain.pem --key privkey.pem https://localhost:8443/ | jq -r ' .clientCertificate.subject.CN' ) "
365376SAN=" $( curl -sk --cert fullchain.pem --key privkey.pem https://localhost:8443/ | jq -r ' .clientCertificate.subjectaltname' ) "
@@ -412,7 +423,7 @@ docker run -d --rm \
412423 -e HTTPS_CERT_FILE=" ${container_https_cert_file} " \
413424 -v " ${https_key_file} :${container_https_key_file} :ro,z" \
414425 -e HTTPS_KEY_FILE=" ${container_https_key_file} " \
415- --name http-echo-tests -p 8443:8443 -t mendhak/http-https-echo
426+ --name http-echo-tests -p 8443:8443 -t mendhak/http-https-echo:testing
416427sleep 5
417428
418429REQUEST_WITH_STATUS_CODE=" $( curl -s --cacert " $( pwd) /server_fullchain.pem" -o /dev/null -w " %{http_code}" \
@@ -430,7 +441,7 @@ docker stop http-echo-tests
430441sleep 5
431442
432443message " Check that environment variables returned in response if enabled"
433- docker run -d --rm -e ECHO_INCLUDE_ENV_VARS=1 --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
444+ docker run -d --rm -e ECHO_INCLUDE_ENV_VARS=1 --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
434445sleep 5
435446RESPONSE_BODY=" $( curl -sk https://localhost:8443/ | jq -r ' .env.ECHO_INCLUDE_ENV_VARS' ) "
436447
@@ -447,7 +458,7 @@ docker stop http-echo-tests
447458sleep 5
448459
449460message " Check that environment variables are not present in response by default"
450- docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
461+ docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
451462sleep 5
452463RESPONSE_BODY_ENV_CHECK=" $( curl -sk https://localhost:8443/ | jq ' has("env")' ) "
453464
@@ -464,7 +475,7 @@ docker stop http-echo-tests
464475sleep 5
465476
466477message " Start container with PROMETHEUS disabled "
467- docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
478+ docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
468479sleep 5
469480curl -s -k -X POST -d " tiramisu" https://localhost:8443/ > /dev/null
470481
@@ -485,7 +496,7 @@ docker stop http-echo-tests
485496sleep 5
486497
487498message " Start container with PROMETHEUS enabled "
488- docker run -d -e PROMETHEUS_ENABLED=true --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
499+ docker run -d -e PROMETHEUS_ENABLED=true --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
489500sleep 5
490501curl -s -k -X POST -d " tiramisu" https://localhost:8443/ > /dev/null
491502
0 commit comments