@@ -26,8 +26,19 @@ if ! [ -x "$(command -v jq)" ]; then
26
26
sudo apt -y install jq
27
27
fi
28
28
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
+
31
42
32
43
mkdir -p testarea
33
44
pushd testarea
@@ -36,7 +47,7 @@ message " Cleaning up from previous test run "
36
47
docker ps -aq --filter " name=http-echo-tests" | grep -q . && docker stop http-echo-tests && docker rm -f http-echo-tests
37
48
38
49
message " 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
40
51
sleep 5
41
52
42
53
@@ -149,7 +160,7 @@ docker stop http-echo-tests
149
160
sleep 5
150
161
151
162
message " 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
153
164
sleep 5
154
165
155
166
message " Make http(s) request, and test the path, method and header. "
@@ -183,7 +194,7 @@ docker stop http-echo-tests
183
194
sleep 5
184
195
185
196
message " 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
187
198
sleep 5
188
199
REQUEST=$( curl -s -k http://localhost:8080/a/b/c)
189
200
if [[ -z ${REQUEST} ]]
@@ -200,7 +211,7 @@ docker stop http-echo-tests
200
211
sleep 5
201
212
202
213
message " 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
204
215
sleep 5
205
216
RESPONSE=$( curl -s -k -X POST -d ' cauliflower' http://localhost:8080/a/b/c? response_body_only=true)
206
217
if [[ ${RESPONSE} == " cauliflower" ]]
@@ -218,7 +229,7 @@ docker stop http-echo-tests
218
229
sleep 5
219
230
220
231
message " 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
222
233
sleep 5
223
234
224
235
REQUEST=$( curl -s -k -H " Authentication: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" https://localhost:8443/ )
@@ -239,7 +250,7 @@ sleep 5
239
250
240
251
241
252
message " 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
243
254
sleep 5
244
255
curl -s -k -X POST -d " banana" https://localhost:8443/ping > /dev/null
245
256
@@ -259,7 +270,7 @@ docker stop http-echo-tests
259
270
sleep 5
260
271
261
272
message " 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
263
274
sleep 5
264
275
curl -s -k -X GET https://localhost:8443/strawberry > /dev/null
265
276
if [ $( docker logs http-echo-tests | grep -c " GET /strawberry HTTP/1.1" ) -eq 0 ]
@@ -278,7 +289,7 @@ sleep 5
278
289
message " Start container with CORS_CONFIG"
279
290
docker run -d --rm \
280
291
-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
282
293
sleep 5
283
294
# Check if the expected CORS headers are present in the response
284
295
if curl -s -i http://localhost:8080/ 2>&1 | grep -q -E \
@@ -297,7 +308,7 @@ docker stop http-echo-tests
297
308
sleep 5
298
309
299
310
message " 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
301
312
sleep 5
302
313
curl -s -k -X POST -d " tiramisu" https://localhost:8443/ > /dev/null
303
314
@@ -317,7 +328,7 @@ docker stop http-echo-tests
317
328
sleep 5
318
329
319
330
message " 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
321
332
322
333
WHOAMI=$( docker exec http-echo-tests whoami)
323
334
@@ -334,9 +345,9 @@ docker stop http-echo-tests
334
345
sleep 5
335
346
336
347
message " 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 }}' ) "
338
349
CONTAINER_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
340
351
sleep 5
341
352
curl -s http://localhost:8080 > /dev/null
342
353
@@ -359,7 +370,7 @@ message " Check that mTLS server responds with client certificate details"
359
370
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout privkey.pem -out fullchain.pem \
360
371
-subj " /CN=client.example.net" \
361
372
-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
363
374
sleep 5
364
375
COMMON_NAME=" $( curl -sk --cert fullchain.pem --key privkey.pem https://localhost:8443/ | jq -r ' .clientCertificate.subject.CN' ) "
365
376
SAN=" $( curl -sk --cert fullchain.pem --key privkey.pem https://localhost:8443/ | jq -r ' .clientCertificate.subjectaltname' ) "
@@ -412,7 +423,7 @@ docker run -d --rm \
412
423
-e HTTPS_CERT_FILE=" ${container_https_cert_file} " \
413
424
-v " ${https_key_file} :${container_https_key_file} :ro,z" \
414
425
-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
416
427
sleep 5
417
428
418
429
REQUEST_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
430
441
sleep 5
431
442
432
443
message " 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
434
445
sleep 5
435
446
RESPONSE_BODY=" $( curl -sk https://localhost:8443/ | jq -r ' .env.ECHO_INCLUDE_ENV_VARS' ) "
436
447
@@ -447,7 +458,7 @@ docker stop http-echo-tests
447
458
sleep 5
448
459
449
460
message " 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
451
462
sleep 5
452
463
RESPONSE_BODY_ENV_CHECK=" $( curl -sk https://localhost:8443/ | jq ' has("env")' ) "
453
464
@@ -464,7 +475,7 @@ docker stop http-echo-tests
464
475
sleep 5
465
476
466
477
message " 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
468
479
sleep 5
469
480
curl -s -k -X POST -d " tiramisu" https://localhost:8443/ > /dev/null
470
481
@@ -485,7 +496,7 @@ docker stop http-echo-tests
485
496
sleep 5
486
497
487
498
message " 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
489
500
sleep 5
490
501
curl -s -k -X POST -d " tiramisu" https://localhost:8443/ > /dev/null
491
502
0 commit comments