diff --git a/test/default_relay_host.bats b/test/default_relay_host.bats index faa0abd5..e006ed8b 100644 --- a/test/default_relay_host.bats +++ b/test/default_relay_host.bats @@ -3,7 +3,7 @@ load 'test_helper/common' function setup() { docker run -d --name mail_with_default_relay \ -v "$(duplicate_config_for_container relay-hosts)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e DEFAULT_RELAY_HOST=default.relay.host.invalid:25 \ --cap-add=SYS_PTRACE \ -e PERMIT_DOCKER=host \ @@ -23,4 +23,4 @@ function teardown() { @test "checking default relay host: default relay host is added to main.cf" { run docker exec mail_with_default_relay /bin/sh -c 'grep -e "^relayhost =" /etc/postfix/main.cf' assert_output 'relayhost = default.relay.host.invalid:25' -} \ No newline at end of file +} diff --git a/test/mail_dhparams_default.bats b/test/mail_dhparams_default.bats index 72a789ea..ff984576 100644 --- a/test/mail_dhparams_default.bats +++ b/test/mail_dhparams_default.bats @@ -23,7 +23,7 @@ function teardown() { function setup_file() { docker run -d --name mail_default_dhparams_one_dir \ -v "$(duplicate_config_for_container . mail_default_dhparams_both_one_dir)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e DMS_DEBUG=0 \ -e ONE_DIR=1 \ -h mail.my-domain.com -t ${NAME} @@ -31,7 +31,7 @@ function setup_file() { docker run -d --name mail_default_dhparams_not_one_dir \ -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 \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e DMS_DEBUG=0 \ -e ONE_DIR=0 \ -h mail.my-domain.com -t ${NAME} diff --git a/test/mail_dhparams_manual_not_one_dir.bats b/test/mail_dhparams_manual_not_one_dir.bats index 928e3bb3..e8b76efe 100644 --- a/test/mail_dhparams_manual_not_one_dir.bats +++ b/test/mail_dhparams_manual_not_one_dir.bats @@ -13,21 +13,21 @@ load 'test_helper/common' function setup() { - run_setup_file_if_necessary + run_setup_file_if_necessary } function teardown() { - run_teardown_file_if_necessary + run_teardown_file_if_necessary } 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" "${PRIVATE_CONFIG}/dhparams.pem" + local PRIVATE_CONFIG=$(duplicate_config_for_container .) + # copy the custom DHE params in local config + cp "$(pwd)/test/test-files/ssl/custom-dhe-params.pem" "${PRIVATE_CONFIG}/dhparams.pem" - docker run -d --name mail_manual_dhparams_not_one_dir \ + docker run -d --name mail_manual_dhparams_not_one_dir \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e DMS_DEBUG=0 \ -e ONE_DIR=0 \ -h mail.my-domain.com -t ${NAME} @@ -35,7 +35,7 @@ function setup_file() { } function teardown_file() { - docker rm -f mail_manual_dhparams_not_one_dir + docker rm -f mail_manual_dhparams_not_one_dir } @test "first" { diff --git a/test/mail_dhparams_manual_one_dir.bats b/test/mail_dhparams_manual_one_dir.bats index 69091d83..5063fa42 100644 --- a/test/mail_dhparams_manual_one_dir.bats +++ b/test/mail_dhparams_manual_one_dir.bats @@ -22,8 +22,8 @@ function teardown() { function setup_file() { docker run -d --name mail_manual_dhparams_one_dir \ -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 \ + -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 \ -e ONE_DIR=1 \ -h mail.my-domain.com -t ${NAME} diff --git a/test/mail_disabled_clamav_spamassassin.bats b/test/mail_disabled_clamav_spamassassin.bats index a85cd712..f05be894 100644 --- a/test/mail_disabled_clamav_spamassassin.bats +++ b/test/mail_disabled_clamav_spamassassin.bats @@ -11,7 +11,7 @@ teardown() { setup_file() { docker run --rm -d --name mail_disabled_clamav_spamassassin \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_CLAMAV=0 \ -e ENABLE_SPAMASSASSIN=0 \ -e DMS_DEBUG=0 \ diff --git a/test/mail_fail2ban.bats b/test/mail_fail2ban.bats index d96b2cfa..b764ce2e 100644 --- a/test/mail_fail2ban.bats +++ b/test/mail_fail2ban.bats @@ -11,7 +11,7 @@ function teardown() { function setup_file() { docker run --rm -d --name mail_fail2ban \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_FAIL2BAN=1 \ -e POSTSCREEN_ACTION=ignore \ --cap-add=NET_ADMIN \ @@ -25,7 +25,7 @@ function setup_file() { tail -f /var/log/faillog wait_for_finished_setup_in_container mail_fail2ban - + } function teardown_file() { @@ -146,4 +146,4 @@ function teardown_file() { @test "last" { skip 'this test is only there to reliably mark the end for the teardown_file' -} \ No newline at end of file +} diff --git a/test/mail_fetchmail.bats b/test/mail_fetchmail.bats index cdafafdc..d56014f2 100644 --- a/test/mail_fetchmail.bats +++ b/test/mail_fetchmail.bats @@ -11,7 +11,7 @@ function teardown() { function setup_file() { docker run -d --name mail_fetchmail \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_FETCHMAIL=1 \ --cap-add=NET_ADMIN \ -e DMS_DEBUG=0 \ @@ -61,4 +61,4 @@ function teardown_file() { @test "last" { skip 'this test is only there to reliably mark the end for the teardown_file' -} \ No newline at end of file +} diff --git a/test/mail_lmtp_ip.bats b/test/mail_lmtp_ip.bats index 42ad9639..bfb1c2e0 100644 --- a/test/mail_lmtp_ip.bats +++ b/test/mail_lmtp_ip.bats @@ -12,7 +12,7 @@ setup_file() { docker run -d --name mail_lmtp_ip \ -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 \ + -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 \ -e DMS_DEBUG=0 \ diff --git a/test/mail_override_hostname.bats b/test/mail_override_hostname.bats index 1a6da949..2e1ea3f3 100644 --- a/test/mail_override_hostname.bats +++ b/test/mail_override_hostname.bats @@ -7,7 +7,7 @@ function setup() { function setup_file() { docker run --rm -d --name mail_override_hostname \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e PERMIT_DOCKER=network \ -e DMS_DEBUG=0 \ -e ENABLE_SRS=1 \ @@ -15,7 +15,7 @@ function setup_file() { -h unknown.domain.tld \ -t ${NAME} - wait_for_smtp_port_in_container mail_override_hostname + wait_for_smtp_port_in_container mail_override_hostname # postfix virtual transport lmtp docker exec mail_override_hostname /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt" } diff --git a/test/mail_pop3.bats b/test/mail_pop3.bats index c6d429e5..b3f8b705 100644 --- a/test/mail_pop3.bats +++ b/test/mail_pop3.bats @@ -11,7 +11,7 @@ function teardown() { function setup_file() { docker run -d --name mail_pop3 \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_POP3=1 \ -e DMS_DEBUG=0 \ -h mail.my-domain.com -t ${NAME} @@ -91,4 +91,4 @@ function teardown_file() { @test "last" { skip 'this test is only there to reliably mark the end for the teardown_file' -} \ No newline at end of file +} diff --git a/test/mail_postfix_inet.bats b/test/mail_postfix_inet.bats index 94328f11..18220438 100644 --- a/test/mail_postfix_inet.bats +++ b/test/mail_postfix_inet.bats @@ -16,14 +16,14 @@ function teardown() { function setup_file() { docker run -d --name mail_postfix_inet_default \ -v "$(duplicate_config_for_container . mail_postfix_inet_default)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -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 "$(duplicate_config_for_container . mail_postfix_inet_all)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e POSTFIX_INET_PROTOCOLS=all \ -h mail.my-domain.com -t "${NAME}" @@ -31,7 +31,7 @@ function setup_file() { docker run -d --name mail_postfix_inet_ipv4 \ -v "$(duplicate_config_for_container . mail_postfix_inet_ipv4)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e POSTFIX_INET_PROTOCOLS=ipv4 \ -h mail.my-domain.com -t "${NAME}" @@ -39,7 +39,7 @@ function setup_file() { docker run -d --name mail_postfix_inet_ipv6 \ -v "$(duplicate_config_for_container . mail_postfix_inet_ipv6)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -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 8df044bc..e303fbe6 100644 --- a/test/mail_postscreen.bats +++ b/test/mail_postscreen.bats @@ -14,7 +14,7 @@ teardown() { setup_file() { docker run -d --name mail_postscreen \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e POSTSCREEN_ACTION=enforce \ --cap-add=NET_ADMIN \ -h mail.my-domain.com -t ${NAME} @@ -59,4 +59,4 @@ teardown_file() { @test "last" { skip 'only used to call teardown_file from teardown' -} \ No newline at end of file +} diff --git a/test/mail_privacy.bats b/test/mail_privacy.bats index a425f6b8..c6d664ba 100644 --- a/test/mail_privacy.bats +++ b/test/mail_privacy.bats @@ -11,7 +11,7 @@ function teardown() { function setup_file() { docker run -d --name mail_privacy \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e SASL_PASSWD="external-domain.com username:password" \ -e ENABLE_MANAGESIEVE=1 \ --cap-add=SYS_PTRACE \ diff --git a/test/mail_quotas_disabled.bats b/test/mail_quotas_disabled.bats index faefd2af..cbdd2137 100644 --- a/test/mail_quotas_disabled.bats +++ b/test/mail_quotas_disabled.bats @@ -16,7 +16,7 @@ function teardown() { function setup_file() { docker run -d --name mail_no_quotas \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e DMS_DEBUG=0 \ -e ENABLE_QUOTAS=0 \ -h mail.my-domain.com -t "${NAME}" diff --git a/test/mail_smtponly.bats b/test/mail_smtponly.bats index 7b9cec5c..5ab37274 100644 --- a/test/mail_smtponly.bats +++ b/test/mail_smtponly.bats @@ -11,7 +11,7 @@ function teardown() { function setup_file() { docker run --rm -d --name mail_smtponly \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e SMTP_ONLY=1 \ -e PERMIT_DOCKER=network \ -e DMS_DEBUG=0 \ diff --git a/test/mail_spam_bounced.bats b/test/mail_spam_bounced.bats index f6af38ae..ebe87675 100644 --- a/test/mail_spam_bounced.bats +++ b/test/mail_spam_bounced.bats @@ -16,7 +16,7 @@ function teardown() { function setup_file() { docker run -d --name mail_spam_bounced_defined \ -v "$(duplicate_config_for_container . mail_spam_bounced_defined)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_SPAMASSASSIN=1 \ -e SPAMASSASSIN_SPAM_TO_INBOX=0 \ -h mail.my-domain.com -t "${NAME}" @@ -25,7 +25,7 @@ function setup_file() { docker run -d --name mail_spam_bounced_undefined \ -v "$(duplicate_config_for_container . mail_spam_bounced_defined)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -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 6e7259e2..c53f7e63 100644 --- a/test/mail_spam_junk_folder.bats +++ b/test/mail_spam_junk_folder.bats @@ -16,7 +16,7 @@ function teardown() { function setup_file() { docker run -d --name mail_spam_moved_junk \ -v "$(duplicate_config_for_container . mail_spam_moved_junk)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_SPAMASSASSIN=1 \ -e SPAMASSASSIN_SPAM_TO_INBOX=1 \ -e MOVE_SPAM_TO_JUNK=1 \ @@ -27,7 +27,7 @@ function setup_file() { docker run -d --name mail_spam_moved_new \ -v "$(duplicate_config_for_container . mail_spam_moved_new)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_SPAMASSASSIN=1 \ -e SPAMASSASSIN_SPAM_TO_INBOX=1 \ -e MOVE_SPAM_TO_JUNK=0 \ diff --git a/test/mail_special_use_folders.bats b/test/mail_special_use_folders.bats index cb6eb84a..5bbee43b 100644 --- a/test/mail_special_use_folders.bats +++ b/test/mail_special_use_folders.bats @@ -11,7 +11,7 @@ teardown() { setup_file() { docker run -d --name mail_special_use_folders \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e SASL_PASSWD="external-domain.com username:password" \ -e ENABLE_CLAMAV=0 \ -e ENABLE_SPAMASSASSIN=0 \ diff --git a/test/mail_srs_domainname.bats b/test/mail_srs_domainname.bats index efbc5d83..13c482d0 100644 --- a/test/mail_srs_domainname.bats +++ b/test/mail_srs_domainname.bats @@ -3,7 +3,7 @@ load 'test_helper/common' @test "checking SRS: SRS_DOMAINNAME is used correctly" { docker run --rm -d --name mail_srs_domainname \ -v "$(duplicate_config_for_container . mail_srs_domainname)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e PERMIT_DOCKER=network \ -e DMS_DEBUG=0 \ -e ENABLE_SRS=1 \ @@ -20,7 +20,7 @@ load 'test_helper/common' @test "checking SRS: DOMAINNAME is handled correctly" { docker run --rm -d --name mail_domainname \ -v "$(duplicate_config_for_container . mail_domainname)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e PERMIT_DOCKER=network \ -e DMS_DEBUG=0 \ -e ENABLE_SRS=1 \ @@ -31,4 +31,4 @@ load 'test_helper/common' teardown() { docker rm -f mail_domainname; } repeat_until_success_or_timeout 15 docker exec mail_domainname grep "SRS_DOMAIN=my-domain.com" /etc/default/postsrsd -} \ No newline at end of file +} diff --git a/test/mail_ssl_letsencrypt.bats b/test/mail_ssl_letsencrypt.bats index 45714509..45694923 100644 --- a/test/mail_ssl_letsencrypt.bats +++ b/test/mail_ssl_letsencrypt.bats @@ -9,10 +9,12 @@ function teardown() { } 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 "$(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 \ @@ -22,7 +24,7 @@ function setup_file() { 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 "$(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 \ @@ -34,7 +36,7 @@ function setup_file() { 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 \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e DMS_DEBUG=0 \ -e SSL_TYPE=letsencrypt \ -e "SSL_DOMAIN=*.example.com" \ diff --git a/test/mail_ssl_manual.bats b/test/mail_ssl_manual.bats index 0ce0a90c..a9d0faee 100644 --- a/test/mail_ssl_manual.bats +++ b/test/mail_ssl_manual.bats @@ -11,7 +11,7 @@ function teardown() { function setup_file() { docker run -d --name mail_manual_ssl \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -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 \ -e SSL_KEY_PATH=/tmp/docker-mailserver/letsencrypt/mail.my-domain.com/privkey.pem \ @@ -57,4 +57,4 @@ function teardown_file() { @test "last" { skip 'this test is only there to reliably mark the end for the teardown_file' -} \ No newline at end of file +} diff --git a/test/mail_undef_spam_subject.bats b/test/mail_undef_spam_subject.bats index 0f9b83c7..6cc61314 100644 --- a/test/mail_undef_spam_subject.bats +++ b/test/mail_undef_spam_subject.bats @@ -3,14 +3,14 @@ load 'test_helper/common' function setup() { docker run -d --name mail_undef_spam_subject \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -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 "$(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 \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/onedir":/var/mail-state \ -e ENABLE_CLAMAV=1 \ -e SPOOF_PROTECTION=1 \ -e ENABLE_SPAMASSASSIN=1 \ @@ -47,4 +47,4 @@ function teardown() { assert_success run docker exec mail_undef_spam_subject /bin/sh -c "grep '\$sa_spam_subject_tag' /etc/amavis/conf.d/20-debian_defaults | grep '= undef'" assert_success -} \ No newline at end of file +} diff --git a/test/mail_with_imap.bats b/test/mail_with_imap.bats index 0b23693a..ac16c2c1 100644 --- a/test/mail_with_imap.bats +++ b/test/mail_with_imap.bats @@ -12,7 +12,7 @@ teardown() { setup_file() { docker run -d --name mail_with_imap \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_SASLAUTHD=1 \ -e SASLAUTHD_MECHANISMS=rimap \ -e SASLAUTHD_MECH_OPTIONS=127.0.0.1 \ diff --git a/test/mail_with_ldap.bats b/test/mail_with_ldap.bats index 3b4254a8..098e986a 100644 --- a/test/mail_with_ldap.bats +++ b/test/mail_with_ldap.bats @@ -15,11 +15,11 @@ function setup_file() { docker run -d --name ldap_for_mail \ -e LDAP_DOMAIN="localhost.localdomain" \ - -h ldap.my-domain.com -t ldap - + -h ldap.my-domain.com -t ldap + docker run -d --name mail_with_ldap \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_LDAP=1 \ -e LDAP_SERVER_HOST=ldap \ -e LDAP_START_TLS=no \ @@ -214,7 +214,7 @@ function teardown_file() { # Pflogsumm delivery check # -@test "checking pflogsum delivery" { +@test "checking pflogsum delivery" { # checking default sender is correctly set when env variable not defined run docker exec mail_with_ldap grep "mailserver-report@mail.my-domain.com" /etc/logrotate.d/maillog assert_success diff --git a/test/mail_with_mdbox.bats b/test/mail_with_mdbox.bats index 8913eff4..0ad9361f 100644 --- a/test/mail_with_mdbox.bats +++ b/test/mail_with_mdbox.bats @@ -11,7 +11,7 @@ teardown() { setup_file() { docker run -d --name mail_with_mdbox_format \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e SASL_PASSWD="external-domain.com username:password" \ -e ENABLE_CLAMAV=0 \ -e ENABLE_SPAMASSASSIN=0 \ diff --git a/test/mail_with_postgrey.bats b/test/mail_with_postgrey.bats index 11ce2f04..247852ae 100644 --- a/test/mail_with_postgrey.bats +++ b/test/mail_with_postgrey.bats @@ -11,7 +11,7 @@ function teardown() { function setup_file() { docker run -d --name mail_with_postgrey \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_POSTGREY=1 \ -e POSTGREY_DELAY=15 \ -e POSTGREY_MAX_AGE=35 \ @@ -98,4 +98,4 @@ function teardown_file() { @test "last" { # this test is only there to reliably mark the end for the teardown_file -} \ No newline at end of file +} diff --git a/test/mail_with_postgrey_disabled_by_default.bats b/test/mail_with_postgrey_disabled_by_default.bats index 31b4baf5..dc3ae80c 100644 --- a/test/mail_with_postgrey_disabled_by_default.bats +++ b/test/mail_with_postgrey_disabled_by_default.bats @@ -3,7 +3,7 @@ load 'test_helper/common' function setup() { CONTAINER=$(docker run -d \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e DMS_DEBUG=0 \ -h mail.my-domain.com -t ${NAME}) # using postfix availability as start indicator, this might be insufficient for postgrey @@ -17,4 +17,4 @@ function teardown() { @test "checking process: postgrey (disabled in default configuration)" { run docker exec $CONTAINER /bin/bash -c "ps aux --forest | grep -v grep | grep 'postgrey'" assert_failure -} \ No newline at end of file +} diff --git a/test/mail_with_relays.bats b/test/mail_with_relays.bats index 07afab7e..a374efd4 100644 --- a/test/mail_with_relays.bats +++ b/test/mail_with_relays.bats @@ -16,7 +16,7 @@ function setup_file() { docker run -d --name mail_with_relays \ -v "$tmp_confdir":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e RELAY_HOST=default.relay.com \ -e RELAY_PORT=2525 \ -e RELAY_USER=smtp_user \ diff --git a/test/mail_with_sdbox.bats b/test/mail_with_sdbox.bats index 2056d480..25589aee 100644 --- a/test/mail_with_sdbox.bats +++ b/test/mail_with_sdbox.bats @@ -11,7 +11,7 @@ teardown() { setup_file() { docker run -d --name mail_with_sdbox_format \ -v "$(duplicate_config_for_container .)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e SASL_PASSWD="external-domain.com username:password" \ -e ENABLE_CLAMAV=0 \ -e ENABLE_SPAMASSASSIN=0 \ diff --git a/test/permit_docker.bats b/test/permit_docker.bats index 3edb6cdd..400966e3 100644 --- a/test/permit_docker.bats +++ b/test/permit_docker.bats @@ -9,7 +9,7 @@ setup() { # 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 "$(duplicate_config_for_container . mail_smtponly_second_network)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e SMTP_ONLY=1 \ -e PERMIT_DOCKER=connected-networks \ -e DMS_DEBUG=0 \ @@ -20,7 +20,7 @@ setup() { docker start mail_smtponly_second_network docker run -d --name mail_smtponly_second_network_sender \ -v "$(duplicate_config_for_container . mail_smtponly_second_network_sender)":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e SMTP_ONLY=1 \ -e PERMIT_DOCKER=connected-networks \ -e DMS_DEBUG=0 \ @@ -56,4 +56,4 @@ teardown() { repeat_until_success_or_timeout 60 run docker exec mail_smtponly_second_network /bin/sh -c 'grep -cE "to=.*status\=sent" /var/log/mail/mail.log' [ "$status" -ge 0 ] -} \ No newline at end of file +} diff --git a/test/test_helper/common.bash b/test/test_helper/common.bash index 6e0ebb80..d768cc65 100644 --- a/test/test_helper/common.bash +++ b/test/test_helper/common.bash @@ -75,7 +75,7 @@ function container_is_running() { # @param ${1} port # @param ${2} container name function wait_for_tcp_port_in_container() { - repeat_until_success_or_timeout --fatal-test "container_is_running ${2}" "${TEST_TIMEOUT_IN_SECONDS}" docker exec "${2}" /bin/sh -c "nc -z 0.0.0.0 ${1}" + repeat_until_success_or_timeout --fatal-test "container_is_running ${2}" "${TEST_TIMEOUT_IN_SECONDS}" docker exec ${2} /bin/sh -c "nc -z 0.0.0.0 ${1}" } # @param ${1} name of the postfix container @@ -177,8 +177,6 @@ function wait_for_service() { function wait_for_changes_to_be_detected_in_container() { local CONTAINER_NAME="${1}" local TIMEOUT=${TEST_TIMEOUT_IN_SECONDS} - repeat_in_container_until_success_or_timeout \ - "${TIMEOUT}" \ - "${CONTAINER_NAME}" \ - bash -c 'source /usr/local/bin/helper_functions.sh; cmp --silent -- <(_monitored_files_checksums) "${CHKSUM_FILE}" >/dev/null' + repeat_in_container_until_success_or_timeout "${TIMEOUT}" "${CONTAINER_NAME}" \ + bash -c 'source /usr/local/bin/helper_functions.sh; cmp --silent -- <(_monitored_files_checksums) "${CHKSUM_FILE}" >/dev/null' } diff --git a/test/tests.bats b/test/tests.bats index b4ab4277..e6219606 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -10,7 +10,7 @@ setup() { } setup_file() { - PRIVATE_CONFIG="$(duplicate_config_for_container . mail)" + local PRIVATE_CONFIG="$(duplicate_config_for_container . mail)" mv "${PRIVATE_CONFIG}/user-patches/user-patches.sh" "${PRIVATE_CONFIG}/user-patches.sh" docker run --rm -d --name mail \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ @@ -460,7 +460,7 @@ 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)" + local PRIVATE_CONFIG="$(duplicate_config_for_container . mail_default_key_size)" # Prepare default key size 2048 rm -rf "${PRIVATE_CONFIG}/keyDefault" mkdir -p "${PRIVATE_CONFIG}/keyDefault" @@ -486,7 +486,7 @@ 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)" + local PRIVATE_CONFIG="$(duplicate_config_for_container . mail_key_size_2048)" # Prepare set key size 2048 rm -rf "${PRIVATE_CONFIG}/key2048" mkdir -p "${PRIVATE_CONFIG}/config/key2048" @@ -511,7 +511,7 @@ 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)" + local PRIVATE_CONFIG="$(duplicate_config_for_container . mail_key_size_1024)" # Prepare set key size 1024 rm -rf "${PRIVATE_CONFIG}/key1024" mkdir -p "${PRIVATE_CONFIG}/key1024" @@ -533,7 +533,7 @@ EOF } @test "checking opendkim: generator creates keys, tables and TrustedHosts" { - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts)" + local 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 \ @@ -564,7 +564,7 @@ EOF } @test "checking opendkim: generator creates keys, tables and TrustedHosts without postfix-accounts.cf" { - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts_without_postfix_accounts.cf)" + local 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 \ @@ -594,7 +594,7 @@ EOF } @test "checking opendkim: generator creates keys, tables and TrustedHosts without postfix-virtual.cf" { - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts_without_postfix_virtual.cf)" + local 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 \ @@ -624,7 +624,7 @@ EOF } @test "checking opendkim: generator creates keys, tables and TrustedHosts using domain name" { - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts_without_postfix_virtual.cf)" + local 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 "${PRIVATE_CONFIG}/with-domain/":/tmp/docker-mailserver/ \ @@ -932,7 +932,7 @@ EOF } @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) + local PRIVATE_CONFIG=$(duplicate_config_for_container without-accounts/ without-accounts_file_does_not_exist) run docker run --rm \ -v "${PRIVATE_CONFIG}/without-accounts/":/tmp/docker-mailserver/ \ "${IMAGE_NAME:?}" /bin/sh -c 'addmailuser user3@domain.tld mypassword'