From 5fef8a5b780692f37cd5cee58cc948ca3d6f75f3 Mon Sep 17 00:00:00 2001 From: Martin Schulze Date: Fri, 18 Sep 2020 01:37:42 +0200 Subject: [PATCH] Give each container their own private config folder --- test/default_relay_host.bats | 2 +- test/mail_dhparams_default.bats | 4 +- test/mail_dhparams_manual_not_one_dir.bats | 7 +- test/mail_dhparams_manual_one_dir.bats | 2 +- test/mail_disabled_clamav_spamassassin.bats | 2 +- test/mail_fail2ban.bats | 2 +- test/mail_fetchmail.bats | 2 +- test/mail_lmtp_ip.bats | 4 +- test/mail_override_hostname.bats | 2 +- test/mail_pop3.bats | 2 +- test/mail_postfix_inet.bats | 8 +- test/mail_postscreen.bats | 2 +- test/mail_privacy.bats | 2 +- test/mail_quotas_disabled.bats | 2 +- test/mail_smtponly.bats | 2 +- test/mail_spam_bounced.bats | 4 +- test/mail_spam_junk_folder.bats | 4 +- test/mail_special_use_folders.bats | 2 +- test/mail_srs_domainname.bats | 4 +- test/mail_ssl_letsencrypt.bats | 28 +++-- test/mail_ssl_manual.bats | 2 +- test/mail_undef_spam_subject.bats | 4 +- test/mail_with_imap.bats | 2 +- test/mail_with_ldap.bats | 2 +- test/mail_with_mdbox.bats | 2 +- test/mail_with_postgrey.bats | 2 +- ...ail_with_postgrey_disabled_by_default.bats | 2 +- test/mail_with_sdbox.bats | 2 +- test/permit_docker.bats | 4 +- test/test_helper/common.bash | 16 +++ test/tests.bats | 118 ++++++++++-------- 31 files changed, 138 insertions(+), 105 deletions(-) diff --git a/test/default_relay_host.bats b/test/default_relay_host.bats index a1fa22f7..91c42ab2 100644 --- a/test/default_relay_host.bats +++ b/test/default_relay_host.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup() { docker run -d --name mail_with_default_relay \ - -v "`pwd`/test/config/relay-hosts":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container relay-hosts/)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e DEFAULT_RELAY_HOST=default.relay.host.invalid:25 \ --cap-add=SYS_PTRACE \ diff --git a/test/mail_dhparams_default.bats b/test/mail_dhparams_default.bats index 9fae1b16..72a789ea 100644 --- a/test/mail_dhparams_default.bats +++ b/test/mail_dhparams_default.bats @@ -22,7 +22,7 @@ function teardown() { function setup_file() { docker run -d --name mail_default_dhparams_one_dir \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_default_dhparams_both_one_dir)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e DMS_DEBUG=0 \ -e ONE_DIR=1 \ @@ -30,7 +30,7 @@ function setup_file() { wait_for_finished_setup_in_container mail_default_dhparams_one_dir docker run -d --name mail_default_dhparams_not_one_dir \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_default_dhparams_both_not_one_dir)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e DMS_DEBUG=0 \ -e ONE_DIR=0 \ diff --git a/test/mail_dhparams_manual_not_one_dir.bats b/test/mail_dhparams_manual_not_one_dir.bats index 36e2f926..2277c2f5 100644 --- a/test/mail_dhparams_manual_not_one_dir.bats +++ b/test/mail_dhparams_manual_not_one_dir.bats @@ -21,11 +21,12 @@ function teardown() { } function setup_file() { + private_config=$(duplicate_config_for_container .) # copy the custom DHE params in local config - cp "`pwd`/test/test-files/ssl/custom-dhe-params.pem" "`pwd`/test/config/dhparams.pem" + cp "`pwd`/test/test-files/ssl/custom-dhe-params.pem" "$private_config/dhparams.pem" docker run -d --name mail_manual_dhparams_not_one_dir \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$private_config":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e DMS_DEBUG=0 \ -e ONE_DIR=0 \ @@ -34,8 +35,6 @@ function setup_file() { } function teardown_file() { - # remove custom dhe file - rm "`pwd`/test/config/dhparams.pem" docker rm -f mail_manual_dhparams_not_one_dir } diff --git a/test/mail_dhparams_manual_one_dir.bats b/test/mail_dhparams_manual_one_dir.bats index 1ce23adc..69091d83 100644 --- a/test/mail_dhparams_manual_one_dir.bats +++ b/test/mail_dhparams_manual_one_dir.bats @@ -21,7 +21,7 @@ function teardown() { function setup_file() { docker run -d --name mail_manual_dhparams_one_dir \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -v "`pwd`/test/test-files/ssl/custom-dhe-params.pem":/var/mail-state/lib-shared/dhparams.pem:ro \ -e DMS_DEBUG=0 \ diff --git a/test/mail_disabled_clamav_spamassassin.bats b/test/mail_disabled_clamav_spamassassin.bats index 269a53c2..a85cd712 100644 --- a/test/mail_disabled_clamav_spamassassin.bats +++ b/test/mail_disabled_clamav_spamassassin.bats @@ -10,7 +10,7 @@ teardown() { setup_file() { docker run --rm -d --name mail_disabled_clamav_spamassassin \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_CLAMAV=0 \ -e ENABLE_SPAMASSASSIN=0 \ diff --git a/test/mail_fail2ban.bats b/test/mail_fail2ban.bats index 7b213c24..d96b2cfa 100644 --- a/test/mail_fail2ban.bats +++ b/test/mail_fail2ban.bats @@ -10,7 +10,7 @@ function teardown() { function setup_file() { docker run --rm -d --name mail_fail2ban \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_FAIL2BAN=1 \ -e POSTSCREEN_ACTION=ignore \ diff --git a/test/mail_fetchmail.bats b/test/mail_fetchmail.bats index bb6d4d8b..cdafafdc 100644 --- a/test/mail_fetchmail.bats +++ b/test/mail_fetchmail.bats @@ -10,7 +10,7 @@ function teardown() { function setup_file() { docker run -d --name mail_fetchmail \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_FETCHMAIL=1 \ --cap-add=NET_ADMIN \ diff --git a/test/mail_lmtp_ip.bats b/test/mail_lmtp_ip.bats index 4ec82e03..02547436 100644 --- a/test/mail_lmtp_ip.bats +++ b/test/mail_lmtp_ip.bats @@ -10,8 +10,8 @@ teardown() { setup_file() { docker run -d --name mail_lmtp_ip \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ - -v "`pwd`/test/config/dovecot-lmtp":/etc/dovecot \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container dovecot-lmtp/ mail_lmtp_ip_dovecot-lmtp)":/etc/dovecot \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_POSTFIX_VIRTUAL_TRANSPORT=1 \ -e POSTFIX_DAGENT=lmtp:127.0.0.1:24 \ diff --git a/test/mail_override_hostname.bats b/test/mail_override_hostname.bats index dbc6a9ca..1a6da949 100644 --- a/test/mail_override_hostname.bats +++ b/test/mail_override_hostname.bats @@ -6,7 +6,7 @@ function setup() { function setup_file() { docker run --rm -d --name mail_override_hostname \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e PERMIT_DOCKER=network \ -e DMS_DEBUG=0 \ diff --git a/test/mail_pop3.bats b/test/mail_pop3.bats index 5f183fea..c6d429e5 100644 --- a/test/mail_pop3.bats +++ b/test/mail_pop3.bats @@ -10,7 +10,7 @@ function teardown() { function setup_file() { docker run -d --name mail_pop3 \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_POP3=1 \ -e DMS_DEBUG=0 \ diff --git a/test/mail_postfix_inet.bats b/test/mail_postfix_inet.bats index a42639be..94328f11 100644 --- a/test/mail_postfix_inet.bats +++ b/test/mail_postfix_inet.bats @@ -15,14 +15,14 @@ function teardown() { function setup_file() { docker run -d --name mail_postfix_inet_default \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_postfix_inet_default)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -h mail.my-domain.com -t "${NAME}" wait_for_finished_setup_in_container mail_postfix_inet_default docker run -d --name mail_postfix_inet_all \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_postfix_inet_all)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e POSTFIX_INET_PROTOCOLS=all \ -h mail.my-domain.com -t "${NAME}" @@ -30,7 +30,7 @@ function setup_file() { wait_for_finished_setup_in_container mail_postfix_inet_all docker run -d --name mail_postfix_inet_ipv4 \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_postfix_inet_ipv4)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e POSTFIX_INET_PROTOCOLS=ipv4 \ -h mail.my-domain.com -t "${NAME}" @@ -38,7 +38,7 @@ function setup_file() { wait_for_finished_setup_in_container mail_postfix_inet_ipv4 docker run -d --name mail_postfix_inet_ipv6 \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_postfix_inet_ipv6)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e POSTFIX_INET_PROTOCOLS=ipv6 \ -h mail.my-domain.com -t "${NAME}" diff --git a/test/mail_postscreen.bats b/test/mail_postscreen.bats index a6f17b5c..8df044bc 100644 --- a/test/mail_postscreen.bats +++ b/test/mail_postscreen.bats @@ -13,7 +13,7 @@ teardown() { setup_file() { docker run -d --name mail_postscreen \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e POSTSCREEN_ACTION=enforce \ --cap-add=NET_ADMIN \ diff --git a/test/mail_privacy.bats b/test/mail_privacy.bats index 44af92af..a425f6b8 100644 --- a/test/mail_privacy.bats +++ b/test/mail_privacy.bats @@ -10,7 +10,7 @@ function teardown() { function setup_file() { docker run -d --name mail_privacy \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e SASL_PASSWD="external-domain.com username:password" \ -e ENABLE_MANAGESIEVE=1 \ diff --git a/test/mail_quotas_disabled.bats b/test/mail_quotas_disabled.bats index e04e5918..faefd2af 100644 --- a/test/mail_quotas_disabled.bats +++ b/test/mail_quotas_disabled.bats @@ -15,7 +15,7 @@ function teardown() { function setup_file() { docker run -d --name mail_no_quotas \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e DMS_DEBUG=0 \ -e ENABLE_QUOTAS=0 \ diff --git a/test/mail_smtponly.bats b/test/mail_smtponly.bats index e0cc8080..7b9cec5c 100644 --- a/test/mail_smtponly.bats +++ b/test/mail_smtponly.bats @@ -10,7 +10,7 @@ function teardown() { function setup_file() { docker run --rm -d --name mail_smtponly \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e SMTP_ONLY=1 \ -e PERMIT_DOCKER=network \ diff --git a/test/mail_spam_bounced.bats b/test/mail_spam_bounced.bats index 9b0880fc..f6af38ae 100644 --- a/test/mail_spam_bounced.bats +++ b/test/mail_spam_bounced.bats @@ -15,7 +15,7 @@ function teardown() { function setup_file() { docker run -d --name mail_spam_bounced_defined \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_spam_bounced_defined)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_SPAMASSASSIN=1 \ -e SPAMASSASSIN_SPAM_TO_INBOX=0 \ @@ -24,7 +24,7 @@ function setup_file() { wait_for_finished_setup_in_container mail_spam_bounced_defined docker run -d --name mail_spam_bounced_undefined \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_spam_bounced_defined)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_SPAMASSASSIN=1 \ -h mail.my-domain.com -t "${NAME}" diff --git a/test/mail_spam_junk_folder.bats b/test/mail_spam_junk_folder.bats index 3b17c92e..6e7259e2 100644 --- a/test/mail_spam_junk_folder.bats +++ b/test/mail_spam_junk_folder.bats @@ -15,7 +15,7 @@ function teardown() { function setup_file() { docker run -d --name mail_spam_moved_junk \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_spam_moved_junk)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_SPAMASSASSIN=1 \ -e SPAMASSASSIN_SPAM_TO_INBOX=1 \ @@ -26,7 +26,7 @@ function setup_file() { wait_for_finished_setup_in_container mail_spam_moved_junk docker run -d --name mail_spam_moved_new \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_spam_moved_new)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_SPAMASSASSIN=1 \ -e SPAMASSASSIN_SPAM_TO_INBOX=1 \ diff --git a/test/mail_special_use_folders.bats b/test/mail_special_use_folders.bats index bbd2cc79..cb6eb84a 100644 --- a/test/mail_special_use_folders.bats +++ b/test/mail_special_use_folders.bats @@ -10,7 +10,7 @@ teardown() { setup_file() { docker run -d --name mail_special_use_folders \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e SASL_PASSWD="external-domain.com username:password" \ -e ENABLE_CLAMAV=0 \ diff --git a/test/mail_srs_domainname.bats b/test/mail_srs_domainname.bats index 8047df79..efbc5d83 100644 --- a/test/mail_srs_domainname.bats +++ b/test/mail_srs_domainname.bats @@ -2,7 +2,7 @@ load 'test_helper/common' @test "checking SRS: SRS_DOMAINNAME is used correctly" { docker run --rm -d --name mail_srs_domainname \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_srs_domainname)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e PERMIT_DOCKER=network \ -e DMS_DEBUG=0 \ @@ -19,7 +19,7 @@ load 'test_helper/common' @test "checking SRS: DOMAINNAME is handled correctly" { docker run --rm -d --name mail_domainname \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_domainname)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e PERMIT_DOCKER=network \ -e DMS_DEBUG=0 \ diff --git a/test/mail_ssl_letsencrypt.bats b/test/mail_ssl_letsencrypt.bats index 0a8cc62b..cb826208 100644 --- a/test/mail_ssl_letsencrypt.bats +++ b/test/mail_ssl_letsencrypt.bats @@ -9,28 +9,31 @@ function teardown() { } function setup_file() { + private_config="$(duplicate_config_for_container . mail_lets_domain)" docker run -d --name mail_lets_domain \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$private_config":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ - -v "`pwd`/test/config/letsencrypt/my-domain.com":/etc/letsencrypt/live/my-domain.com \ + -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 "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$private_config":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ - -v "`pwd`/test/config/letsencrypt/mail.my-domain.com":/etc/letsencrypt/live/mail.my-domain.com \ + -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 - cp "`pwd`/test/config/letsencrypt/acme.json" "`pwd`/test/config/acme.json" + 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 "`pwd`/test/config":/tmp/docker-mailserver \ - -v "`pwd`/test/config/acme.json":/etc/letsencrypt/acme.json:ro \ + -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 \ @@ -44,7 +47,6 @@ function teardown_file() { docker rm -f mail_lets_domain docker rm -f mail_lets_hostname docker rm -f mail_lets_acme_json - rm "`pwd`/test/config/acme.json" } # this test must come first to reliably identify when to run setup_file @@ -103,16 +105,16 @@ function teardown_file() { @test "can extract certs from acme.json" { run docker exec mail_lets_acme_json /bin/bash -c "cat /etc/letsencrypt/live/mail.my-domain.com/key.pem" - assert_output "$(cat "`pwd`/test/config/letsencrypt/mail.my-domain.com/privkey.pem")" + assert_output "$(cat "$(private_config_path mail_lets_acme_json)/letsencrypt/mail.my-domain.com/privkey.pem")" assert_success run docker exec mail_lets_acme_json /bin/bash -c "cat /etc/letsencrypt/live/mail.my-domain.com/fullchain.pem" - assert_output "$(cat "`pwd`/test/config/letsencrypt/mail.my-domain.com/fullchain.pem")" + assert_output "$(cat "$(private_config_path mail_lets_acme_json)/letsencrypt/mail.my-domain.com/fullchain.pem")" assert_success } @test "can detect changes" { - cp "`pwd`/test/config/letsencrypt/acme-changed.json" "`pwd`/test/config/acme.json" + cp "$(private_config_path mail_lets_acme_json)/letsencrypt/acme-changed.json" "$(private_config_path mail_lets_acme_json)/acme.json" sleep 11 run docker exec mail_lets_acme_json /bin/bash -c "supervisorctl tail changedetector" assert_output --partial "Cert found in /etc/letsencrypt/acme.json for *.example.com" @@ -121,11 +123,11 @@ function teardown_file() { assert_output --partial "Change detected" run docker exec mail_lets_acme_json /bin/bash -c "cat /etc/letsencrypt/live/mail.my-domain.com/key.pem" - assert_output "$(cat "`pwd`/test/config/letsencrypt/changed/key.pem")" + assert_output "$(cat "$(private_config_path mail_lets_acme_json)/letsencrypt/changed/key.pem")" assert_success run docker exec mail_lets_acme_json /bin/bash -c "cat /etc/letsencrypt/live/mail.my-domain.com/fullchain.pem" - assert_output "$(cat "`pwd`/test/config/letsencrypt/changed/fullchain.pem")" + assert_output "$(cat "$(private_config_path mail_lets_acme_json)/letsencrypt/changed/fullchain.pem")" assert_success } diff --git a/test/mail_ssl_manual.bats b/test/mail_ssl_manual.bats index 00465ebd..0ce0a90c 100644 --- a/test/mail_ssl_manual.bats +++ b/test/mail_ssl_manual.bats @@ -10,7 +10,7 @@ function teardown() { function setup_file() { docker run -d --name mail_manual_ssl \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e SSL_TYPE=manual \ -e SSL_CERT_PATH=/tmp/docker-mailserver/letsencrypt/mail.my-domain.com/fullchain.pem \ diff --git a/test/mail_undef_spam_subject.bats b/test/mail_undef_spam_subject.bats index 5798f2bb..0f9b83c7 100644 --- a/test/mail_undef_spam_subject.bats +++ b/test/mail_undef_spam_subject.bats @@ -2,13 +2,13 @@ load 'test_helper/common' function setup() { docker run -d --name mail_undef_spam_subject \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_SPAMASSASSIN=1 \ -e SA_SPAM_SUBJECT="undef" \ -h mail.my-domain.com -t ${NAME} CONTAINER=$(docker run -d \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_undef_spam_subject_2)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -v "`pwd`/test/onedir":/var/mail-state \ -e ENABLE_CLAMAV=1 \ diff --git a/test/mail_with_imap.bats b/test/mail_with_imap.bats index ae867c5f..0b23693a 100644 --- a/test/mail_with_imap.bats +++ b/test/mail_with_imap.bats @@ -11,7 +11,7 @@ teardown() { setup_file() { docker run -d --name mail_with_imap \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_SASLAUTHD=1 \ -e SASLAUTHD_MECHANISMS=rimap \ diff --git a/test/mail_with_ldap.bats b/test/mail_with_ldap.bats index a236035c..3b4254a8 100644 --- a/test/mail_with_ldap.bats +++ b/test/mail_with_ldap.bats @@ -18,7 +18,7 @@ function setup_file() { -h ldap.my-domain.com -t ldap docker run -d --name mail_with_ldap \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_LDAP=1 \ -e LDAP_SERVER_HOST=ldap \ diff --git a/test/mail_with_mdbox.bats b/test/mail_with_mdbox.bats index 535aa801..8913eff4 100644 --- a/test/mail_with_mdbox.bats +++ b/test/mail_with_mdbox.bats @@ -10,7 +10,7 @@ teardown() { setup_file() { docker run -d --name mail_with_mdbox_format \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e SASL_PASSWD="external-domain.com username:password" \ -e ENABLE_CLAMAV=0 \ diff --git a/test/mail_with_postgrey.bats b/test/mail_with_postgrey.bats index 03248295..11ce2f04 100644 --- a/test/mail_with_postgrey.bats +++ b/test/mail_with_postgrey.bats @@ -10,7 +10,7 @@ function teardown() { function setup_file() { docker run -d --name mail_with_postgrey \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_POSTGREY=1 \ -e POSTGREY_DELAY=15 \ diff --git a/test/mail_with_postgrey_disabled_by_default.bats b/test/mail_with_postgrey_disabled_by_default.bats index d71108b4..31b4baf5 100644 --- a/test/mail_with_postgrey_disabled_by_default.bats +++ b/test/mail_with_postgrey_disabled_by_default.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup() { CONTAINER=$(docker run -d \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e DMS_DEBUG=0 \ -h mail.my-domain.com -t ${NAME}) diff --git a/test/mail_with_sdbox.bats b/test/mail_with_sdbox.bats index 2f3d2202..2056d480 100644 --- a/test/mail_with_sdbox.bats +++ b/test/mail_with_sdbox.bats @@ -10,7 +10,7 @@ teardown() { setup_file() { docker run -d --name mail_with_sdbox_format \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e SASL_PASSWD="external-domain.com username:password" \ -e ENABLE_CLAMAV=0 \ diff --git a/test/permit_docker.bats b/test/permit_docker.bats index 4429ab11..3edb6cdd 100644 --- a/test/permit_docker.bats +++ b/test/permit_docker.bats @@ -8,7 +8,7 @@ setup() { # currently we cannot use --network in `docker run` multiple times, it will just use the last one # instead we need to use create, network connect and start (see https://success.docker.com/article/multiple-docker-networks) docker create --name mail_smtponly_second_network \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_smtponly_second_network)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e SMTP_ONLY=1 \ -e PERMIT_DOCKER=connected-networks \ @@ -19,7 +19,7 @@ setup() { docker network connect ${NON_DEFAULT_DOCKER_MAIL_NETWORK_NAME}2 mail_smtponly_second_network docker start mail_smtponly_second_network docker run -d --name mail_smtponly_second_network_sender \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$(duplicate_config_for_container . mail_smtponly_second_network_sender)":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -e SMTP_ONLY=1 \ -e PERMIT_DOCKER=connected-networks \ diff --git a/test/test_helper/common.bash b/test/test_helper/common.bash index f537d95c..929cc8cc 100644 --- a/test/test_helper/common.bash +++ b/test/test_helper/common.bash @@ -105,3 +105,19 @@ function run_teardown_file_if_necessary() { teardown_file fi } + +# get the private config path for the given container or test file, if no container name was given +function private_config_path() { + echo "$PWD/test/duplicate_configs/${1:$BATS_TEST_FILENAME}" +} + +# @param $1 relative source in test/config folder +# @param $2 (optional) container name, defaults to $BATS_TEST_FILENAME +# @return path to the folder where the config is duplicated +function duplicate_config_for_container() { + output="$(private_config_path "$2")" + rm -rf "$output" # cleanup + mkdir -p "$output" + cp -r "$PWD/test/config/$1" "$output" + echo "$output" +} \ No newline at end of file diff --git a/test/tests.bats b/test/tests.bats index fcc3841f..1193fcc4 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -7,11 +7,12 @@ setup() { } setup_file() { + private_config="$(duplicate_config_for_container . mail)" docker run --rm -d --name mail \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "$private_config":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -v "`pwd`/test/onedir":/var/mail-state \ - -v "`pwd`/test/config/user-patches/user-patches.sh":/tmp/docker-mailserver/user-patches.sh \ + -v "$private_config/user-patches/user-patches.sh":/tmp/docker-mailserver/user-patches.sh \ -e ENABLE_CLAMAV=1 \ -e SPOOF_PROTECTION=1 \ -e ENABLE_SPAMASSASSIN=1 \ @@ -32,7 +33,7 @@ setup_file() { # generate account after run docker exec mail addmailuser pass@localhost.localdomain 'may be \a `p^a.*ssword' # setup sieve - repeat_until_success_or_timeout 15 docker cp "`pwd`/test/config/sieve/dovecot.sieve" mail:/var/mail/localhost.localdomain/user1/.dovecot.sieve + repeat_until_success_or_timeout 15 docker cp "$private_config/sieve/dovecot.sieve" mail:/var/mail/localhost.localdomain/user1/.dovecot.sieve wait_for_smtp_port_in_container mail # sending test mails docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-spam.txt" @@ -460,18 +461,21 @@ EOF # Instead it tests the file-size (here 511) - which may differ with a different domain names # This test may be re-used as a global test to provide better test coverage. @test "checking opendkim: generator creates default keys size" { + private_config="$(duplicate_config_for_container . mail_default_key_size)" # Prepare default key size 2048 - rm -rf "$(pwd)/test/config/keyDefault" && mkdir -p "$(pwd)/test/config/keyDefault" + rm -rf "$private_config/keyDefault" + mkdir -p "$private_config/keyDefault" + run docker run --rm \ - -v "$(pwd)/test/config/keyDefault/":/tmp/docker-mailserver/ \ - -v "$(pwd)/test/config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ - -v "$(pwd)/test/config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ + -v "$private_config/keyDefault/":/tmp/docker-mailserver/ \ + -v "$private_config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ + -v "$private_config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config | wc -l' assert_success assert_output 6 run docker run --rm \ - -v "$(pwd)/test/config/keyDefault/opendkim":/etc/opendkim \ + -v "$private_config/keyDefault/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` \ /bin/sh -c 'stat -c%s /etc/opendkim/keys/localhost.localdomain/mail.txt' @@ -483,18 +487,20 @@ EOF # Instead it tests the file-size (here 511) - which may differ with a different domain names # This test may be re-used as a global test to provide better test coverage. @test "checking opendkim: generator creates key size 2048" { + private_config="$(duplicate_config_for_container . mail_key_size_2048)" # Prepare set key size 2048 - rm -rf "$(pwd)/test/config/key2048" && mkdir -p "$(pwd)/test/config/key2048" + rm -rf "$private_config/key2048" + mkdir -p "$private_config/config/key2048" run docker run --rm \ - -v "$(pwd)/test/config/key2048/":/tmp/docker-mailserver/ \ - -v "$(pwd)/test/config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ - -v "$(pwd)/test/config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ + -v "$private_config/key2048/":/tmp/docker-mailserver/ \ + -v "$private_config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ + -v "$private_config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config 2048 | wc -l' assert_success assert_output 6 run docker run --rm \ - -v "$(pwd)/test/config/key2048/opendkim":/etc/opendkim \ + -v "$private_config/key2048/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` \ /bin/sh -c 'stat -c%s /etc/opendkim/keys/localhost.localdomain/mail.txt' @@ -506,18 +512,20 @@ EOF # Instead it tests the file-size (here 329) - which may differ with a different domain names # This test may be re-used as a global test to provide better test coverage. @test "checking opendkim: generator creates key size 1024" { + private_config="$(duplicate_config_for_container . mail_key_size_1024)" # Prepare set key size 1024 - rm -rf "$(pwd)/test/config/key1024" && mkdir -p "$(pwd)/test/config/key1024" + rm -rf "$private_config/key1024" + mkdir -p "$private_config/key1024" run docker run --rm \ - -v "$(pwd)/test/config/key1024/":/tmp/docker-mailserver/ \ - -v "$(pwd)/test/config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ - -v "$(pwd)/test/config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ + -v "$private_config/key1024/":/tmp/docker-mailserver/ \ + -v "$private_config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ + -v "$private_config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config 1024 | wc -l' assert_success assert_output 6 run docker run --rm \ - -v "$(pwd)/test/config/key1024/opendkim":/etc/opendkim \ + -v "$private_config/key1024/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` \ /bin/sh -c 'stat -c%s /etc/opendkim/keys/localhost.localdomain/mail.txt' @@ -526,139 +534,146 @@ EOF } @test "checking opendkim: generator creates keys, tables and TrustedHosts" { - rm -rf "$(pwd)/test/config/empty" && mkdir -p "$(pwd)/test/config/empty" + private_config="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts)" + rm -rf "$private_config/empty" + mkdir -p "$private_config/empty" run docker run --rm \ - -v "$(pwd)/test/config/empty/":/tmp/docker-mailserver/ \ - -v "$(pwd)/test/config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ - -v "$(pwd)/test/config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ + -v "$private_config/empty/":/tmp/docker-mailserver/ \ + -v "$private_config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ + -v "$private_config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config | wc -l' assert_success assert_output 6 # Check keys for localhost.localdomain run docker run --rm \ - -v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \ + -v "$private_config/empty/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/localhost.localdomain/ | wc -l' assert_success assert_output 2 # Check keys for otherdomain.tld run docker run --rm \ - -v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \ + -v "$private_config/empty/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/otherdomain.tld | wc -l' assert_success assert_output 2 # Check presence of tables and TrustedHosts run docker run --rm \ - -v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \ + -v "$private_config/empty/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c "ls -1 /etc/opendkim | grep -E 'KeyTable|SigningTable|TrustedHosts|keys'|wc -l" assert_success assert_output 4 } @test "checking opendkim: generator creates keys, tables and TrustedHosts without postfix-accounts.cf" { - rm -rf "$(pwd)/test/config/without-accounts" && mkdir -p "$(pwd)/test/config/without-accounts" + private_config="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts_without_postfix_accounts.cf)" + rm -rf "$private_config/without-accounts" + mkdir -p "$private_config/without-accounts" run docker run --rm \ - -v "$(pwd)/test/config/without-accounts/":/tmp/docker-mailserver/ \ - -v "$(pwd)/test/config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ + -v "$private_config/without-accounts/":/tmp/docker-mailserver/ \ + -v "$private_config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config | wc -l' assert_success assert_output 5 # Check keys for localhost.localdomain run docker run --rm \ - -v "$(pwd)/test/config/without-accounts/opendkim":/etc/opendkim \ + -v "$private_config/without-accounts/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/localhost.localdomain/ | wc -l' assert_success assert_output 2 # Check keys for otherdomain.tld # run docker run --rm \ - # -v "$(pwd)/test/config/without-accounts/opendkim":/etc/opendkim \ + # -v "$private_config/without-accounts/opendkim":/etc/opendkim \ # `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/otherdomain.tld | wc -l' # assert_success # [ "$output" -eq 0 ] # Check presence of tables and TrustedHosts run docker run --rm \ - -v "$(pwd)/test/config/without-accounts/opendkim":/etc/opendkim \ + -v "$private_config/without-accounts/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c "ls -1 /etc/opendkim | grep -E 'KeyTable|SigningTable|TrustedHosts|keys'|wc -l" assert_success assert_output 4 } @test "checking opendkim: generator creates keys, tables and TrustedHosts without postfix-virtual.cf" { - rm -rf "$(pwd)/test/config/without-virtual" && mkdir -p "$(pwd)/test/config/without-virtual" + private_config="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts_without_postfix_virtual.cf)" + rm -rf "$private_config/without-virtual" + mkdir -p "$private_config/without-virtual" run docker run --rm \ - -v "$(pwd)/test/config/without-virtual/":/tmp/docker-mailserver/ \ - -v "$(pwd)/test/config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ + -v "$private_config/without-virtual/":/tmp/docker-mailserver/ \ + -v "$private_config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config | wc -l' assert_success assert_output 5 # Check keys for localhost.localdomain run docker run --rm \ - -v "$(pwd)/test/config/without-virtual/opendkim":/etc/opendkim \ + -v "$private_config/without-virtual/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/localhost.localdomain/ | wc -l' assert_success assert_output 2 # Check keys for otherdomain.tld run docker run --rm \ - -v "$(pwd)/test/config/without-virtual/opendkim":/etc/opendkim \ + -v "$private_config/without-virtual/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/otherdomain.tld | wc -l' assert_success assert_output 2 # Check presence of tables and TrustedHosts run docker run --rm \ - -v "$(pwd)/test/config/without-virtual/opendkim":/etc/opendkim \ + -v "$private_config/without-virtual/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c "ls -1 /etc/opendkim | grep -E 'KeyTable|SigningTable|TrustedHosts|keys'|wc -l" assert_success assert_output 4 } @test "checking opendkim: generator creates keys, tables and TrustedHosts using domain name" { - rm -rf "$(pwd)/test/config/with-domain" && mkdir -p "$(pwd)/test/config/with-domain" + private_config="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts_without_postfix_virtual.cf)" + rm -rf "$private_config/with-domain" && mkdir -p "$private_config/with-domain" run docker run --rm \ - -v "$(pwd)/test/config/with-domain/":/tmp/docker-mailserver/ \ - -v "$(pwd)/test/config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ - -v "$(pwd)/test/config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ + -v "$private_config/with-domain/":/tmp/docker-mailserver/ \ + -v "$private_config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ + -v "$private_config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config | wc -l' assert_success assert_output 6 # Generate key using domain name run docker run --rm \ - -v "$(pwd)/test/config/with-domain/":/tmp/docker-mailserver/ \ + -v "$private_config/with-domain/":/tmp/docker-mailserver/ \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-domain testdomain.tld | wc -l' assert_success assert_output 1 # Check keys for localhost.localdomain run docker run --rm \ - -v "$(pwd)/test/config/with-domain/opendkim":/etc/opendkim \ + -v "$private_config/with-domain/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/localhost.localdomain/ | wc -l' assert_success assert_output 2 # Check keys for otherdomain.tld run docker run --rm \ - -v "$(pwd)/test/config/with-domain/opendkim":/etc/opendkim \ + -v "$private_config/with-domain/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/otherdomain.tld | wc -l' assert_success assert_output 2 # Check keys for testdomain.tld run docker run --rm \ - -v "$(pwd)/test/config/with-domain/opendkim":/etc/opendkim \ + -v "$private_config/with-domain/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/testdomain.tld | wc -l' assert_success assert_output 2 # Check presence of tables and TrustedHosts run docker run --rm \ - -v "$(pwd)/test/config/with-domain/opendkim":/etc/opendkim \ + -v "$private_config/with-domain/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c "ls -1 /etc/opendkim | grep -E 'KeyTable|SigningTable|TrustedHosts|keys' | wc -l" assert_success assert_output 4 # Check valid entries actually present in KeyTable run docker run --rm \ - -v "$(pwd)/test/config/with-domain/opendkim":/etc/opendkim \ + -v "$private_config/with-domain/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c \ "egrep 'localhost.localdomain|otherdomain.tld|localdomain2.com|testdomain.tld' /etc/opendkim/KeyTable | wc -l" assert_success assert_output 4 # Check valid entries actually present in SigningTable run docker run --rm \ - -v "$(pwd)/test/config/with-domain/opendkim":/etc/opendkim \ + -v "$private_config/with-domain/opendkim":/etc/opendkim \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c \ "egrep 'localhost.localdomain|otherdomain.tld|localdomain2.com|testdomain.tld' /etc/opendkim/SigningTable | wc -l" assert_success @@ -915,19 +930,20 @@ EOF @test "checking accounts: no error is generated when deleting a user if /tmp/docker-mailserver/postfix-accounts.cf is missing" { run docker run --rm \ - -v "$(pwd)/test/config/without-accounts/":/tmp/docker-mailserver/ \ + -v "$(duplicate_config_for_container without-accounts/ without-accounts-deleting-user)":/tmp/docker-mailserver/ \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'delmailuser -y user3@domain.tld' assert_success [ -z "$output" ] } @test "checking accounts: user3 should have been added to /tmp/docker-mailserver/postfix-accounts.cf even when that file does not exist" { + private_config=$(duplicate_config_for_container without-accounts/ without-accounts_file_does_not_exist) run docker run --rm \ - -v "$(pwd)/test/config/without-accounts/":/tmp/docker-mailserver/ \ + -v "$private_config/without-accounts/":/tmp/docker-mailserver/ \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'addmailuser user3@domain.tld mypassword' assert_success run docker run --rm \ - -v "$(pwd)/test/config/without-accounts/":/tmp/docker-mailserver/ \ + -v "$private_config/without-accounts/":/tmp/docker-mailserver/ \ `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'grep user3@domain.tld -i /tmp/docker-mailserver/postfix-accounts.cf' assert_success [ ! -z "$output" ]