From def8198fb099ce18c15d5b23c97c79209c34265a Mon Sep 17 00:00:00 2001 From: mendhak Date: Fri, 3 Apr 2026 21:27:27 +0100 Subject: [PATCH 1/9] Improve tests speed --- tests.sh | 142 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 91 insertions(+), 51 deletions(-) diff --git a/tests.sh b/tests.sh index 73cca7f..9a597ab 100755 --- a/tests.sh +++ b/tests.sh @@ -21,6 +21,27 @@ function passed { echo ${GREEN}✓$1${RESTORE} } +wait_for_ready() { + local check_path="${1:-/}" + for i in {1..30}; do + if curl -sf "http://localhost:8080${check_path}" >/dev/null 2>&1; then + return 0 + fi + sleep 0.5 + done + echo "Container failed to start"; exit 1 +} + +wait_for_removed() { + for i in {1..30}; do + if ! docker ps -q --filter "name=http-echo-tests" | grep -q .; then + return 0 + fi + sleep 0.5 + done + echo "Container failed to stop"; exit 1 +} + if ! [ -x "$(command -v jq)" ]; then message "JQ not installed. Installing..." sudo apt -y install jq @@ -44,11 +65,12 @@ mkdir -p testarea pushd testarea message " Cleaning up from previous test run " -docker ps -aq --filter "name=http-echo-tests" | grep -q . && docker stop http-echo-tests && docker rm -f http-echo-tests +docker rm -f http-echo-tests 2>/dev/null || true +wait_for_removed message " Start container normally " docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing -sleep 10 +wait_for_ready message " Make http(s) request, and test the path, method, header and status code. " @@ -178,11 +200,11 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Start container with max header size " docker run -d --rm -e MAX_HEADER_SIZE=1000 --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing -sleep 10 +wait_for_ready message " Make request with a header within limit." LARGE_HEADER_VALUE=$(head -c 600 /dev/null -if [ $(docker logs http-echo-tests | wc -l) == 2 ] && \ +# There should be 3 lines, the "listening on...", the /ping ready test, and the /ping POST test. +if [ $(docker logs http-echo-tests | wc -l) == 3 ] && \ ! [ $(docker logs http-echo-tests | grep banana) ] then passed "LOG_IGNORE_PATH ignored the /ping path" @@ -319,14 +344,16 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Start container with LOG_IGNORE_PATH (regex path)" docker run -d --rm -e LOG_IGNORE_PATH="^\/ping|^\/health|^\/metrics" --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing -sleep 5 +wait_for_ready "/health" + curl -s -k -X POST -d "banana" https://localhost:8443/metrics > /dev/null -if [ $(docker logs http-echo-tests | wc -l) == 2 ] && \ +# There should be 3 lines, the "listening on...", the /health ready test, and the /metrics POST test. +if [ $(docker logs http-echo-tests | wc -l) == 3 ] && \ ! [ $(docker logs http-echo-tests | grep banana) ] then passed "LOG_IGNORE_PATH ignored the /metrics path" @@ -351,14 +378,16 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Start container with LOG_IGNORE_PATH (ignore all paths) " docker run -d --rm -e LOG_IGNORE_PATH=".*" --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing -sleep 5 +wait_for_ready "/hello" + curl -s -k -X POST -d "banana" https://localhost:8443/ > /dev/null -if [ $(docker logs http-echo-tests | wc -l) == 2 ] && \ +# There should be 3 lines, the "listening on", the "/hello" ready test, and the POST banana test. +if [ $(docker logs http-echo-tests | wc -l) == 3 ] && \ ! [ $(docker logs http-echo-tests | grep banana) ] then passed "LOG_IGNORE_PATH ignored all paths" @@ -370,12 +399,13 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Start container with DISABLE_REQUEST_LOGS " 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 -sleep 5 +wait_for_ready "/healthy" + curl -s -k -X GET https://localhost:8443/strawberry > /dev/null if [ $(docker logs http-echo-tests | grep -c "GET /strawberry HTTP/1.1") -eq 0 ] then @@ -388,13 +418,14 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Start container with CORS_CONFIG" docker run -d --rm \ -e CORS_ALLOW_ORIGIN="http://example.com" -e CORS_ALLOW_HEADERS="x-custom-test-header" \ --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing -sleep 5 +wait_for_ready + # Check if the expected CORS headers are present in the response if curl -s -i http://localhost:8080/ 2>&1 | grep -q -E \ "Access-Control-Allow-Headers: x-custom-test-header" && @@ -409,14 +440,16 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Start container with LOG_WITHOUT_NEWLINE " 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 -sleep 5 +wait_for_ready + curl -s -k -X POST -d "tiramisu" https://localhost:8443/ > /dev/null -if [ $(docker logs http-echo-tests | wc -l) == 3 ] && \ +# There will be 4 lines, the Listening on, the / ready test and response, the POST test and response +if [ $(docker logs http-echo-tests | wc -l) == 5 ] && \ [ $(docker logs http-echo-tests | grep tiramisu) ] then passed "LOG_WITHOUT_NEWLINE logged output in single line" @@ -429,7 +462,7 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Check that container is running as a NON ROOT USER by default" docker run -d --name http-echo-tests --rm mendhak/http-https-echo:testing @@ -446,13 +479,14 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Check that container is running as user different that the user defined in image" IMAGE_USER="$(docker image inspect mendhak/http-https-echo:testing -f '{{ .Config.User }}')" CONTAINER_USER="$((IMAGE_USER + 1000000))" docker run -d --name http-echo-tests --rm -u "${CONTAINER_USER}" -p 8080:8080 mendhak/http-https-echo:testing -sleep 5 +wait_for_ready + curl -s http://localhost:8080 > /dev/null WHOAMI="$(docker exec http-echo-tests id -u)" @@ -467,7 +501,7 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Check that mTLS server responds with client certificate details" # Generate a new self signed cert locally @@ -475,7 +509,8 @@ openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout testpk.pem -subj "/CN=client.example.net" \ -addext "subjectAltName=DNS:client.example.net" docker run -d --rm -e MTLS_ENABLE=1 --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing -sleep 5 +wait_for_ready + COMMON_NAME="$(curl -sk --cert fullchain.pem --key testpk.pem https://localhost:8443/ | jq -r '.clientCertificate.subject.CN')" SAN="$(curl -sk --cert fullchain.pem --key testpk.pem https://localhost:8443/ | jq -r '.clientCertificate.subjectaltname')" if [ "$COMMON_NAME" == "client.example.net" ] && [ "$SAN" == "DNS:client.example.net" ] @@ -508,7 +543,7 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Check that SSL certificate and private key are loaded from custom location" cert_common_name="server.example.net" @@ -542,11 +577,12 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Check that environment variables returned in response if enabled" 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 -sleep 5 +wait_for_ready + RESPONSE_BODY="$(curl -sk https://localhost:8443/ | jq -r '.env.ECHO_INCLUDE_ENV_VARS')" if [ "$RESPONSE_BODY" == "1" ] @@ -559,11 +595,12 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Check that environment variables are not present in response by default" docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing -sleep 5 +wait_for_ready + RESPONSE_BODY_ENV_CHECK="$(curl -sk https://localhost:8443/ | jq 'has("env")')" if [ "$RESPONSE_BODY_ENV_CHECK" == "false" ] @@ -576,11 +613,12 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Start container with PROMETHEUS disabled " docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing -sleep 5 +wait_for_ready + curl -s -k -X POST -d "tiramisu" https://localhost:8443/ > /dev/null # grep for http_request_duration_seconds_count ensure it is not present at /metric path @@ -597,11 +635,12 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Start container with PROMETHEUS enabled " docker run -d -e PROMETHEUS_ENABLED=true --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing -sleep 5 +wait_for_ready + curl -s -k -X POST -d "tiramisu" https://localhost:8443/ > /dev/null METRICS_CHECK="$(curl -sk http://localhost:8080/metrics | grep http_request_duration_seconds_count )" @@ -617,12 +656,12 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Start container with PRESERVE_HEADER_CASE enabled " docker run -d -e PRESERVE_HEADER_CASE=true --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing +wait_for_ready -sleep 5 HEADER_CASE_CHECK=$(curl -s -H "prEseRVe-CaSE: A1b2C3" -H 'x-a-b: 999' -H 'X-a-B: 13' localhost:8080 | jq -r '.headers."prEseRVe-CaSE"') if [[ "$HEADER_CASE_CHECK" == "A1b2C3" ]] then @@ -634,12 +673,13 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Start container with a custom response body from a file " echo "

Hello World

" > test.html docker run -d --rm -v ${PWD}/test.html:/app/test.html --name http-echo-tests -p 8080:8080 -e OVERRIDE_RESPONSE_BODY_FILE_PATH=/test.html -t mendhak/http-https-echo:testing -sleep 5 +wait_for_ready + RESPONSE_BODY=$(curl -s http://localhost:8080) if [[ "$RESPONSE_BODY" == "

Hello World

" ]] then @@ -651,13 +691,13 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Start container with signed cookies support " # Set cookie secret for signing/verifying cookies docker run -d --rm -e COOKIE_SECRET=mysecretkey123 \ --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing -sleep 5 +wait_for_ready SIGNED_COOKIE=$(node -e "var crypto = require('crypto'); @@ -684,12 +724,12 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed message " Check that regular cookies are returned in response " docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing -sleep 5 +wait_for_ready RESPONSE=$(curl -s http://localhost:8080/ -H "Cookie: foo=bar; baz=qux") @@ -705,7 +745,7 @@ fi message " Stop containers " docker stop http-echo-tests -sleep 5 +wait_for_removed popd rm -rf testarea From 69c03d9818f2b1daec5b5ed370b0ade8534a163e Mon Sep 17 00:00:00 2001 From: mendhak Date: Fri, 3 Apr 2026 21:30:09 +0100 Subject: [PATCH 2/9] Another sleep replacement --- tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests.sh b/tests.sh index 9a597ab..225fccc 100755 --- a/tests.sh +++ b/tests.sh @@ -562,8 +562,8 @@ docker run -d --rm \ -e HTTPS_CERT_FILE="${container_https_cert_file}" \ -v "${https_key_file}:${container_https_key_file}:ro,z" \ -e HTTPS_KEY_FILE="${container_https_key_file}" \ - --name http-echo-tests -p 8443:8443 -t mendhak/http-https-echo:testing -sleep 5 + --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing +wait_for_ready REQUEST_WITH_STATUS_CODE="$(curl -s --cacert "$(pwd)/server_fullchain.pem" -o /dev/null -w "%{http_code}" \ --resolve "${cert_common_name}:8443:127.0.0.1" "https://${cert_common_name}:8443/hello-world")" From 48da00d3dbca309e241a05c3645961563a3e8cab Mon Sep 17 00:00:00 2001 From: mendhak Date: Fri, 3 Apr 2026 21:30:27 +0100 Subject: [PATCH 3/9] Group dependabot stuff together --- .github/dependabot.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7ee231c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + open-pull-requests-limit: 10 + groups: + production-dependencies: + patterns: + - "*" From 00d9ed7bca96885b96d857d7f26639ca8f46c512 Mon Sep 17 00:00:00 2001 From: mendhak Date: Fri, 3 Apr 2026 21:44:56 +0100 Subject: [PATCH 4/9] Trap and clean up --- tests.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests.sh b/tests.sh index 225fccc..f1be0e7 100755 --- a/tests.sh +++ b/tests.sh @@ -34,7 +34,7 @@ wait_for_ready() { wait_for_removed() { for i in {1..30}; do - if ! docker ps -q --filter "name=http-echo-tests" | grep -q .; then + if ! docker ps -aq --filter "name=http-echo-tests" | grep -q .; then return 0 fi sleep 0.5 @@ -42,6 +42,16 @@ wait_for_removed() { echo "Container failed to stop"; exit 1 } +cleanup() { + echo "Cleaning up..." + docker stop http-echo-tests 2>/dev/null || true + docker rm http-echo-tests 2>/dev/null || true + popd 2>/dev/null || true + rm -rf testarea +} + +trap cleanup EXIT + if ! [ -x "$(command -v jq)" ]; then message "JQ not installed. Installing..." sudo apt -y install jq @@ -747,6 +757,4 @@ message " Stop containers " docker stop http-echo-tests wait_for_removed -popd -rm -rf testarea message "DONE" From 538a4984dff114c11af5c9d3c7ca1bbbcab8fb85 Mon Sep 17 00:00:00 2001 From: mendhak Date: Fri, 3 Apr 2026 22:17:51 +0100 Subject: [PATCH 5/9] Quote variables --- tests.sh | 106 ++++++++++++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 59 deletions(-) diff --git a/tests.sh b/tests.sh index f1be0e7..9be476c 100755 --- a/tests.sh +++ b/tests.sh @@ -85,36 +85,33 @@ wait_for_ready message " Make http(s) request, and test the path, method, header and status code. " REQUEST=$(curl -s -k -X PUT -H "Arbitrary:Header" -d aaa=bbb 'https://localhost:8443/hello-world?ccc=ddd&myquery=98765') -if [ $(echo $REQUEST | jq -r '.path') == '/hello-world' ] && \ - [ $(echo $REQUEST | jq -r '.method') == 'PUT' ] && \ - [ $(echo $REQUEST | jq -r '.query.myquery') == '98765' ] && \ - [ $(echo $REQUEST | jq -r '.headers.arbitrary') == 'Header' ] -then +if [ "$(echo "$REQUEST" | jq -r '.path')" == '/hello-world' ] && \ + [ "$(echo "$REQUEST" | jq -r '.method')" == 'PUT' ] && \ + [ "$(echo "$REQUEST" | jq -r '.query.myquery')" == '98765' ] && \ + [ "$(echo "$REQUEST" | jq -r '.headers.arbitrary')" == 'Header' ]; then passed "HTTPS request passed." else failed "HTTPS request failed." - echo $REQUEST | jq + echo "$REQUEST" | jq exit 1 fi REQUEST_WITH_STATUS_CODE=$(curl -s -k -o /dev/null -w "%{http_code}" -H "x-set-response-status-code: 404" https://localhost:8443/hello-world) REQUEST_WITH_STATUS_CODE_V=$(curl -v -k -o /dev/null -w "%{http_code}" -H "x-set-response-status-code: 404" https://localhost:8443/hello-world) -if [ $(echo $REQUEST_WITH_STATUS_CODE == '404') ] -then +if [ "$REQUEST_WITH_STATUS_CODE" = "404" ]; then passed "HTTPS status code header passed." else failed "HTTPS status code header failed." - echo $REQUEST_WITH_STATUS_CODE_V + echo "$REQUEST_WITH_STATUS_CODE_V" exit 1 fi REQUEST_WITH_STATUS_CODE=$(curl -s -k -o /dev/null -w "%{http_code}" https://localhost:8443/status/test?x-set-response-status-code=419) REQUEST_WITH_STATUS_CODE_V=$(curl -v -k -o /dev/null -w "%{http_code}" https://localhost:8443/hello-world?x-set-response-status-code=419) -if [ $(echo $REQUEST_WITH_STATUS_CODE == '419') ] -then +if [ "$REQUEST_WITH_STATUS_CODE" = "419" ]; then passed "HTTPS status code querystring passed." else failed "HTTPS status code querystring failed." - echo $REQUEST_WITH_STATUS_CODE_V + echo "$REQUEST_WITH_STATUS_CODE_V" exit 1 fi @@ -122,7 +119,7 @@ REQUEST_WITH_CONTENT_TYPE_HEADER=$(curl -o /dev/null -k -Ss -w "%{content_type}" if [[ "$REQUEST_WITH_CONTENT_TYPE_HEADER" == *"aaaa/bbbb"* ]]; then passed "Request with custom response type header, passed" else - echo $REQUEST_WITH_CONTENT_TYPE_HEADER + echo "$REQUEST_WITH_CONTENT_TYPE_HEADER" failed "Request with custom response type header, failed." exit 1 fi @@ -131,7 +128,7 @@ REQUEST_WITH_CONTENT_TYPE_PARAMETER=$(curl -o /dev/null -k -Ss -w "%{content_typ if [[ "$REQUEST_WITH_CONTENT_TYPE_PARAMETER" == *"jellyfish/cabbage"* ]]; then passed "Request with custom response type parameter, passed" else - echo $REQUEST_WITH_CONTENT_TYPE_PARAMETER + echo "$REQUEST_WITH_CONTENT_TYPE_PARAMETER" failed "Request with custom response type parameter, failed." exit 1 fi @@ -142,7 +139,7 @@ if [[ $(echo "$REQUEST_WITH_SLEEP_MS>5" | bc -l) == 1 ]]; then passed "Request header with response delay passed" else failed "Request header with response delay failed" - echo $REQUEST_WITH_SLEEP_MS + echo "$REQUEST_WITH_SLEEP_MS" exit 1 fi @@ -151,7 +148,7 @@ if [[ $(echo "$REQUEST_WITH_SLEEP_MS>4" | bc -l) == 1 ]]; then passed "Request query with response delay passed" else failed "Request query with response delay failed" - echo $REQUEST_WITH_SLEEP_MS + echo "$REQUEST_WITH_SLEEP_MS" exit 1 fi @@ -160,51 +157,48 @@ if [[ $(echo "$REQUEST_WITH_INVALID_SLEEP_MS<2" | bc -l) == 1 ]]; then passed "Request with invalid response delay passed" else failed "Request with invalid response delay failed" - echo $REQUEST_WITH_INVALID_SLEEP_MS + echo "$REQUEST_WITH_INVALID_SLEEP_MS" exit 1 fi REQUEST=$(curl -s -X PUT -H "Arbitrary:Header" -d aaa=bbb http://localhost:8080/hello-world) -if [ $(echo $REQUEST | jq -r '.path') == '/hello-world' ] && \ - [ $(echo $REQUEST | jq -r '.method') == 'PUT' ] && \ - [ $(echo $REQUEST | jq -r '.headers.arbitrary') == 'Header' ] -then +if [ "$(echo "$REQUEST" | jq -r '.path')" == '/hello-world' ] && \ + [ "$(echo "$REQUEST" | jq -r '.method')" == 'PUT' ] && \ + [ "$(echo "$REQUEST" | jq -r '.headers.arbitrary')" == 'Header' ]; then passed "HTTP request with arbitrary header passed." else failed "HTTP request with arbitrary header failed." - echo $REQUEST | jq + echo "$REQUEST" | jq exit 1 fi message " Make JSON request, and test that json is in the output. " REQUEST=$(curl -s -X POST -H "Content-Type: application/json" -d '{"a":"b"}' http://localhost:8080/) -if [ $(echo $REQUEST | jq -r '.json.a') == 'b' ] -then +if [ "$(echo "$REQUEST" | jq -r '.json.a')" == 'b' ]; then passed "JSON test passed." else failed "JSON test failed." - echo $REQUEST | jq + echo "$REQUEST" | jq exit 1 fi message " Make JSON request with gzip Content-Encoding, and test that json is in the output. " REQUEST=$(echo -n '{"a":"b"}' | gzip | curl -s -X POST -H "Content-Encoding: gzip" -H "Content-Type: application/json" --data-binary @- http://localhost:8080/) -if [ $(echo $REQUEST | jq -r '.json.a') == 'b' ] -then +if [ "$(echo "$REQUEST" | jq -r '.json.a')" == 'b' ]; then passed "JSON test passed." else failed "JSON test failed." - echo $REQUEST | jq + echo "$REQUEST" | jq exit 1 fi REQUEST=$(curl -s -X POST -H "Content-Type: application/json" -d 'not-json' http://localhost:8080) -if [ $(echo $REQUEST | jq -r '.json') == 'null' ]; then +if [ "$(echo "$REQUEST" | jq -r '.json')" == 'null' ]; then passed "JSON with Invalid Body test passed." else failed "JSON with Invalid Body test failed." - echo $REQUEST | jq + echo "$REQUEST" | jq exit 1 fi @@ -220,11 +214,11 @@ message " Make request with a header within limit." LARGE_HEADER_VALUE=$(head -c 600 &1) -if echo $REQUEST | grep -q "HTTP/1.1 431 Request Header Fields Too Large"; then +if echo "$REQUEST" | grep -q "HTTP/1.1 431 Request Header Fields Too Large"; then passed "Large header test resulted in HTTP 431." else failed "Large header test failed." - echo $REQUEST + echo "$REQUEST" exit 1 fi @@ -250,26 +244,24 @@ wait_for_ready message " Make http(s) request, and test the path, method and header. " REQUEST=$(curl -s -k -X PUT -H "Arbitrary:Header" -d aaa=bbb https://localhost:8443/hello-world) -if [ $(echo $REQUEST | jq -r '.path') == '/hello-world' ] && \ - [ $(echo $REQUEST | jq -r '.method') == 'PUT' ] && \ - [ $(echo $REQUEST | jq -r '.headers.arbitrary') == 'Header' ] -then +if [ "$(echo "$REQUEST" | jq -r '.path')" == '/hello-world' ] && \ + [ "$(echo "$REQUEST" | jq -r '.method')" == 'PUT' ] && \ + [ "$(echo "$REQUEST" | jq -r '.headers.arbitrary')" == 'Header' ]; then passed "HTTPS request passed." else failed "HTTPS request failed." - echo $REQUEST | jq + echo "$REQUEST" | jq exit 1 fi REQUEST=$(curl -s -X PUT -H "Arbitrary:Header" -d aaa=bbb http://localhost:8080/hello-world) -if [ $(echo $REQUEST | jq -r '.path') == '/hello-world' ] && \ - [ $(echo $REQUEST | jq -r '.method') == 'PUT' ] && \ - [ $(echo $REQUEST | jq -r '.headers.arbitrary') == 'Header' ] -then +if [ "$(echo "$REQUEST" | jq -r '.path')" == '/hello-world' ] && \ + [ "$(echo "$REQUEST" | jq -r '.method')" == 'PUT' ] && \ + [ "$(echo "$REQUEST" | jq -r '.headers.arbitrary')" == 'Header' ]; then passed "HTTP request passed." else failed "HTTP request failed." - echo $REQUEST | jq + echo "$REQUEST" | jq exit 1 fi @@ -300,12 +292,11 @@ message " Start container with response body only " docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing wait_for_ready RESPONSE=$(curl -s -k -X POST -d 'cauliflower' http://localhost:8080/a/b/c?response_body_only=true) -if [[ ${RESPONSE} == "cauliflower" ]] -then +if [[ "$RESPONSE" == "cauliflower" ]]; then passed "Response body only received." else failed "Expected response body only." - echo $RESPONSE + echo "$RESPONSE" exit 1 fi @@ -319,14 +310,13 @@ docker run -d --rm -e JWT_HEADER=Authentication --name http-echo-tests -p 8080:8 wait_for_ready REQUEST=$(curl -s -k -H "Authentication: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" https://localhost:8443/ ) -if [ $(echo $REQUEST | jq -r '.jwt.header.typ') == 'JWT' ] && \ - [ $(echo $REQUEST | jq -r '.jwt.header.alg') == 'HS256' ] && \ - [ $(echo $REQUEST | jq -r '.jwt.payload.sub') == '1234567890' ] -then +if [ "$(echo "$REQUEST" | jq -r '.jwt.header.typ')" == 'JWT' ] && \ + [ "$(echo "$REQUEST" | jq -r '.jwt.header.alg')" == 'HS256' ] && \ + [ "$(echo "$REQUEST" | jq -r '.jwt.payload.sub')" == '1234567890' ]; then passed "JWT request passed." else failed "JWT request failed." - echo $REQUEST | jq + echo "$REQUEST" | jq exit 1 fi @@ -723,12 +713,11 @@ console.log(sign('my-value','mysecretkey123'));") RESPONSE=$(curl -s http://localhost:8080/ -H "Cookie: mysigned=s:${SIGNED_COOKIE}") -if [ $(echo $RESPONSE | jq -r '.signedCookies.mysigned') == 'my-value' ] -then +if [ "$(echo "$RESPONSE" | jq -r '.signedCookies.mysigned')" == 'my-value' ]; then passed "Signed cookie test passed." else failed "Signed cookie test failed." - echo $RESPONSE | jq + echo "$RESPONSE" | jq exit 1 fi @@ -743,13 +732,12 @@ wait_for_ready RESPONSE=$(curl -s http://localhost:8080/ -H "Cookie: foo=bar; baz=qux") -if [ $(echo $RESPONSE | jq -r '.cookies.foo') == 'bar' ] && \ - [ $(echo $RESPONSE | jq -r '.cookies.baz') == 'qux' ] -then +if [ "$(echo "$RESPONSE" | jq -r '.cookies.foo')" == 'bar' ] && \ + [ "$(echo "$RESPONSE" | jq -r '.cookies.baz')" == 'qux' ]; then passed "Cookies returned in response test passed." else failed "Cookies returned in response test failed." - echo $RESPONSE | jq + echo "$RESPONSE" | jq exit 1 fi From 2f9e5e6c2764a46789fa2f9414522e90bbccd054 Mon Sep 17 00:00:00 2001 From: mendhak Date: Fri, 3 Apr 2026 22:23:28 +0100 Subject: [PATCH 6/9] A little more consistency with square brackets --- tests.sh | 104 +++++++++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/tests.sh b/tests.sh index 9be476c..a7df672 100755 --- a/tests.sh +++ b/tests.sh @@ -5,7 +5,7 @@ set -euo pipefail function message { echo "" echo "---------------------------------------------------------------" - echo $1 + echo "$1" echo "---------------------------------------------------------------" } @@ -14,11 +14,11 @@ RED=$(echo -en '\033[01;31m') GREEN=$(echo -en '\033[01;32m') function failed { - echo ${RED}✗$1${RESTORE} + echo "${RED}✗${1}${RESTORE}" } function passed { - echo ${GREEN}✓$1${RESTORE} + echo "${GREEN}✓${1}${RESTORE}" } wait_for_ready() { @@ -52,16 +52,16 @@ cleanup() { trap cleanup EXIT -if ! [ -x "$(command -v jq)" ]; then +if ! command -v jq >/dev/null 2>&1; then message "JQ not installed. Installing..." sudo apt -y install jq fi message " Check if we're in Github Actions or local run " -if [ -n "${GITHUB_ACTIONS:-}" ]; then +if [[ -n "${GITHUB_ACTIONS:-}" ]]; then echo " Github Actions. Image should already be built." docker images - if [ -z "$(docker images -q mendhak/http-https-echo:testing 2> /dev/null)" ]; then + if [[ -z "$(docker images -q mendhak/http-https-echo:testing 2> /dev/null)" ]]; then echo "Docker image mendhak/http-https-echo:testing not found. Exiting." exit 1 fi @@ -85,10 +85,10 @@ wait_for_ready message " Make http(s) request, and test the path, method, header and status code. " REQUEST=$(curl -s -k -X PUT -H "Arbitrary:Header" -d aaa=bbb 'https://localhost:8443/hello-world?ccc=ddd&myquery=98765') -if [ "$(echo "$REQUEST" | jq -r '.path')" == '/hello-world' ] && \ - [ "$(echo "$REQUEST" | jq -r '.method')" == 'PUT' ] && \ - [ "$(echo "$REQUEST" | jq -r '.query.myquery')" == '98765' ] && \ - [ "$(echo "$REQUEST" | jq -r '.headers.arbitrary')" == 'Header' ]; then +if [[ "$(echo "$REQUEST" | jq -r '.path')" == '/hello-world' ]] && \ + [[ "$(echo "$REQUEST" | jq -r '.method')" == 'PUT' ]] && \ + [[ "$(echo "$REQUEST" | jq -r '.query.myquery')" == '98765' ]] && \ + [[ "$(echo "$REQUEST" | jq -r '.headers.arbitrary')" == 'Header' ]]; then passed "HTTPS request passed." else failed "HTTPS request failed." @@ -97,7 +97,7 @@ else fi REQUEST_WITH_STATUS_CODE=$(curl -s -k -o /dev/null -w "%{http_code}" -H "x-set-response-status-code: 404" https://localhost:8443/hello-world) REQUEST_WITH_STATUS_CODE_V=$(curl -v -k -o /dev/null -w "%{http_code}" -H "x-set-response-status-code: 404" https://localhost:8443/hello-world) -if [ "$REQUEST_WITH_STATUS_CODE" = "404" ]; then +if [[ "$REQUEST_WITH_STATUS_CODE" == "404" ]]; then passed "HTTPS status code header passed." else failed "HTTPS status code header failed." @@ -107,7 +107,7 @@ fi REQUEST_WITH_STATUS_CODE=$(curl -s -k -o /dev/null -w "%{http_code}" https://localhost:8443/status/test?x-set-response-status-code=419) REQUEST_WITH_STATUS_CODE_V=$(curl -v -k -o /dev/null -w "%{http_code}" https://localhost:8443/hello-world?x-set-response-status-code=419) -if [ "$REQUEST_WITH_STATUS_CODE" = "419" ]; then +if [[ "$REQUEST_WITH_STATUS_CODE" == "419" ]]; then passed "HTTPS status code querystring passed." else failed "HTTPS status code querystring failed." @@ -162,9 +162,9 @@ else fi REQUEST=$(curl -s -X PUT -H "Arbitrary:Header" -d aaa=bbb http://localhost:8080/hello-world) -if [ "$(echo "$REQUEST" | jq -r '.path')" == '/hello-world' ] && \ - [ "$(echo "$REQUEST" | jq -r '.method')" == 'PUT' ] && \ - [ "$(echo "$REQUEST" | jq -r '.headers.arbitrary')" == 'Header' ]; then +if [[ "$(echo "$REQUEST" | jq -r '.path')" == '/hello-world' ]] && \ + [[ "$(echo "$REQUEST" | jq -r '.method')" == 'PUT' ]] && \ + [[ "$(echo "$REQUEST" | jq -r '.headers.arbitrary')" == 'Header' ]]; then passed "HTTP request with arbitrary header passed." else failed "HTTP request with arbitrary header failed." @@ -174,7 +174,7 @@ fi message " Make JSON request, and test that json is in the output. " REQUEST=$(curl -s -X POST -H "Content-Type: application/json" -d '{"a":"b"}' http://localhost:8080/) -if [ "$(echo "$REQUEST" | jq -r '.json.a')" == 'b' ]; then +if [[ "$(echo "$REQUEST" | jq -r '.json.a')" == 'b' ]]; then passed "JSON test passed." else failed "JSON test failed." @@ -185,7 +185,7 @@ fi message " Make JSON request with gzip Content-Encoding, and test that json is in the output. " REQUEST=$(echo -n '{"a":"b"}' | gzip | curl -s -X POST -H "Content-Encoding: gzip" -H "Content-Type: application/json" --data-binary @- http://localhost:8080/) -if [ "$(echo "$REQUEST" | jq -r '.json.a')" == 'b' ]; then +if [[ "$(echo "$REQUEST" | jq -r '.json.a')" == 'b' ]]; then passed "JSON test passed." else failed "JSON test failed." @@ -194,7 +194,7 @@ else fi REQUEST=$(curl -s -X POST -H "Content-Type: application/json" -d 'not-json' http://localhost:8080) -if [ "$(echo "$REQUEST" | jq -r '.json')" == 'null' ]; then +if [[ "$(echo "$REQUEST" | jq -r '.json')" == 'null' ]]; then passed "JSON with Invalid Body test passed." else failed "JSON with Invalid Body test failed." @@ -214,7 +214,7 @@ message " Make request with a header within limit." LARGE_HEADER_VALUE=$(head -c 600 /dev/null # There should be 3 lines, the "listening on...", the /ping ready test, and the /ping POST test. -if [ $(docker logs http-echo-tests | wc -l) == 3 ] && \ - ! [ $(docker logs http-echo-tests | grep banana) ] +if [[ "$(docker logs http-echo-tests | wc -l)" == 3 ]] && \ + ! docker logs http-echo-tests | grep -q banana then passed "LOG_IGNORE_PATH ignored the /ping path" else @@ -353,8 +353,8 @@ wait_for_ready "/health" curl -s -k -X POST -d "banana" https://localhost:8443/metrics > /dev/null # There should be 3 lines, the "listening on...", the /health ready test, and the /metrics POST test. -if [ $(docker logs http-echo-tests | wc -l) == 3 ] && \ - ! [ $(docker logs http-echo-tests | grep banana) ] +if [[ "$(docker logs http-echo-tests | wc -l)" == 3 ]] && \ + ! docker logs http-echo-tests | grep -q banana then passed "LOG_IGNORE_PATH ignored the /metrics path" else @@ -366,7 +366,7 @@ fi # Test a positive case where the path is not ignored curl -s -k -X POST -d "strawberry" https://localhost:8443/veryvisible > /dev/null -if [[ $(docker logs http-echo-tests | grep strawberry) ]] +if docker logs http-echo-tests | grep -q strawberry then passed "LOG_IGNORE_PATH didn't ignore the /veryvisible path" else @@ -387,8 +387,8 @@ wait_for_ready "/hello" curl -s -k -X POST -d "banana" https://localhost:8443/ > /dev/null # There should be 3 lines, the "listening on", the "/hello" ready test, and the POST banana test. -if [ $(docker logs http-echo-tests | wc -l) == 3 ] && \ - ! [ $(docker logs http-echo-tests | grep banana) ] +if [[ "$(docker logs http-echo-tests | wc -l)" == 3 ]] && \ + ! docker logs http-echo-tests | grep -q banana then passed "LOG_IGNORE_PATH ignored all paths" else @@ -407,7 +407,7 @@ docker run -d --rm -e DISABLE_REQUEST_LOGS=true --name http-echo-tests -p 8080:8 wait_for_ready "/healthy" curl -s -k -X GET https://localhost:8443/strawberry > /dev/null -if [ $(docker logs http-echo-tests | grep -c "GET /strawberry HTTP/1.1") -eq 0 ] +if [[ "$(docker logs http-echo-tests | grep -c "GET /strawberry HTTP/1.1")" -eq 0 ]] then passed "DISABLE_REQUEST_LOGS disabled Express HTTP logging" else @@ -449,8 +449,8 @@ wait_for_ready curl -s -k -X POST -d "tiramisu" https://localhost:8443/ > /dev/null # There will be 4 lines, the Listening on, the / ready test and response, the POST test and response -if [ $(docker logs http-echo-tests | wc -l) == 5 ] && \ - [ $(docker logs http-echo-tests | grep tiramisu) ] +if [[ "$(docker logs http-echo-tests | wc -l)" == 5 ]] && \ + docker logs http-echo-tests | grep -q tiramisu then passed "LOG_WITHOUT_NEWLINE logged output in single line" else @@ -469,7 +469,7 @@ docker run -d --name http-echo-tests --rm mendhak/http-https-echo:testing WHOAMI=$(docker exec http-echo-tests whoami) -if [ "$WHOAMI" == "node" ] +if [[ "$WHOAMI" == "node" ]] then passed "Running as non root user" else @@ -491,7 +491,7 @@ curl -s http://localhost:8080 > /dev/null WHOAMI="$(docker exec http-echo-tests id -u)" -if [ "$WHOAMI" == "$CONTAINER_USER" ] +if [[ "$WHOAMI" == "$CONTAINER_USER" ]] then passed "Running as $CONTAINER_USER user" else @@ -513,7 +513,7 @@ wait_for_ready COMMON_NAME="$(curl -sk --cert fullchain.pem --key testpk.pem https://localhost:8443/ | jq -r '.clientCertificate.subject.CN')" SAN="$(curl -sk --cert fullchain.pem --key testpk.pem https://localhost:8443/ | jq -r '.clientCertificate.subjectaltname')" -if [ "$COMMON_NAME" == "client.example.net" ] && [ "$SAN" == "DNS:client.example.net" ] +if [[ "$COMMON_NAME" == "client.example.net" && "$SAN" == "DNS:client.example.net" ]] then passed "Client certificate details are present in the output" else @@ -523,7 +523,7 @@ fi message " Check if certificate is not passed, then client certificate details are empty" CLIENT_CERT="$(curl -sk https://localhost:8443/ | jq -r '.clientCertificate')" -if [ "$CLIENT_CERT" == "{}" ] +if [[ "$CLIENT_CERT" == "{}" ]] then passed "Client certificate details are not present in the response" else @@ -533,7 +533,7 @@ fi message " Check that HTTP server does not have any client certificate property" CLIENT_CERT=$(curl -sk --cert cert.pem --key testpk.pem http://localhost:8080/ | jq 'has("clientCertificate")') -if [ "$CLIENT_CERT" == "false" ] +if [[ "$CLIENT_CERT" == "false" ]] then passed "Client certificate details are not present in regular HTTP server" else @@ -567,7 +567,7 @@ wait_for_ready REQUEST_WITH_STATUS_CODE="$(curl -s --cacert "$(pwd)/server_fullchain.pem" -o /dev/null -w "%{http_code}" \ --resolve "${cert_common_name}:8443:127.0.0.1" "https://${cert_common_name}:8443/hello-world")" -if [ "${REQUEST_WITH_STATUS_CODE}" = 200 ] +if [[ "${REQUEST_WITH_STATUS_CODE}" == 200 ]] then passed "Server certificate and private key are loaded from configured custom location" else @@ -585,7 +585,7 @@ wait_for_ready RESPONSE_BODY="$(curl -sk https://localhost:8443/ | jq -r '.env.ECHO_INCLUDE_ENV_VARS')" -if [ "$RESPONSE_BODY" == "1" ] +if [[ "$RESPONSE_BODY" == "1" ]] then passed "Environment variables present in the output" else @@ -603,7 +603,7 @@ wait_for_ready RESPONSE_BODY_ENV_CHECK="$(curl -sk https://localhost:8443/ | jq 'has("env")')" -if [ "$RESPONSE_BODY_ENV_CHECK" == "false" ] +if [[ "$RESPONSE_BODY_ENV_CHECK" == "false" ]] then passed "Environment variables not present in the output by default" else @@ -677,7 +677,7 @@ wait_for_removed message " Start container with a custom response body from a file " echo "

Hello World

" > test.html -docker run -d --rm -v ${PWD}/test.html:/app/test.html --name http-echo-tests -p 8080:8080 -e OVERRIDE_RESPONSE_BODY_FILE_PATH=/test.html -t mendhak/http-https-echo:testing +docker run -d --rm -v "${PWD}/test.html:/app/test.html" --name http-echo-tests -p 8080:8080 -e OVERRIDE_RESPONSE_BODY_FILE_PATH=/test.html -t mendhak/http-https-echo:testing wait_for_ready RESPONSE_BODY=$(curl -s http://localhost:8080) @@ -713,7 +713,7 @@ console.log(sign('my-value','mysecretkey123'));") RESPONSE=$(curl -s http://localhost:8080/ -H "Cookie: mysigned=s:${SIGNED_COOKIE}") -if [ "$(echo "$RESPONSE" | jq -r '.signedCookies.mysigned')" == 'my-value' ]; then +if [[ "$(echo "$RESPONSE" | jq -r '.signedCookies.mysigned')" == 'my-value' ]]; then passed "Signed cookie test passed." else failed "Signed cookie test failed." @@ -732,8 +732,8 @@ wait_for_ready RESPONSE=$(curl -s http://localhost:8080/ -H "Cookie: foo=bar; baz=qux") -if [ "$(echo "$RESPONSE" | jq -r '.cookies.foo')" == 'bar' ] && \ - [ "$(echo "$RESPONSE" | jq -r '.cookies.baz')" == 'qux' ]; then +if [[ "$(echo "$RESPONSE" | jq -r '.cookies.foo')" == 'bar' ]] && \ + [[ "$(echo "$RESPONSE" | jq -r '.cookies.baz')" == 'qux' ]]; then passed "Cookies returned in response test passed." else failed "Cookies returned in response test failed." From a84c25827134cf746b10bb522c5713849eb700c4 Mon Sep 17 00:00:00 2001 From: mendhak Date: Fri, 3 Apr 2026 22:25:30 +0100 Subject: [PATCH 7/9] Slightly fewer iterations --- tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests.sh b/tests.sh index a7df672..91e7aad 100755 --- a/tests.sh +++ b/tests.sh @@ -23,7 +23,7 @@ function passed { wait_for_ready() { local check_path="${1:-/}" - for i in {1..30}; do + for i in {1..20}; do if curl -sf "http://localhost:8080${check_path}" >/dev/null 2>&1; then return 0 fi @@ -33,7 +33,7 @@ wait_for_ready() { } wait_for_removed() { - for i in {1..30}; do + for i in {1..20}; do if ! docker ps -aq --filter "name=http-echo-tests" | grep -q .; then return 0 fi From 77ce22aa9a1aaebb212d3faabd251dcfb3eeb50c Mon Sep 17 00:00:00 2001 From: mendhak Date: Fri, 3 Apr 2026 22:33:55 +0100 Subject: [PATCH 8/9] Consolidate stop requests --- tests.sh | 77 ++++++++++++++++++++------------------------------------ 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/tests.sh b/tests.sh index 91e7aad..03b203a 100755 --- a/tests.sh +++ b/tests.sh @@ -32,7 +32,8 @@ wait_for_ready() { echo "Container failed to start"; exit 1 } -wait_for_removed() { +stop_and_remove() { + docker stop http-echo-tests 2>/dev/null || true for i in {1..20}; do if ! docker ps -aq --filter "name=http-echo-tests" | grep -q .; then return 0 @@ -76,7 +77,7 @@ pushd testarea message " Cleaning up from previous test run " docker rm -f http-echo-tests 2>/dev/null || true -wait_for_removed +stop_and_remove message " Start container normally " docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing @@ -203,8 +204,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with max header size " docker run -d --rm -e MAX_HEADER_SIZE=1000 --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing @@ -235,8 +235,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with different internal ports " 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 @@ -267,8 +266,7 @@ fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with empty responses " 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 @@ -285,8 +283,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with response body only " docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing @@ -302,8 +299,7 @@ fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with JWT_HEADER " docker run -d --rm -e JWT_HEADER=Authentication --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing @@ -321,8 +317,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with LOG_IGNORE_PATH (normal path)" @@ -343,8 +338,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with LOG_IGNORE_PATH (regex path)" docker run -d --rm -e LOG_IGNORE_PATH="^\/ping|^\/health|^\/metrics" --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing @@ -377,8 +371,7 @@ fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with LOG_IGNORE_PATH (ignore all paths) " docker run -d --rm -e LOG_IGNORE_PATH=".*" --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing @@ -398,8 +391,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with DISABLE_REQUEST_LOGS " @@ -417,8 +409,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with CORS_CONFIG" docker run -d --rm \ @@ -439,8 +430,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with LOG_WITHOUT_NEWLINE " 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 @@ -461,8 +451,7 @@ fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Check that container is running as a NON ROOT USER by default" docker run -d --name http-echo-tests --rm mendhak/http-https-echo:testing @@ -478,8 +467,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Check that container is running as user different that the user defined in image" IMAGE_USER="$(docker image inspect mendhak/http-https-echo:testing -f '{{ .Config.User }}')" @@ -500,8 +488,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Check that mTLS server responds with client certificate details" # Generate a new self signed cert locally @@ -542,8 +529,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Check that SSL certificate and private key are loaded from custom location" cert_common_name="server.example.net" @@ -576,8 +562,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Check that environment variables returned in response if enabled" 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 @@ -594,8 +579,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Check that environment variables are not present in response by default" docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing @@ -612,8 +596,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with PROMETHEUS disabled " docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing @@ -634,8 +617,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with PROMETHEUS enabled " docker run -d -e PROMETHEUS_ENABLED=true --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing @@ -655,8 +637,7 @@ fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with PRESERVE_HEADER_CASE enabled " docker run -d -e PRESERVE_HEADER_CASE=true --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing @@ -672,8 +653,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with a custom response body from a file " echo "

Hello World

" > test.html @@ -690,8 +670,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Start container with signed cookies support " # Set cookie secret for signing/verifying cookies @@ -722,8 +701,7 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message " Check that regular cookies are returned in response " @@ -742,7 +720,6 @@ else fi message " Stop containers " -docker stop http-echo-tests -wait_for_removed +stop_and_remove message "DONE" From 10af7eee6182613028b76f54a8513b3d242acae2 Mon Sep 17 00:00:00 2001 From: mendhak Date: Fri, 3 Apr 2026 22:51:22 +0100 Subject: [PATCH 9/9] Plaintext test clarification --- tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests.sh b/tests.sh index 03b203a..330d68e 100755 --- a/tests.sh +++ b/tests.sh @@ -518,8 +518,8 @@ else exit 1 fi -message " Check that HTTP server does not have any client certificate property" -CLIENT_CERT=$(curl -sk --cert cert.pem --key testpk.pem http://localhost:8080/ | jq 'has("clientCertificate")') +message " Check that plaintext HTTP port does not have any client certificate property" +CLIENT_CERT=$(curl -s http://localhost:8080/ | jq 'has("clientCertificate")') if [[ "$CLIENT_CERT" == "false" ]] then passed "Client certificate details are not present in regular HTTP server"