mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-02 17:14:31 +02:00
tests: streamline tests and helpers further (#3747)
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
This commit is contained in:
parent
aba218e6d7
commit
06fab3f129
39 changed files with 243 additions and 247 deletions
|
@ -207,7 +207,7 @@ function _should_have_correct_mail_headers() {
|
|||
# (eg: OVERRIDE_HOSTNAME or `--hostname mail --domainname example.test`)
|
||||
local EXPECTED_HOSTNAME=${3:-${EXPECTED_FQDN}}
|
||||
|
||||
_send_email --from 'user@external.tld' --data 'existing/user1'
|
||||
_send_email --from 'user@external.tld'
|
||||
_wait_for_empty_mail_queue_in_container
|
||||
_count_files_in_directory_in_container '/var/mail/localhost.localdomain/user1/new/' '1'
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ function teardown_file() {
|
|||
|
||||
# TODO replace with _send_email as soon as it supports DSN
|
||||
# TODO ref: https://github.com/jetmore/swaks/issues/41
|
||||
_nc_wrapper 'emails/nc_raw/dsn/unauthenticated'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/authenticated' '0.0.0.0 465'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/authenticated' '0.0.0.0 587'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/unauthenticated.txt'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/authenticated.txt' '0.0.0.0 465'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/authenticated.txt' '0.0.0.0 587'
|
||||
_wait_for_empty_mail_queue_in_container
|
||||
|
||||
_run_in_container grep "${LOG_DSN}" /var/log/mail/mail.log
|
||||
|
@ -62,7 +62,7 @@ function teardown_file() {
|
|||
@test "should only send a DSN when requested from ports 465/587" {
|
||||
export CONTAINER_NAME=${CONTAINER2_NAME}
|
||||
|
||||
_nc_wrapper 'emails/nc_raw/dsn/unauthenticated'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/unauthenticated.txt'
|
||||
_wait_for_empty_mail_queue_in_container
|
||||
|
||||
# DSN requests can now only be made on ports 465 and 587,
|
||||
|
@ -74,8 +74,8 @@ function teardown_file() {
|
|||
assert_failure
|
||||
|
||||
# These ports are excluded via master.cf.
|
||||
_nc_wrapper 'emails/nc_raw/dsn/authenticated' '0.0.0.0 465'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/authenticated' '0.0.0.0 587'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/authenticated.txt' '0.0.0.0 465'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/authenticated.txt' '0.0.0.0 587'
|
||||
_wait_for_empty_mail_queue_in_container
|
||||
|
||||
_run_in_container grep "${LOG_DSN}" /var/log/mail/mail.log
|
||||
|
@ -85,9 +85,9 @@ function teardown_file() {
|
|||
@test "should never send a DSN" {
|
||||
export CONTAINER_NAME=${CONTAINER3_NAME}
|
||||
|
||||
_nc_wrapper 'emails/nc_raw/dsn/unauthenticated'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/authenticated' '0.0.0.0 465'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/authenticated' '0.0.0.0 587'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/unauthenticated.txt'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/authenticated.txt' '0.0.0.0 465'
|
||||
_nc_wrapper 'emails/nc_raw/dsn/authenticated.txt' '0.0.0.0 587'
|
||||
_wait_for_empty_mail_queue_in_container
|
||||
|
||||
# DSN requests are rejected regardless of origin.
|
||||
|
|
|
@ -38,7 +38,7 @@ function teardown_file() { _default_teardown ; }
|
|||
|
||||
@test "delivers mail to existing account" {
|
||||
_wait_for_smtp_port_in_container
|
||||
_send_email --data 'existing/user1' # send a test email
|
||||
_send_email
|
||||
|
||||
# Verify delivery was successful, log line should look similar to:
|
||||
# postfix/lmtp[1274]: 0EA424ABE7D9: to=<user1@localhost.localdomain>, 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 <user1@localhost.localdomain> ixPpB+Zvv2P7BAAAUi6ngw Saved)
|
||||
|
|
|
@ -26,11 +26,10 @@ function teardown_file() { _default_teardown ; }
|
|||
# this test covers https://github.com/docker-mailserver/docker-mailserver/issues/681
|
||||
@test "(Postfix) remove privacy details of the sender" {
|
||||
_send_email \
|
||||
--port 587 -tls --auth LOGIN \
|
||||
--port 587 -tls --auth PLAIN \
|
||||
--auth-user user1@localhost.localdomain \
|
||||
--auth-password mypassword \
|
||||
--data 'privacy'
|
||||
assert_success
|
||||
--data 'privacy.txt'
|
||||
|
||||
_run_until_success_or_timeout 120 _exec_in_container_bash '[[ -d /var/mail/localhost.localdomain/user1/new ]]'
|
||||
assert_success
|
||||
|
|
|
@ -63,46 +63,43 @@ function setup_file() {
|
|||
|
||||
# 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
|
||||
# _send_email --from 'virus@external.tld' --data 'amavis/virus'
|
||||
# _send_email --from 'virus@external.tld' --data 'amavis/virus.txt'
|
||||
|
||||
# Required for 'delivers mail to existing alias':
|
||||
_send_email --to alias1@localhost.localdomain --data 'existing/alias-external'
|
||||
_send_email --to alias1@localhost.localdomain --header "Subject: Test Message existing-alias-external"
|
||||
# Required for 'delivers mail to existing alias with recipient delimiter':
|
||||
_send_email --to alias1~test@localhost.localdomain --data 'existing/alias-recipient-delimiter'
|
||||
_send_email --to alias1~test@localhost.localdomain --header 'Subject: Test Message existing-alias-recipient-delimiter'
|
||||
# Required for 'delivers mail to existing catchall':
|
||||
_send_email --to wildcard@localdomain2.com --data 'existing/catchall-local'
|
||||
_send_email --to wildcard@localdomain2.com --header 'Subject: Test Message existing-catchall-local'
|
||||
# Required for 'delivers mail to regexp alias':
|
||||
_send_email --to test123@localhost.localdomain --data 'existing/regexp-alias-local'
|
||||
_send_email --to test123@localhost.localdomain --header 'Subject: Test Message existing-regexp-alias-local'
|
||||
|
||||
# Required for 'rejects mail to unknown user':
|
||||
_send_email --to nouser@localhost.localdomain --data 'non-existing-user'
|
||||
_send_email --expect-rejection --to nouser@localhost.localdomain
|
||||
assert_failure
|
||||
# Required for 'redirects mail to external aliases':
|
||||
_send_email --to bounce-always@localhost.localdomain --data 'existing/regexp-alias-external'
|
||||
_send_email --to alias2@localhost.localdomain --data 'existing/alias-local'
|
||||
_send_email --to bounce-always@localhost.localdomain
|
||||
_send_email --to alias2@localhost.localdomain
|
||||
# Required for 'rejects spam':
|
||||
_send_email --from 'spam@external.tld' --data 'amavis/spam'
|
||||
_send_email --from 'spam@external.tld' --data 'amavis/spam.txt'
|
||||
|
||||
# Required for 'delivers mail to existing account':
|
||||
_send_email --data 'existing/user1'
|
||||
assert_success
|
||||
_send_email --header 'Subject: Test Message existing-user1'
|
||||
_send_email --to user2@otherdomain.tld
|
||||
assert_success
|
||||
_send_email --to user3@localhost.localdomain
|
||||
assert_success
|
||||
_send_email --to added@localhost.localdomain --data 'existing/added'
|
||||
assert_success
|
||||
_send_email --to user1@localhost.localdomain --data 'existing/user-and-cc-local-alias'
|
||||
assert_success
|
||||
_send_email --data 'sieve/spam-folder'
|
||||
assert_success
|
||||
_send_email --to user2@otherdomain.tld --data 'sieve/pipe'
|
||||
assert_success
|
||||
_send_email --to added@localhost.localdomain --header 'Subject: Test Message existing-added'
|
||||
_send_email \
|
||||
--to user1@localhost.localdomain \
|
||||
--header 'Subject: Test Message existing-user-and-cc-local-alias' \
|
||||
--cc 'alias2@localhost.localdomain'
|
||||
_send_email --data 'sieve/spam-folder.txt'
|
||||
_send_email --to user2@otherdomain.tld --data 'sieve/pipe.txt'
|
||||
_run_in_container_bash 'sendmail root < /tmp/docker-mailserver-test/emails/sendmail/root-email.txt'
|
||||
assert_success
|
||||
}
|
||||
|
||||
function _unsuccessful() {
|
||||
_send_email --port 465 --auth "${1}" --auth-user "${2}" --auth-password wrongpassword
|
||||
_send_email --expect-rejection --port 465 --auth "${1}" --auth-user "${2}" --auth-password wrongpassword --quit-after AUTH
|
||||
assert_failure
|
||||
assert_output --partial 'authentication failed'
|
||||
assert_output --partial 'No authentication type succeeded'
|
||||
|
@ -110,7 +107,6 @@ function _unsuccessful() {
|
|||
|
||||
function _successful() {
|
||||
_send_email --port 465 --auth "${1}" --auth-user "${2}" --auth-password mypassword --quit-after AUTH
|
||||
assert_success
|
||||
assert_output --partial 'Authentication successful'
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue