load 'test_helper/common' function setup() { run_setup_file_if_necessary } function teardown() { run_teardown_file_if_necessary } function setup_file() { local PRIVATE_CONFIG PRIVATE_CONFIG="$(duplicate_config_for_container . mail_lets_domain)" docker run -d --name mail_lets_domain \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -v "${PRIVATE_CONFIG}/letsencrypt/my-domain.com":/etc/letsencrypt/live/my-domain.com \ -e DMS_DEBUG=0 \ -e SSL_TYPE=letsencrypt \ -h mail.my-domain.com -t ${NAME} wait_for_finished_setup_in_container mail_lets_domain PRIVATE_CONFIG="$(duplicate_config_for_container . mail_lets_hostname)" docker run -d --name mail_lets_hostname \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -v "${PRIVATE_CONFIG}/letsencrypt/mail.my-domain.com":/etc/letsencrypt/live/mail.my-domain.com \ -e DMS_DEBUG=0 \ -e SSL_TYPE=letsencrypt \ -h mail.my-domain.com -t ${NAME} wait_for_finished_setup_in_container mail_lets_hostname PRIVATE_CONFIG="$(duplicate_config_for_container . mail_lets_acme_json)" cp "$(private_config_path mail_lets_acme_json)/letsencrypt/acme.json" "$(private_config_path mail_lets_acme_json)/acme.json" docker run -d --name mail_lets_acme_json \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "${PRIVATE_CONFIG}/acme.json":/etc/letsencrypt/acme.json:ro \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e DMS_DEBUG=0 \ -e SSL_TYPE=letsencrypt \ -e "SSL_DOMAIN=*.example.com" \ -h mail.my-domain.com -t ${NAME} wait_for_finished_setup_in_container mail_lets_acme_json } function teardown_file() { docker rm -f mail_lets_domain docker rm -f mail_lets_hostname docker rm -f mail_lets_acme_json } # this test must come first to reliably identify when to run setup_file @test "first" { skip 'Starting testing of letsencrypt SSL' } @test "checking ssl: letsencrypt configuration is correct" { #test domain has certificate files run docker exec mail_lets_domain /bin/sh -c 'postconf | grep "smtpd_tls_cert_file = /etc/letsencrypt/live/my-domain.com/fullchain.pem" | wc -l' assert_success assert_output 1 run docker exec mail_lets_domain /bin/sh -c 'postconf | grep "smtpd_tls_key_file = /etc/letsencrypt/live/my-domain.com/key.pem" | wc -l' assert_success assert_output 1 run docker exec mail_lets_domain /bin/sh -c 'doveconf | grep "ssl_cert =