mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
use new filters in tests
This commit is contained in:
parent
51a3b3f5f3
commit
6503f24b61
|
@ -38,8 +38,7 @@ function teardown_file() { _default_teardown ; }
|
|||
}
|
||||
|
||||
@test 'should be identified by Amavis' {
|
||||
_run_in_container grep -i 'Found secondary av scanner ClamAV-clamscan' /var/log/mail/mail.log
|
||||
assert_success
|
||||
_service_log_should_contain_string 'mail' 'Found secondary av scanner ClamAV-clamscan'
|
||||
}
|
||||
|
||||
@test 'freshclam cron is enabled' {
|
||||
|
@ -53,6 +52,6 @@ function teardown_file() { _default_teardown ; }
|
|||
}
|
||||
|
||||
@test 'rejects virus' {
|
||||
_run_in_container_bash "grep 'Blocked INFECTED' /var/log/mail/mail.log | grep '<virus@external.tld> -> <user1@localhost.localdomain>'"
|
||||
assert_success
|
||||
_service_log_should_contain_string 'mail' 'Blocked INFECTED'
|
||||
assert_output --partial '<virus@external.tld> -> <user1@localhost.localdomain>'
|
||||
}
|
||||
|
|
|
@ -25,16 +25,14 @@ function setup_file() {
|
|||
function teardown_file() { _default_teardown ; }
|
||||
|
||||
@test "ClamAV - Amavis integration should not be active" {
|
||||
_run_in_container grep -i 'Found secondary av scanner ClamAV-clamscan' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_service_log_should_not_contain_string 'mail' 'Found secondary av scanner ClamAV-clamscan'
|
||||
}
|
||||
|
||||
@test "SA - Amavis integration should not be active" {
|
||||
_run_in_container_bash "grep -i 'ANTI-SPAM-SA code' /var/log/mail/mail.log | grep 'NOT loaded'"
|
||||
assert_success
|
||||
_service_log_should_contain_string 'mail' 'ANTI-SPAM-SA code'
|
||||
assert_output --partial 'NOT loaded'
|
||||
}
|
||||
|
||||
@test "SA - should not have been called" {
|
||||
_run_in_container grep -i 'connect to /var/run/clamav/clamd.ctl failed' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_service_log_should_not_contain_string 'mail' 'connect to /var/run/clamav/clamd.ctl failed'
|
||||
}
|
||||
|
|
|
@ -272,10 +272,10 @@ function teardown_file() { _default_teardown ; }
|
|||
_nc_wrapper 'nc/rspamd_imap_move_to_junk.txt' '0.0.0.0 143'
|
||||
sleep 1 # wait for the transaction to finish
|
||||
|
||||
_run_in_container cat /var/log/mail/mail.log
|
||||
assert_success
|
||||
assert_output --partial 'imapsieve: Matched static mailbox rule [1]'
|
||||
refute_output --partial 'imapsieve: Matched static mailbox rule [2]'
|
||||
_service_log_should_contain_string 'mail' 'imapsieve: Matched static mailbox rule \[1\]'
|
||||
_service_log_should_not_contain_string 'mail' 'imapsieve: Matched static mailbox rule \[2\]'
|
||||
|
||||
_filter_service_log 'mail' '.'
|
||||
for LINE in "${LEARN_SPAM_LINES[@]}"; do
|
||||
assert_output --partial "${LINE}"
|
||||
done
|
||||
|
@ -286,9 +286,9 @@ function teardown_file() { _default_teardown ; }
|
|||
_nc_wrapper 'nc/rspamd_imap_move_to_inbox.txt' '0.0.0.0 143'
|
||||
sleep 1 # wait for the transaction to finish
|
||||
|
||||
_run_in_container cat /var/log/mail/mail.log
|
||||
assert_success
|
||||
assert_output --partial 'imapsieve: Matched static mailbox rule [2]'
|
||||
_service_log_should_contain_string 'mail' 'imapsieve: Matched static mailbox rule \[2\]'
|
||||
|
||||
_filter_service_log 'mail' '.'
|
||||
for LINE in "${LEARN_HAM_LINES[@]}"; do
|
||||
assert_output --partial "${LINE}"
|
||||
done
|
||||
|
|
|
@ -54,7 +54,7 @@ function teardown_file() {
|
|||
_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
|
||||
_filter_service_log 'mail' "${LOG_DSN}"
|
||||
_should_output_number_of_lines 3
|
||||
}
|
||||
|
||||
|
@ -70,15 +70,14 @@ function teardown_file() {
|
|||
#
|
||||
# Although external requests are discarded, anyone who has requested a DSN
|
||||
# will still receive it, but it will come from the sending mail server, not this one.
|
||||
_run_in_container grep "${LOG_DSN}" /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_service_log_should_not_contain_string 'mail' "${LOG_DSN}"
|
||||
|
||||
# These ports are excluded via master.cf.
|
||||
_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
|
||||
_service_log_should_contain_string 'mail' "${LOG_DSN}"
|
||||
_should_output_number_of_lines 2
|
||||
}
|
||||
|
||||
|
@ -92,6 +91,5 @@ function teardown_file() {
|
|||
|
||||
# DSN requests are rejected regardless of origin.
|
||||
# This is usually a bad idea, as you won't get them either.
|
||||
_run_in_container grep "${LOG_DSN}" /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_service_log_should_not_contain_string 'mail' "${LOG_DSN}"
|
||||
}
|
||||
|
|
|
@ -174,33 +174,28 @@ function _successful() {
|
|||
}
|
||||
|
||||
@test "delivers mail to existing alias" {
|
||||
_run_in_container grep 'to=<user1@localhost.localdomain>, orig_to=<alias1@localhost.localdomain>' /var/log/mail/mail.log
|
||||
assert_success
|
||||
_service_log_should_contain_string 'mail' 'to=<user1@localhost.localdomain>, orig_to=<alias1@localhost.localdomain>'
|
||||
assert_output --partial 'status=sent'
|
||||
_should_output_number_of_lines 1
|
||||
}
|
||||
|
||||
@test "delivers mail to existing alias with recipient delimiter" {
|
||||
_run_in_container grep 'to=<user1~test@localhost.localdomain>, orig_to=<alias1~test@localhost.localdomain>' /var/log/mail/mail.log
|
||||
assert_success
|
||||
_service_log_should_contain_string 'mail' 'to=<user1~test@localhost.localdomain>, orig_to=<alias1~test@localhost.localdomain>'
|
||||
assert_output --partial 'status=sent'
|
||||
_should_output_number_of_lines 1
|
||||
|
||||
_run_in_container grep 'to=<user1~test@localhost.localdomain>' /var/log/mail/mail.log
|
||||
assert_success
|
||||
_service_log_should_contain_string 'mail' 'to=<user1~test@localhost.localdomain>'
|
||||
refute_output --partial 'status=bounced'
|
||||
}
|
||||
|
||||
@test "delivers mail to existing catchall" {
|
||||
_run_in_container grep 'to=<user1@localhost.localdomain>, orig_to=<wildcard@localdomain2.com>' /var/log/mail/mail.log
|
||||
assert_success
|
||||
_service_log_should_contain_string 'mail' 'to=<user1@localhost.localdomain>, orig_to=<wildcard@localdomain2.com>'
|
||||
assert_output --partial 'status=sent'
|
||||
_should_output_number_of_lines 1
|
||||
}
|
||||
|
||||
@test "delivers mail to regexp alias" {
|
||||
_run_in_container grep 'to=<user1@localhost.localdomain>, orig_to=<test123@localhost.localdomain>' /var/log/mail/mail.log
|
||||
assert_success
|
||||
_service_log_should_contain_string 'mail' 'to=<user1@localhost.localdomain>, orig_to=<test123@localhost.localdomain>'
|
||||
assert_output --partial 'status=sent'
|
||||
_should_output_number_of_lines 1
|
||||
}
|
||||
|
@ -227,23 +222,20 @@ function _successful() {
|
|||
}
|
||||
|
||||
@test "rejects mail to unknown user" {
|
||||
_run_in_container grep '<nouser@localhost.localdomain>: Recipient address rejected: User unknown in virtual mailbox table' /var/log/mail/mail.log
|
||||
assert_success
|
||||
_service_log_should_contain_string 'mail' '<nouser@localhost.localdomain>: Recipient address rejected: User unknown in virtual mailbox table'
|
||||
_should_output_number_of_lines 1
|
||||
}
|
||||
|
||||
@test "redirects mail to external aliases" {
|
||||
_run_in_container_bash "grep 'Passed CLEAN {RelayedInbound}' /var/log/mail/mail.log | grep -- '-> <external1@otherdomain.tld>'"
|
||||
assert_success
|
||||
assert_output --partial '<user@external.tld> -> <external1@otherdomain.tld>'
|
||||
_service_log_should_contain_string 'mail' 'Passed CLEAN {RelayedInbound}'
|
||||
run bash -c "grep '<user@external.tld> -> <external1@otherdomain.tld>' <<< '${output}'"
|
||||
_should_output_number_of_lines 2
|
||||
# assert_output --partial 'external.tld=user@example.test> -> <external1@otherdomain.tld>'
|
||||
}
|
||||
|
||||
# TODO: Add a test covering case SPAMASSASSIN_SPAM_TO_INBOX=1 (default)
|
||||
@test "rejects spam" {
|
||||
_run_in_container grep 'Blocked SPAM {NoBounceInbound,Quarantined}' /var/log/mail/mail.log
|
||||
assert_success
|
||||
_service_log_should_contain_string 'mail' 'Blocked SPAM {NoBounceInbound,Quarantined}'
|
||||
assert_output --partial '<spam@external.tld> -> <user1@localhost.localdomain>'
|
||||
_should_output_number_of_lines 1
|
||||
|
||||
|
|
|
@ -33,11 +33,9 @@ function teardown_file() { _default_teardown ; }
|
|||
assert_success
|
||||
}
|
||||
|
||||
@test '/var/log/mail/mail.log is error-free' {
|
||||
_run_in_container grep 'non-null host address bits in' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_run_in_container grep ': error:' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
@test 'Mail log is error-free' {
|
||||
_service_log_should_not_contain_string 'mail' 'non-null host address bits in'
|
||||
_service_log_should_not_contain_string 'mail' ': error:'
|
||||
}
|
||||
|
||||
@test '(Manage Sieve) disabled per default' {
|
||||
|
|
|
@ -182,23 +182,15 @@ function teardown_file() { _default_teardown ; }
|
|||
assert_success
|
||||
}
|
||||
|
||||
@test "system: /var/log/mail/mail.log is error free" {
|
||||
_run_in_container grep 'non-null host address bits in' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_run_in_container grep 'mail system configuration error' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_run_in_container grep ': error:' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_run_in_container grep -i 'is not writable' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_run_in_container grep -i 'permission denied' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_run_in_container grep -i '(!)connect' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_run_in_container grep -i 'using backwards-compatible default setting' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_run_in_container grep -i 'connect to 127.0.0.1:10023: Connection refused' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
@test "system: Mail log is error free" {
|
||||
_service_log_should_not_contain_string 'mail' 'non-null host address bits in'
|
||||
_service_log_should_not_contain_string 'mail' 'mail system configuration error'
|
||||
_service_log_should_not_contain_string 'mail' ': error:'
|
||||
_service_log_should_not_contain_string 'mail' 'is not writable'
|
||||
_service_log_should_not_contain_string 'mail' 'permission denied'
|
||||
_service_log_should_not_contain_string 'mail' '\(!\)connect'
|
||||
_service_log_should_not_contain_string 'mail' 'using backwards-compatible default setting'
|
||||
_service_log_should_not_contain_string 'mail' 'connect to 127.0.0.1:10023: Connection refused'
|
||||
}
|
||||
|
||||
@test "system: /var/log/auth.log is error free" {
|
||||
|
@ -212,7 +204,8 @@ function teardown_file() { _default_teardown ; }
|
|||
}
|
||||
|
||||
@test "system: amavis decoders installed and available" {
|
||||
_run_in_container_bash "grep -E '.*(Internal decoder|Found decoder) for\s+\..*' /var/log/mail/mail.log*|grep -Eo '(mail|Z|gz|bz2|xz|lzma|lrz|lzo|lz4|rpm|cpio|tar|deb|rar|arj|arc|zoo|doc|cab|tnef|zip|kmz|7z|jar|swf|lha|iso|exe)' | sort | uniq"
|
||||
_service_log_should_contain_string 'mail' '.*(Internal decoder|Found decoder) for\s+\..*'
|
||||
run bash -c "grep -Eo '(mail|Z|gz|bz2|xz|lzma|lrz|lzo|lz4|rpm|cpio|tar|deb|rar|arj|arc|zoo|doc|cab|tnef|zip|kmz|7z|jar|swf|lha|iso|exe)' <<< '${output}' | sort | uniq"
|
||||
assert_success
|
||||
# Support for doc and zoo removed in buster
|
||||
cat <<'EOF' | assert_output
|
||||
|
|
|
@ -24,8 +24,7 @@ function teardown_file() { _default_teardown ; }
|
|||
_wait_for_empty_mail_queue_in_container
|
||||
|
||||
# Should be successfully sent (received) by Postfix:
|
||||
_run_in_container grep 'to=<user1@localhost.localdomain>' /var/log/mail/mail.log
|
||||
assert_success
|
||||
_service_log_should_contain_string 'mail' 'to=<user1@localhost.localdomain>'
|
||||
assert_output --partial 'status=sent'
|
||||
_should_output_number_of_lines 1
|
||||
|
||||
|
@ -41,35 +40,27 @@ function teardown_file() { _default_teardown ; }
|
|||
# This test case is shared with tests.bats, but provides context on errors + some minor edits
|
||||
# TODO: Could improve in future with keywords from https://github.com/docker-mailserver/docker-mailserver/pull/3550#issuecomment-1738509088
|
||||
# Potentially via a helper that allows an optional fixed number of errors to be present if they were intentional
|
||||
@test '/var/log/mail/mail.log is error free' {
|
||||
@test 'Mail log is error free' {
|
||||
# Postfix: https://serverfault.com/questions/934703/postfix-451-4-3-0-temporary-lookup-failure
|
||||
_run_in_container grep 'non-null host address bits in' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_service_log_should_not_contain_string 'mail' 'non-null host address bits in'
|
||||
|
||||
# Postfix delivery failure: https://github.com/docker-mailserver/docker-mailserver/issues/230
|
||||
_run_in_container grep 'mail system configuration error' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_service_log_should_not_contain_string 'mail' 'mail system configuration error'
|
||||
|
||||
# Unknown error source: https://github.com/docker-mailserver/docker-mailserver/pull/85
|
||||
_run_in_container grep -i ': error:' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_service_log_should_not_contain_string 'mail' ': error:'
|
||||
|
||||
# Unknown error source: https://github.com/docker-mailserver/docker-mailserver/pull/320
|
||||
_run_in_container grep -i 'not writable' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_run_in_container grep -i 'permission denied' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_service_log_should_not_contain_string 'mail' 'not writable'
|
||||
_service_log_should_not_contain_string 'mail' 'permission denied'
|
||||
|
||||
# Amavis: https://forum.howtoforge.com/threads/postfix-smtp-error-caused-by-clamav-cant-connect-to-a-unix-socket-var-run-clamav-clamd-ctl.81002/
|
||||
_run_in_container grep -i '(!)connect' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_service_log_should_not_contain_string 'mail' '\(!\)connect'
|
||||
|
||||
# Postfix: https://github.com/docker-mailserver/docker-mailserver/pull/2597
|
||||
_run_in_container grep -i 'using backwards-compatible default setting' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_service_log_should_not_contain_string 'mail' 'using backwards-compatible default setting'
|
||||
|
||||
# Postgrey: https://github.com/docker-mailserver/docker-mailserver/pull/612#discussion_r117635774
|
||||
_run_in_container grep -i 'connect to 127.0.0.1:10023: Connection refused' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
_service_log_should_not_contain_string 'mail' 'connect to 127.0.0.1:10023: Connection refused'
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue