diff --git a/test/helper/common.bash b/test/helper/common.bash index 09e0b9f1..6920828b 100644 --- a/test/helper/common.bash +++ b/test/helper/common.bash @@ -468,7 +468,7 @@ function _service_log_should_contain_string() { # Filters the mail log for lines that belong to a certain email identified # by its ID. You can obtain the ID of an email you want to send by using -# `_send_mail_and_get_id`. +# `_send_email_and_get_id`. # # @param ${1} = email ID # @param ${2} = container name [OPTIONAL] diff --git a/test/helper/sending.bash b/test/helper/sending.bash index 29a45622..631617a1 100644 --- a/test/helper/sending.bash +++ b/test/helper/sending.bash @@ -7,25 +7,29 @@ # ! ATTENTION: This file is loaded by `common.sh` - do not load it yourself! # ! ATTENTION: This file requires helper functions from `common.sh`! -# Sends a mail from localhost (127.0.0.1) via port 25 to the container. To send -# a custom email, create a file at `test/test-files/email-templates/`, +# Sends a mail from localhost (127.0.0.1) to a container. To send +# a custom email, create a file at `test/test-files/`, # and provide `` as an argument to this function. # # @param ${1} = template file (path) name -# @param ${2} = container name [OPTIONAL] -# @param ${3} = port `nc` will use [OPTIONAL] +# @param ${2} = parameters for `nc` [OPTIONAL] (default: `0.0.0.0 25`) # # ## Attention # +# This function assumes `CONTAINER_NAME` to be properly set (to the container +# name the command should be executed in)! +# # This function will just send the email in an "asynchronous" fashion, i.e. it will # send the email but it will not make sure the mail queue is empty after the mail # has been sent. function _send_email() { local TEMPLATE_FILE=${1:?Must provide name of template file} - local CONTAINER_NAME=$(__handle_container_name "${2:-}") - local PORT=${3:-25} + local NC_PARAMETERS=${2:-0.0.0.0 25} - _run_in_container_bash "nc 0.0.0.0 ${PORT} < /tmp/docker-mailserver-test/email-templates/${TEMPLATE_FILE}.txt" + assert_not_equal "${NC_PARAMETERS}" '' + assert_not_equal "${CONTAINER_NAME:-}" '' + + _run_in_container_bash "nc ${NC_PARAMETERS} < /tmp/docker-mailserver-test/${TEMPLATE_FILE}.txt" assert_success } @@ -39,7 +43,12 @@ function _send_email() { # test file and need to assert certain log entries for each mail individually. # # @param ${1} = template file (path) name -# @param ${2} = container name [OPTIONAL] +# @param ${2} = parameters for `nc` [OPTIONAL] (default: `0.0.0.0 25`) +# +# ## Attention +# +# This function assumes `CONTAINER_NAME` to be properly set (to the container +# name the command should be executed in)! # # ## Safety # @@ -47,11 +56,14 @@ function _send_email() { # If two clients send simultaneously, there is no guarantee the correct ID is # chosen. Sending more than one mail at any given point in time with this function # is UNDEFINED BEHAVIOR! -function _send_mail_and_get_id() { +function _send_email_and_get_id() { local TEMPLATE_FILE=${1:?Must provide name of template file} - local CONTAINER_NAME=$(__handle_container_name "${2:-}") + local NC_PARAMETERS=${2:-0.0.0.0 25} local MAIL_ID + assert_not_equal "${NC_PARAMETERS}" '' + assert_not_equal "${CONTAINER_NAME:-}" '' + _wait_for_empty_mail_queue_in_container _send_email "${TEMPLATE_FILE}" _wait_for_empty_mail_queue_in_container @@ -63,8 +75,6 @@ function _send_mail_and_get_id() { | grep -E -m 1 'postfix/smtpd.*: [A-Z0-9]+: client=localhost' \ | grep -E -o '[A-Z0-9]{9,12}' || true) - run bash -c "-z ${MAIL_ID}" - assert_success 'Could not obtain mail ID - aborting!' - + assert_not_equal "${MAIL_ID}" '' echo "${MAIL_ID}" } diff --git a/test/tests/parallel/set1/dovecot/dovecot_sieve.bats b/test/tests/parallel/set1/dovecot/dovecot_sieve.bats index 9e80932b..889890d2 100644 --- a/test/tests/parallel/set1/dovecot/dovecot_sieve.bats +++ b/test/tests/parallel/set1/dovecot/dovecot_sieve.bats @@ -26,9 +26,9 @@ function setup_file() { _wait_for_smtp_port_in_container # Single mail sent from 'spam@spam.com' that is handled by User (relocate) and Global (copy) sieves for user1: - _send_email 'sieve-spam-folder' + _send_email 'email-templates/sieve-spam-folder' # Mail for user2 triggers the sieve-pipe: - _send_email 'sieve-pipe' + _send_email 'email-templates/sieve-pipe' _wait_for_empty_mail_queue_in_container } diff --git a/test/tests/parallel/set1/dovecot/mailbox_format_dbox.bats b/test/tests/parallel/set1/dovecot/mailbox_format_dbox.bats index 61db93dc..8ce03d9a 100644 --- a/test/tests/parallel/set1/dovecot/mailbox_format_dbox.bats +++ b/test/tests/parallel/set1/dovecot/mailbox_format_dbox.bats @@ -26,7 +26,7 @@ function teardown() { _default_teardown ; } _common_container_setup 'CUSTOM_SETUP_ARGUMENTS' _wait_for_smtp_port_in_container - _send_email 'existing-user1' + _send_email 'email-templates/existing-user1' _wait_for_empty_mail_queue_in_container # Mail received should be stored as `u.1` (one file per message) @@ -47,7 +47,7 @@ function teardown() { _default_teardown ; } _common_container_setup 'CUSTOM_SETUP_ARGUMENTS' _wait_for_smtp_port_in_container - _send_email 'existing-user1' + _send_email 'email-templates/existing-user1' _wait_for_empty_mail_queue_in_container # Mail received should be stored in `m.1` (1 or more messages) diff --git a/test/tests/parallel/set1/dovecot/special_use_folders.bats b/test/tests/parallel/set1/dovecot/special_use_folders.bats index 69db014d..e70899a0 100644 --- a/test/tests/parallel/set1/dovecot/special_use_folders.bats +++ b/test/tests/parallel/set1/dovecot/special_use_folders.bats @@ -14,7 +14,7 @@ function setup_file() { function teardown_file() { _default_teardown ; } @test 'normal delivery works' { - _send_email 'existing-user1' + _send_email 'email-templates/existing-user1' _count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new 1 } @@ -26,8 +26,7 @@ function teardown_file() { _default_teardown ; } } @test "(IMAP) special-use folders should be created when necessary" { - _run_in_container_bash "nc -w 8 0.0.0.0 143 < /tmp/docker-mailserver-test/nc_templates/imap_special_use_folders.txt" - assert_success + _send_email 'nc_templates/imap_special_use_folders' '-w 8 0.0.0.0 143' assert_output --partial 'Drafts' assert_output --partial 'Junk' assert_output --partial 'Trash' diff --git a/test/tests/parallel/set1/spam_virus/amavis.bats b/test/tests/parallel/set1/spam_virus/amavis.bats index c687a70c..875127b1 100644 --- a/test/tests/parallel/set1/spam_virus/amavis.bats +++ b/test/tests/parallel/set1/spam_virus/amavis.bats @@ -26,7 +26,9 @@ function setup_file() { _common_container_setup 'CUSTOM_SETUP_ARGUMENTS' } -function teardown_file() { _default_teardown ; } +function teardown_file() { + docker rm -f "${CONTAINER1_NAME}" "${CONTAINER2_NAME}" +} @test '(Amavis enabled) configuration should be correct' { export CONTAINER_NAME=${CONTAINER1_NAME} diff --git a/test/tests/parallel/set1/spam_virus/clamav.bats b/test/tests/parallel/set1/spam_virus/clamav.bats index e80c3068..31608ef8 100644 --- a/test/tests/parallel/set1/spam_virus/clamav.bats +++ b/test/tests/parallel/set1/spam_virus/clamav.bats @@ -25,7 +25,7 @@ function setup_file() { _wait_for_service postfix _wait_for_smtp_port_in_container - _send_email 'amavis-virus' + _send_email 'email-templates/amavis-virus' _wait_for_empty_mail_queue_in_container } diff --git a/test/tests/parallel/set1/spam_virus/disabled_clamav_spamassassin.bats b/test/tests/parallel/set1/spam_virus/disabled_clamav_spamassassin.bats index e639950b..8402422c 100644 --- a/test/tests/parallel/set1/spam_virus/disabled_clamav_spamassassin.bats +++ b/test/tests/parallel/set1/spam_virus/disabled_clamav_spamassassin.bats @@ -17,7 +17,7 @@ function setup_file() { _common_container_setup 'CUSTOM_SETUP_ARGUMENTS' _wait_for_smtp_port_in_container - _send_email 'existing-user1' + _send_email 'email-templates/existing-user1' _wait_for_empty_mail_queue_in_container } diff --git a/test/tests/parallel/set1/spam_virus/fail2ban.bats b/test/tests/parallel/set1/spam_virus/fail2ban.bats index 262e4e21..8ce843fc 100644 --- a/test/tests/parallel/set1/spam_virus/fail2ban.bats +++ b/test/tests/parallel/set1/spam_virus/fail2ban.bats @@ -74,8 +74,8 @@ function teardown_file() { @test "ban ip on multiple failed login" { CONTAINER1_IP=$(_get_container_ip "${CONTAINER1_NAME}") # Trigger a ban by failing to login twice: - _run_in_container_explicit "${CONTAINER2_NAME}" bash -c "nc ${CONTAINER1_IP} 465 < /tmp/docker-mailserver-test/auth/smtp-auth-login-wrong.txt" - _run_in_container_explicit "${CONTAINER2_NAME}" bash -c "nc ${CONTAINER1_IP} 465 < /tmp/docker-mailserver-test/auth/smtp-auth-login-wrong.txt" + CONTAINER_NAME=${CONTAINER2_NAME} _send_email 'auth/smtp-auth-login-wrong' "${CONTAINER1_IP} 465" + CONTAINER_NAME=${CONTAINER2_NAME} _send_email 'auth/smtp-auth-login-wrong' "${CONTAINER1_IP} 465" # Checking that CONTAINER2_IP is banned in "${CONTAINER1_NAME}" CONTAINER2_IP=$(_get_container_ip "${CONTAINER2_NAME}") diff --git a/test/tests/parallel/set1/spam_virus/postscreen.bats b/test/tests/parallel/set1/spam_virus/postscreen.bats index 4121e1f8..240ba58a 100644 --- a/test/tests/parallel/set1/spam_virus/postscreen.bats +++ b/test/tests/parallel/set1/spam_virus/postscreen.bats @@ -37,9 +37,8 @@ function teardown_file() { docker rm -f "${CONTAINER1_NAME}" "${CONTAINER2_NAME}" } -@test "should fail send when talking out of turn" { - _run_in_container_explicit "${CONTAINER2_NAME}" bash -c "nc ${CONTAINER1_IP} 25 < /tmp/docker-mailserver-test/email-templates/postscreen.txt" - assert_success +@test 'should fail send when talking out of turn' { + CONTAINER_NAME=${CONTAINER2_NAME} _send_email 'email-templates/postscreen' "${CONTAINER1_IP} 25" assert_output --partial 'Protocol error' # Expected postscreen log entry: @@ -62,7 +61,7 @@ function teardown_file() { } # When postscreen is active, it prevents the usual method of piping a file through nc: -# (Won't work: _run_in_container_explicit "${CLIENT_CONTAINER_NAME}" bash -c "nc ${TARGET_CONTAINER_IP} 25 < ${SMTP_TEMPLATE}") +# (Won't work: CONTAINER_NAME=${CLIENT_CONTAINER_NAME} _send_email "${SMTP_TEMPLATE}" "${TARGET_CONTAINER_IP} 25") # The below workaround respects `postscreen_greet_wait` time (default 6 sec), talking to the mail-server in turn: # https://www.postfix.org/postconf.5.html#postscreen_greet_wait function _should_wait_turn_speaking_smtp() { diff --git a/test/tests/parallel/set1/spam_virus/rspamd.bats b/test/tests/parallel/set1/spam_virus/rspamd.bats index 19ffe6e2..96137b3d 100644 --- a/test/tests/parallel/set1/spam_virus/rspamd.bats +++ b/test/tests/parallel/set1/spam_virus/rspamd.bats @@ -31,9 +31,9 @@ function setup_file() { # We will send 3 emails: the first one should pass just fine; the second one should # be rejected due to spam; the third one should be rejected due to a virus. - export MAIL_ID1=$(_send_mail_and_get_id 'existing-user1') - export MAIL_ID2=$(_send_mail_and_get_id 'rspamd-spam') - export MAIL_ID3=$(_send_mail_and_get_id 'rspamd-virus') + export MAIL_ID1=$(_send_email_and_get_id 'email-templates/existing-user1') + export MAIL_ID2=$(_send_email_and_get_id 'email-templates/rspamd-spam') + export MAIL_ID3=$(_send_email_and_get_id 'email-templates/rspamd-virus') # add a nested option to a module _exec_in_container_bash "echo -e 'complicated {\n anOption = someValue;\n}' >/etc/rspamd/override.d/testmodule_complicated.conf" diff --git a/test/tests/parallel/set1/spam_virus/spam_junk_folder.bats b/test/tests/parallel/set1/spam_virus/spam_junk_folder.bats index 7a1bf609..237218e8 100644 --- a/test/tests/parallel/set1/spam_virus/spam_junk_folder.bats +++ b/test/tests/parallel/set1/spam_virus/spam_junk_folder.bats @@ -72,7 +72,7 @@ function teardown() { _default_teardown ; } function _should_send_spam_message() { _wait_for_smtp_port_in_container _wait_for_tcp_port_in_container 10024 # port 10024 is for Amavis - _send_email 'amavis-spam' + _send_email 'email-templates/amavis-spam' } function _should_be_received_by_amavis() { diff --git a/test/tests/parallel/set3/container_configuration/hostname.bats b/test/tests/parallel/set3/container_configuration/hostname.bats index cede4bca..98a98851 100644 --- a/test/tests/parallel/set3/container_configuration/hostname.bats +++ b/test/tests/parallel/set3/container_configuration/hostname.bats @@ -206,7 +206,7 @@ function _should_have_correct_mail_headers() { # (eg: OVERRIDE_HOSTNAME or `--hostname mail --domainname example.test`) local EXPECTED_HOSTNAME=${3:-${EXPECTED_FQDN}} - _send_email 'existing-user1' + _send_email 'email-templates/existing-user1' _wait_for_empty_mail_queue_in_container _count_files_in_directory_in_container '/var/mail/localhost.localdomain/user1/new/' '1' diff --git a/test/tests/parallel/set3/mta/lmtp_ip.bats b/test/tests/parallel/set3/mta/lmtp_ip.bats index ae74001b..861f7f60 100644 --- a/test/tests/parallel/set3/mta/lmtp_ip.bats +++ b/test/tests/parallel/set3/mta/lmtp_ip.bats @@ -38,7 +38,7 @@ function teardown_file() { _default_teardown ; } @test "delivers mail to existing account" { _wait_for_smtp_port_in_container - _send_email 'existing-user1' # send a test email + _send_email 'email-templates/existing-user1' # send a test email # Verify delivery was successful, log line should look similar to: # postfix/lmtp[1274]: 0EA424ABE7D9: to=, relay=127.0.0.1[127.0.0.1]:24, delay=0.13, delays=0.07/0.01/0.01/0.05, dsn=2.0.0, status=sent (250 2.0.0 ixPpB+Zvv2P7BAAAUi6ngw Saved) diff --git a/test/tests/parallel/set3/mta/smtp_delivery.bats b/test/tests/parallel/set3/mta/smtp_delivery.bats index df66debe..af98b2f4 100644 --- a/test/tests/parallel/set3/mta/smtp_delivery.bats +++ b/test/tests/parallel/set3/mta/smtp_delivery.bats @@ -55,40 +55,41 @@ function setup_file() { _wait_for_tcp_port_in_container 10024 _wait_for_smtp_port_in_container_to_respond + # see https://github.com/docker-mailserver/docker-mailserver/pull/3105#issuecomment-1441055103 # Amavis may still not be ready to receive mail, sleep a little to avoid connection failures: - sleep 1 + sleep 5 ### Send mail to queue for delivery ### # TODO: Move to clamav tests (For use when ClamAV is enabled): # _repeat_in_container_until_success_or_timeout 60 "${CONTAINER_NAME}" test -e /var/run/clamav/clamd.ctl - # _run_in_container_bash "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-virus.txt" + # _send_email 'email-templates/amavis-virus' # Required for 'delivers mail to existing alias': - _send_email 'existing-alias-external' + _send_email 'email-templates/existing-alias-external' # Required for 'delivers mail to existing alias with recipient delimiter': - _send_email 'existing-alias-recipient-delimiter' + _send_email 'email-templates/existing-alias-recipient-delimiter' # Required for 'delivers mail to existing catchall': - _send_email 'existing-catchall-local' + _send_email 'email-templates/existing-catchall-local' # Required for 'delivers mail to regexp alias': - _send_email 'existing-regexp-alias-local' + _send_email 'email-templates/existing-regexp-alias-local' # Required for 'rejects mail to unknown user': - _send_email 'non-existing-user' + _send_email 'email-templates/non-existing-user' # Required for 'redirects mail to external aliases': - _send_email 'existing-regexp-alias-external' - _send_email 'existing-alias-local' + _send_email 'email-templates/existing-regexp-alias-external' + _send_email 'email-templates/existing-alias-local' # Required for 'rejects spam': - _send_email 'amavis-spam' + _send_email 'email-templates/amavis-spam' # Required for 'delivers mail to existing account': - _send_email 'existing-user1' - _send_email 'existing-user2' - _send_email 'existing-user3' - _send_email 'existing-added' - _send_email 'existing-user-and-cc-local-alias' - _send_email 'sieve-spam-folder' - _send_email 'sieve-pipe' + _send_email 'email-templates/existing-user1' + _send_email 'email-templates/existing-user2' + _send_email 'email-templates/existing-user3' + _send_email 'email-templates/existing-added' + _send_email 'email-templates/existing-user-and-cc-local-alias' + _send_email 'email-templates/sieve-spam-folder' + _send_email 'email-templates/sieve-pipe' _run_in_container_bash 'sendmail root < /tmp/docker-mailserver-test/email-templates/root-email.txt' } @@ -102,50 +103,43 @@ function setup_file() { } @test "should successfully authenticate with good password (plain)" { - _run_in_container_bash 'nc -w 5 0.0.0.0 465 < /tmp/docker-mailserver-test/auth/smtp-auth-plain.txt' - assert_success + _send_email 'auth/smtp-auth-plain' '-w 5 0.0.0.0 465' assert_output --partial 'Authentication successful' } @test "should fail to authenticate with wrong password (plain)" { - _run_in_container_bash 'nc -w 20 0.0.0.0 465 < /tmp/docker-mailserver-test/auth/smtp-auth-plain-wrong.txt' + _send_email 'auth/smtp-auth-plain-wrong' '-w 20 0.0.0.0 465' assert_output --partial 'authentication failed' - assert_success } @test "should successfully authenticate with good password (login)" { - _run_in_container_bash 'nc -w 5 0.0.0.0 465 < /tmp/docker-mailserver-test/auth/smtp-auth-login.txt' - assert_success + _send_email 'auth/smtp-auth-login' '-w 5 0.0.0.0 465' assert_output --partial 'Authentication successful' } @test "should fail to authenticate with wrong password (login)" { - _run_in_container_bash 'nc -w 20 0.0.0.0 465 < /tmp/docker-mailserver-test/auth/smtp-auth-login-wrong.txt' + _send_email 'auth/smtp-auth-login-wrong' '-w 20 0.0.0.0 465' assert_output --partial 'authentication failed' - assert_success } @test "[user: 'added'] should successfully authenticate with good password (plain)" { - _run_in_container_bash 'nc -w 5 0.0.0.0 465 < /tmp/docker-mailserver-test/auth/added-smtp-auth-plain.txt' - assert_success + _send_email 'auth/added-smtp-auth-plain' '-w 5 0.0.0.0 465' assert_output --partial 'Authentication successful' } @test "[user: 'added'] should fail to authenticate with wrong password (plain)" { - _run_in_container_bash 'nc -w 20 0.0.0.0 465 < /tmp/docker-mailserver-test/auth/added-smtp-auth-plain-wrong.txt' - assert_success + _send_email 'auth/added-smtp-auth-plain-wrong' '-w 20 0.0.0.0 465' assert_output --partial 'authentication failed' } @test "[user: 'added'] should successfully authenticate with good password (login)" { - _run_in_container_bash 'nc -w 5 0.0.0.0 465 < /tmp/docker-mailserver-test/auth/added-smtp-auth-login.txt' + _send_email 'auth/added-smtp-auth-login' '-w 5 0.0.0.0 465' assert_success assert_output --partial 'Authentication successful' } @test "[user: 'added'] should fail to authenticate with wrong password (login)" { - _run_in_container_bash 'nc -w 20 0.0.0.0 465 < /tmp/docker-mailserver-test/auth/added-smtp-auth-login-wrong.txt' - assert_success + _send_email 'auth/added-smtp-auth-login-wrong' '-w 20 0.0.0.0 465' assert_output --partial 'authentication failed' } @@ -264,8 +258,7 @@ function setup_file() { # Dovecot does not support SMTPUTF8, so while we can send we cannot receive # Better disable SMTPUTF8 support entirely if we can't handle it correctly @test "not advertising smtputf8" { - _run_in_container_bash 'nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/smtp-ehlo.txt' - assert_success + _send_email 'email-templates/smtp-ehlo' refute_output --partial 'SMTPUTF8' } diff --git a/test/tests/parallel/set3/mta/smtponly.bats b/test/tests/parallel/set3/mta/smtponly.bats index a53107fc..66123de6 100644 --- a/test/tests/parallel/set3/mta/smtponly.bats +++ b/test/tests/parallel/set3/mta/smtponly.bats @@ -32,7 +32,7 @@ function teardown_file() { _default_teardown ; } assert_success # it looks as if someone tries to send mail to another domain outside of DMS - _send_email 'smtp-only' + _send_email 'email-templates/smtp-only' _wait_for_empty_mail_queue_in_container # this seemingly succeeds, but looking at the logs, it doesn't diff --git a/test/tests/serial/mail_pop3.bats b/test/tests/serial/mail_pop3.bats index c181de79..cb07484a 100644 --- a/test/tests/serial/mail_pop3.bats +++ b/test/tests/serial/mail_pop3.bats @@ -24,13 +24,11 @@ function teardown_file() { _default_teardown ; } } @test 'authentication works' { - _run_in_container_bash 'nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver-test/auth/pop3-auth.txt' - assert_success + _send_email 'auth/pop3-auth' '-w 1 0.0.0.0 110' } @test 'added user authentication works' { - _run_in_container_bash 'nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver-test/auth/added-pop3-auth.txt' - assert_success + _send_email 'auth/added-pop3-auth' '-w 1 0.0.0.0 110' } @test '/var/log/mail/mail.log is error-free' { diff --git a/test/tests/serial/mail_with_imap.bats b/test/tests/serial/mail_with_imap.bats index 14c67b5d..d729c142 100644 --- a/test/tests/serial/mail_with_imap.bats +++ b/test/tests/serial/mail_with_imap.bats @@ -21,8 +21,7 @@ function setup_file() { function teardown_file() { _default_teardown ; } @test '(Dovecot) LDAP RIMAP connection and authentication works' { - _run_in_container_bash "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/imap-auth.txt" - assert_success + _send_email 'auth/imap-auth' '-w 1 0.0.0.0 143' } @test '(SASLauthd) SASL RIMAP authentication works' { @@ -31,14 +30,13 @@ function teardown_file() { _default_teardown ; } } @test '(SASLauthd) RIMAP SMTP authentication works' { - _run_in_container_bash 'nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login.txt' - assert_success + _send_email 'auth/smtp-auth-login' '-w 5 0.0.0.0 25' assert_output --partial 'Error: authentication not enabled' - _run_in_container_bash 'nc -w 5 0.0.0.0 465 < /tmp/docker-mailserver-test/auth/smtp-auth-login.txt' - assert_success + + _send_email 'auth/smtp-auth-login' '-w 5 0.0.0.0 465' assert_output --partial 'Authentication successful' - _run_in_container_bash 'nc -w 5 0.0.0.0 587 < /tmp/docker-mailserver-test/auth/smtp-auth-login.txt' - assert_success + + _send_email 'auth/smtp-auth-login' '-w 5 0.0.0.0 587' assert_output --partial 'Authentication successful' } diff --git a/test/tests/serial/tests.bats b/test/tests/serial/tests.bats index abcd808a..f28787f8 100644 --- a/test/tests/serial/tests.bats +++ b/test/tests/serial/tests.bats @@ -81,13 +81,11 @@ function teardown_file() { _default_teardown ; } } @test "imap: authentication works" { - _run_in_container_bash "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/imap-auth.txt" - assert_success + _send_email 'auth/imap-auth' '-w 1 0.0.0.0 143' } @test "imap: added user authentication works" { - _run_in_container_bash "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/added-imap-auth.txt" - assert_success + _send_email 'auth/added-imap-auth' '-w 1 0.0.0.0 143' } # @@ -416,12 +414,10 @@ EOF sleep 10 # send some big emails - _run_in_container_bash "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/quota-exceeded.txt" - assert_success - _run_in_container_bash "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/quota-exceeded.txt" - assert_success - _run_in_container_bash "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/quota-exceeded.txt" - assert_success + _send_email 'email-templates/quota-exceeded' '0.0.0.0 25' + _send_email 'email-templates/quota-exceeded' '0.0.0.0 25' + _send_email 'email-templates/quota-exceeded' '0.0.0.0 25' + # check for quota warn message existence run _repeat_until_success_or_timeout 20 _exec_in_container_bash 'grep \"Subject: quota warning\" /var/mail/otherdomain.tld/quotauser/new/ -R' assert_success