From a3f32e11b4c3c3acb7a99941d829f899b99a0223 Mon Sep 17 00:00:00 2001 From: Nicolas Duchon Date: Tue, 13 Oct 2020 19:53:55 +0200 Subject: [PATCH] Update acme_accounts test for LETSENCRYPT_EMAIL --- test/tests/acme_accounts/expected-std-out.txt | 3 ++ test/tests/acme_accounts/run.sh | 30 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/test/tests/acme_accounts/expected-std-out.txt b/test/tests/acme_accounts/expected-std-out.txt index ba2246c..5c4b6d6 100644 --- a/test/tests/acme_accounts/expected-std-out.txt +++ b/test/tests/acme_accounts/expected-std-out.txt @@ -6,3 +6,6 @@ Started letsencrypt container for test acme_accounts_default Started test web server for le2.wtf Symlink to le2.wtf certificate has been generated. The link is pointing to the file ./le2.wtf/fullchain.pem +Started test web server for le3.wtf +Symlink to le3.wtf certificate has been generated. +The link is pointing to the file ./le3.wtf/fullchain.pem diff --git a/test/tests/acme_accounts/run.sh b/test/tests/acme_accounts/run.sh index af85ce8..3169587 100755 --- a/test/tests/acme_accounts/run.sh +++ b/test/tests/acme_accounts/run.sh @@ -56,7 +56,7 @@ default_email="contact@${domains[1]}" le_container_name="${le_container_name}_default" run_le_container "${1:?}" "$le_container_name" "--env DEFAULT_EMAIL=${default_email}" -# Run an nginx container for ${domains[1]}. +# Run an nginx container for ${domains[1]} without LETSENCRYPT_EMAIL set. docker run --rm -d \ --name "${domains[1]}" \ -e "VIRTUAL_HOST=${domains[1]}" \ @@ -68,7 +68,6 @@ docker run --rm -d \ wait_for_symlink "${domains[1]}" "$le_container_name" # Test if the expected folder / file / content are there. -# We exit in case of error to avoid deleting the companion container. json_file="/etc/acme.sh/${default_email}/ca/boulder/account.json" if docker exec "$le_container_name" [[ ! -d "/etc/acme.sh/$default_email" ]]; then echo "The /etc/acme.sh/$default_email folder does not exist." @@ -79,5 +78,30 @@ elif [[ "$(docker exec "$le_container_name" jq -r '.contact|.[0]' "$json_file")" docker exec "$le_container_name" jq . "$json_file" fi -# Stop the nginx container silently. +# Run an nginx container for ${domains[2]} with LETSENCRYPT_EMAIL set. +container_email="contact@${domains[2]}" +docker run --rm -d \ + --name "${domains[2]}" \ + -e "VIRTUAL_HOST=${domains[2]}" \ + -e "LETSENCRYPT_HOST=${domains[2]}" \ + -e "LETSENCRYPT_EMAIL=${container_email}" \ + --network boulder_bluenet \ + nginx:alpine > /dev/null && echo "Started test web server for ${domains[2]}" + +# Wait for a symlink at /etc/nginx/certs/${domains[2]}.crt +wait_for_symlink "${domains[2]}" "$le_container_name" + +# Test if the expected folder / file / content are there. +json_file="/etc/acme.sh/${container_email}/ca/boulder/account.json" +if docker exec "$le_container_name" [[ ! -d "/etc/acme.sh/$container_email" ]]; then + echo "The /etc/acme.sh/$container_email folder does not exist." +elif docker exec "$le_container_name" [[ ! -f "$json_file" ]]; then + echo "The $json_file file does not exist." +elif [[ "$(docker exec "$le_container_name" jq -r '.contact|.[0]' "$json_file")" != "mailto:${container_email}" ]]; then + echo "$default_email is not set on ${json_file}." + docker exec "$le_container_name" jq . "$json_file" +fi + +# Stop the nginx containers silently. docker stop "${domains[1]}" > /dev/null 2>&1 +docker stop "${domains[2]}" > /dev/null 2>&1