|
364 | 364 | message " Stop containers " |
365 | 365 | docker stop http-echo-tests |
366 | 366 |
|
| 367 | +message " Check that SSL certificate and private key are loaded from custom location" |
| 368 | +cert_common_name="server.example.net" |
| 369 | +https_cert_file="$(pwd)/server_fullchain.pem" |
| 370 | +https_key_file="$(pwd)/server_privkey.pem" |
| 371 | +# Generate a new self signed cert locally |
| 372 | +openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout "${https_key_file}" -out "${https_cert_file}" \ |
| 373 | + -subj "/CN=${cert_common_name}" \ |
| 374 | + -addext "subjectAltName=DNS:${cert_common_name}" |
| 375 | +chmod a+r "${https_cert_file}" |
| 376 | +chmod a+r "${https_key_file}" |
| 377 | +container_https_cert_file="/test/tls.crt" |
| 378 | +container_https_key_file="/test/tls.key" |
| 379 | +docker run -d --rm \ |
| 380 | + -v "${https_cert_file}:${container_https_cert_file}:ro,z" \ |
| 381 | + -e HTTPS_CERT_FILE="${container_https_cert_file}" \ |
| 382 | + -v "${https_key_file}:${container_https_key_file}:ro,z" \ |
| 383 | + -e HTTPS_KEY_FILE="${container_https_key_file}" \ |
| 384 | + --name http-echo-tests -p 8443:8443 -t mendhak/http-https-echo |
| 385 | +sleep 5 |
| 386 | + |
| 387 | +REQUEST_WITH_STATUS_CODE="$(curl -s --cacert "$(pwd)/server_fullchain.pem" -o /dev/null -w "%{http_code}" \ |
| 388 | + --resolve "${cert_common_name}:8443:127.0.0.1" "https://${cert_common_name}:8443/hello-world")" |
| 389 | +if [ "${REQUEST_WITH_STATUS_CODE}" = 200 ] |
| 390 | +then |
| 391 | + passed "Server certificate and private key are loaded from configured custom location" |
| 392 | +else |
| 393 | + failed "HTTPS request failed" |
| 394 | + exit 1 |
| 395 | +fi |
| 396 | + |
| 397 | +message " Stop containers " |
| 398 | +docker stop http-echo-tests |
| 399 | + |
367 | 400 | message " Check that environment variables returned in response if enabled" |
368 | 401 | 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 |
369 | 402 | sleep 5 |
|
0 commit comments