mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-03 09:34:33 +02:00
tests(refactor): Improve consistency and documentation for test helpers (#3012)
This commit is contained in:
parent
fb82082cf1
commit
e3c4ef76c6
32 changed files with 936 additions and 656 deletions
|
@ -5,7 +5,7 @@ BATS_TEST_NAME_PREFIX='[Amavis] '
|
|||
CONTAINER_NAME='dms-test_amavis'
|
||||
|
||||
function setup_file() {
|
||||
init_with_defaults
|
||||
_init_with_defaults
|
||||
|
||||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env ENABLE_AMAVIS=1
|
||||
|
@ -13,14 +13,14 @@ function setup_file() {
|
|||
--env ENABLE_SPAMASSASSIN=1
|
||||
)
|
||||
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
}
|
||||
|
||||
function teardown_file() { _default_teardown ; }
|
||||
|
||||
@test "SpamAssassin integration should be active" {
|
||||
# give Amavis just a bit of time to print out its full debug log
|
||||
run repeat_in_container_until_success_or_timeout 5 "${CONTAINER_NAME}" grep 'ANTI-SPAM-SA' /var/log/mail/mail.log
|
||||
run _repeat_in_container_until_success_or_timeout 5 "${CONTAINER_NAME}" grep 'ANTI-SPAM-SA' /var/log/mail/mail.log
|
||||
assert_success
|
||||
assert_output --partial 'loaded'
|
||||
refute_output --partial 'NOT loaded'
|
||||
|
|
|
@ -5,7 +5,7 @@ BATS_TEST_NAME_PREFIX='[ClamAV] '
|
|||
CONTAINER_NAME='dms-test_clamav'
|
||||
|
||||
function setup_file() {
|
||||
init_with_defaults
|
||||
_init_with_defaults
|
||||
|
||||
# Comment for maintainers about `PERMIT_DOCKER=host`:
|
||||
# https://github.com/docker-mailserver/docker-mailserver/pull/2815/files#r991087509
|
||||
|
@ -18,24 +18,24 @@ function setup_file() {
|
|||
--env LOG_LEVEL=trace
|
||||
)
|
||||
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
|
||||
# wait for ClamAV to be fully setup or we will get errors on the log
|
||||
repeat_in_container_until_success_or_timeout 60 "${CONTAINER_NAME}" test -e /var/run/clamav/clamd.ctl
|
||||
_repeat_in_container_until_success_or_timeout 60 "${CONTAINER_NAME}" test -e /var/run/clamav/clamd.ctl
|
||||
|
||||
wait_for_service "${CONTAINER_NAME}" postfix
|
||||
wait_for_smtp_port_in_container "${CONTAINER_NAME}"
|
||||
_wait_for_service postfix
|
||||
_wait_for_smtp_port_in_container
|
||||
|
||||
_run_in_container bash -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-virus.txt"
|
||||
_run_in_container_bash "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-virus.txt"
|
||||
assert_success
|
||||
|
||||
wait_for_empty_mail_queue_in_container "${CONTAINER_NAME}"
|
||||
_wait_for_empty_mail_queue_in_container
|
||||
}
|
||||
|
||||
function teardown_file() { _default_teardown ; }
|
||||
|
||||
@test "log files exist at /var/log/mail directory" {
|
||||
_run_in_container bash -c "ls -1 /var/log/mail/ | grep -E 'clamav|freshclam|mail.log' | wc -l"
|
||||
_run_in_container_bash "ls -1 /var/log/mail/ | grep -E 'clamav|freshclam|mail.log' | wc -l"
|
||||
assert_success
|
||||
assert_output 3
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ function teardown_file() { _default_teardown ; }
|
|||
}
|
||||
|
||||
@test "freshclam cron is enabled" {
|
||||
_run_in_container bash -c "grep '/usr/bin/freshclam' -r /etc/cron.d"
|
||||
_run_in_container_bash "grep '/usr/bin/freshclam' -r /etc/cron.d"
|
||||
assert_success
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,6 @@ function teardown_file() { _default_teardown ; }
|
|||
}
|
||||
|
||||
@test "rejects virus" {
|
||||
_run_in_container bash -c "grep 'Blocked INFECTED' /var/log/mail/mail.log | grep '<virus@external.tld> -> <user1@localhost.localdomain>'"
|
||||
_run_in_container_bash "grep 'Blocked INFECTED' /var/log/mail/mail.log | grep '<virus@external.tld> -> <user1@localhost.localdomain>'"
|
||||
assert_success
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ BATS_TEST_NAME_PREFIX='[ClamAV + SA] (disabled) '
|
|||
CONTAINER_NAME='dms-test_clamav-spamassasin_disabled'
|
||||
|
||||
function setup_file() {
|
||||
init_with_defaults
|
||||
_init_with_defaults
|
||||
|
||||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env ENABLE_AMAVIS=1
|
||||
|
@ -14,12 +14,12 @@ function setup_file() {
|
|||
--env AMAVIS_LOGLEVEL=2
|
||||
)
|
||||
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
wait_for_smtp_port_in_container "${CONTAINER_NAME}"
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_wait_for_smtp_port_in_container
|
||||
|
||||
_run_in_container bash -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||
_run_in_container_bash "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||
assert_success
|
||||
wait_for_empty_mail_queue_in_container "${CONTAINER_NAME}"
|
||||
_wait_for_empty_mail_queue_in_container
|
||||
}
|
||||
|
||||
function teardown_file() { _default_teardown ; }
|
||||
|
@ -30,7 +30,7 @@ function teardown_file() { _default_teardown ; }
|
|||
}
|
||||
|
||||
@test "SA - Amavis integration should not be active" {
|
||||
_run_in_container bash -c "grep -i 'ANTI-SPAM-SA code' /var/log/mail/mail.log | grep 'NOT loaded'"
|
||||
_run_in_container_bash "grep -i 'ANTI-SPAM-SA code' /var/log/mail/mail.log | grep 'NOT loaded'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
|
|
|
@ -10,17 +10,17 @@ function setup_file() {
|
|||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env ENABLE_DNSBL=1
|
||||
)
|
||||
init_with_defaults
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
wait_for_smtp_port_in_container "${CONTAINER_NAME}"
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_wait_for_smtp_port_in_container
|
||||
|
||||
local CONTAINER_NAME=${CONTAINER2_NAME}
|
||||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env ENABLE_DNSBL=0
|
||||
)
|
||||
init_with_defaults
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
wait_for_smtp_port_in_container "${CONTAINER_NAME}"
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_wait_for_smtp_port_in_container
|
||||
}
|
||||
|
||||
function teardown_file() {
|
||||
|
@ -29,32 +29,32 @@ function teardown_file() {
|
|||
|
||||
# ENABLE_DNSBL=1
|
||||
@test "(enabled) Postfix DNS block list zen.spamhaus.org" {
|
||||
run docker exec "${CONTAINER1_NAME}" postconf smtpd_recipient_restrictions
|
||||
_run_in_container_explicit "${CONTAINER1_NAME}" postconf smtpd_recipient_restrictions
|
||||
assert_output --partial 'reject_rbl_client zen.spamhaus.org'
|
||||
}
|
||||
|
||||
@test "(enabled) Postscreen DNS block lists -> postscreen_dnsbl_action" {
|
||||
run docker exec "${CONTAINER1_NAME}" postconf postscreen_dnsbl_action
|
||||
_run_in_container_explicit "${CONTAINER1_NAME}" postconf postscreen_dnsbl_action
|
||||
assert_output 'postscreen_dnsbl_action = enforce'
|
||||
}
|
||||
|
||||
@test "(enabled) Postscreen DNS block lists -> postscreen_dnsbl_sites" {
|
||||
run docker exec "${CONTAINER1_NAME}" postconf postscreen_dnsbl_sites
|
||||
_run_in_container_explicit "${CONTAINER1_NAME}" postconf postscreen_dnsbl_sites
|
||||
assert_output 'postscreen_dnsbl_sites = zen.spamhaus.org=127.0.0.[2..11]*3 bl.mailspike.net=127.0.0.[2;14;13;12;11;10] b.barracudacentral.org*2 bl.spameatingmonkey.net=127.0.0.2 dnsbl.sorbs.net psbl.surriel.com list.dnswl.org=127.0.[0..255].0*-2 list.dnswl.org=127.0.[0..255].1*-3 list.dnswl.org=127.0.[0..255].[2..3]*-4'
|
||||
}
|
||||
|
||||
# ENABLE_DNSBL=0
|
||||
@test "(disabled) Postfix DNS block list zen.spamhaus.org" {
|
||||
run docker exec "${CONTAINER2_NAME}" postconf smtpd_recipient_restrictions
|
||||
_run_in_container_explicit "${CONTAINER2_NAME}" postconf smtpd_recipient_restrictions
|
||||
refute_output --partial 'reject_rbl_client zen.spamhaus.org'
|
||||
}
|
||||
|
||||
@test "(disabled) Postscreen DNS block lists -> postscreen_dnsbl_action" {
|
||||
run docker exec "${CONTAINER2_NAME}" postconf postscreen_dnsbl_action
|
||||
_run_in_container_explicit "${CONTAINER2_NAME}" postconf postscreen_dnsbl_action
|
||||
assert_output 'postscreen_dnsbl_action = ignore'
|
||||
}
|
||||
|
||||
@test "(disabled) Postscreen DNS block lists -> postscreen_dnsbl_sites" {
|
||||
run docker exec "${CONTAINER2_NAME}" postconf postscreen_dnsbl_sites
|
||||
_run_in_container_explicit "${CONTAINER2_NAME}" postconf postscreen_dnsbl_sites
|
||||
assert_output 'postscreen_dnsbl_sites ='
|
||||
}
|
||||
|
|
|
@ -16,14 +16,14 @@ function setup_file() {
|
|||
# NOTE: May no longer be needed with newer F2B:
|
||||
--ulimit "nofile=$(ulimit -Sn):$(ulimit -Hn)"
|
||||
)
|
||||
init_with_defaults
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
wait_for_smtp_port_in_container "${CONTAINER_NAME}"
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_wait_for_smtp_port_in_container
|
||||
|
||||
# Create a container which will send wrong authentications and should get banned
|
||||
CONTAINER_NAME=${CONTAINER2_NAME}
|
||||
init_with_defaults
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
|
||||
# Set default implicit container fallback for helpers:
|
||||
CONTAINER_NAME=${CONTAINER1_NAME}
|
||||
|
@ -72,26 +72,26 @@ function teardown_file() {
|
|||
# - You could hard-code `sleep 5` on both cases to avoid the alternative assertions,
|
||||
# but the polling + piping into grep approach here reliably minimizes the delay.
|
||||
@test "ban ip on multiple failed login" {
|
||||
CONTAINER1_IP=$(get_container_ip ${CONTAINER1_NAME})
|
||||
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} 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login-wrong.txt"
|
||||
_run_in_container_explicit "${CONTAINER2_NAME}" bash -c "nc ${CONTAINER1_IP} 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login-wrong.txt"
|
||||
|
||||
# Checking that CONTAINER2_IP is banned in "${CONTAINER1_NAME}"
|
||||
CONTAINER2_IP=$(get_container_ip ${CONTAINER2_NAME})
|
||||
run repeat_in_container_until_success_or_timeout 10 "${CONTAINER_NAME}" bash -c "fail2ban-client status postfix-sasl | grep -F '${CONTAINER2_IP}'"
|
||||
CONTAINER2_IP=$(_get_container_ip "${CONTAINER2_NAME}")
|
||||
run _repeat_in_container_until_success_or_timeout 10 "${CONTAINER_NAME}" /bin/bash -c "fail2ban-client status postfix-sasl | grep -F '${CONTAINER2_IP}'"
|
||||
assert_success
|
||||
assert_output --partial 'Banned IP list:'
|
||||
|
||||
# Checking that CONTAINER2_IP is banned by nftables
|
||||
_run_in_container bash -c 'nft list set inet f2b-table addr-set-postfix-sasl'
|
||||
_run_in_container_bash 'nft list set inet f2b-table addr-set-postfix-sasl'
|
||||
assert_success
|
||||
assert_output --partial "elements = { ${CONTAINER2_IP} }"
|
||||
}
|
||||
|
||||
# NOTE: Depends on previous test case, if no IP was banned at this point, it passes regardless..
|
||||
@test "unban ip works" {
|
||||
CONTAINER2_IP=$(get_container_ip ${CONTAINER2_NAME})
|
||||
CONTAINER2_IP=$(_get_container_ip "${CONTAINER2_NAME}")
|
||||
_run_in_container fail2ban-client set postfix-sasl unbanip "${CONTAINER2_IP}"
|
||||
assert_success
|
||||
|
||||
|
@ -101,7 +101,7 @@ function teardown_file() {
|
|||
refute_output --partial "${CONTAINER2_IP}"
|
||||
|
||||
# Checking that CONTAINER2_IP is unbanned by nftables
|
||||
_run_in_container bash -c 'nft list set inet f2b-table addr-set-postfix-sasl'
|
||||
_run_in_container_bash 'nft list set inet f2b-table addr-set-postfix-sasl'
|
||||
refute_output --partial "${CONTAINER2_IP}"
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@ function setup_file() {
|
|||
--env POSTGREY_TEXT="Delayed by Postgrey"
|
||||
)
|
||||
|
||||
init_with_defaults
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
|
||||
# Postfix needs to be ready on port 25 for nc usage below:
|
||||
wait_for_smtp_port_in_container "${CONTAINER_NAME}"
|
||||
_wait_for_smtp_port_in_container
|
||||
}
|
||||
|
||||
function teardown_file() { _default_teardown ; }
|
||||
|
@ -60,7 +60,7 @@ function teardown_file() { _default_teardown ; }
|
|||
'reason=new' \
|
||||
'client_address=127.0.0.1/32, sender=user@external.tld, recipient=user1@localhost.localdomain'
|
||||
|
||||
repeat_until_success_or_timeout 10 _run_in_container grep \
|
||||
_repeat_until_success_or_timeout 10 _run_in_container grep \
|
||||
'Recipient address rejected: Delayed by Postgrey' \
|
||||
/var/log/mail/mail.log
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ function _send_test_mail() {
|
|||
# This is required for port 10023, otherwise the connection never drops.
|
||||
# It could increase the number of seconds to wait for port 25 to allow for asserting a response,
|
||||
# but that would enforce the delay in tests for port 10023.
|
||||
_run_in_container bash -c "nc -w 0 0.0.0.0 ${PORT} < ${MAIL_TEMPLATE}"
|
||||
_run_in_container_bash "nc -w 0 0.0.0.0 ${PORT} < ${MAIL_TEMPLATE}"
|
||||
}
|
||||
|
||||
function _should_have_log_entry() {
|
||||
|
@ -122,7 +122,7 @@ function _should_have_log_entry() {
|
|||
local TRIPLET=$3
|
||||
|
||||
# Allow some extra time for logs to update to avoids a false-positive failure:
|
||||
run_until_success_or_timeout 10 docker exec "${CONTAINER_NAME}" grep \
|
||||
_run_until_success_or_timeout 10 _exec_in_container grep \
|
||||
"${ACTION}, ${REASON}," \
|
||||
/var/log/mail/mail.log
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ CONTAINER1_NAME='dms-test_postscreen_enforce'
|
|||
CONTAINER2_NAME='dms-test_postscreen_sender'
|
||||
|
||||
function setup() {
|
||||
CONTAINER1_IP=$(get_container_ip ${CONTAINER1_NAME})
|
||||
CONTAINER1_IP=$(_get_container_ip ${CONTAINER1_NAME})
|
||||
}
|
||||
|
||||
function setup_file() {
|
||||
|
@ -16,16 +16,16 @@ function setup_file() {
|
|||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env POSTSCREEN_ACTION=enforce
|
||||
)
|
||||
init_with_defaults
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
wait_for_smtp_port_in_container "${CONTAINER_NAME}"
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_wait_for_smtp_port_in_container
|
||||
|
||||
# A standard DMS instance to send mail from:
|
||||
# NOTE: None of DMS is actually used for this (just bash + nc).
|
||||
CONTAINER_NAME=${CONTAINER2_NAME}
|
||||
init_with_defaults
|
||||
_init_with_defaults
|
||||
# No need to wait for DMS to be ready for this container:
|
||||
common_container_create
|
||||
_common_container_create
|
||||
run docker start "${CONTAINER_NAME}"
|
||||
assert_success
|
||||
|
||||
|
@ -50,7 +50,7 @@ function teardown_file() {
|
|||
@test "should successfully login (respecting postscreen_greet_wait time)" {
|
||||
# NOTE: Sometimes fails on first attempt (trying too soon?),
|
||||
# Instead of a `run` + asserting partial, Using repeat + internal grep match:
|
||||
repeat_until_success_or_timeout 10 _should_wait_turn_speaking_smtp \
|
||||
_repeat_until_success_or_timeout 10 _should_wait_turn_speaking_smtp \
|
||||
"${CONTAINER2_NAME}" \
|
||||
"${CONTAINER1_IP}" \
|
||||
'/tmp/docker-mailserver-test/auth/smtp-auth-login.txt' \
|
||||
|
|
|
@ -5,7 +5,7 @@ BATS_TEST_NAME_PREFIX='[Spam] (bounced) '
|
|||
CONTAINER_NAME='dms-test_spam-bounced'
|
||||
|
||||
function setup_file() {
|
||||
init_with_defaults
|
||||
_init_with_defaults
|
||||
|
||||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env ENABLE_AMAVIS=1
|
||||
|
@ -14,8 +14,8 @@ function setup_file() {
|
|||
--env SPAMASSASSIN_SPAM_TO_INBOX=0
|
||||
)
|
||||
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
wait_for_smtp_port_in_container_to_respond "${CONTAINER_NAME}"
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_wait_for_smtp_port_in_container_to_respond
|
||||
}
|
||||
|
||||
function teardown_file() { _default_teardown ; }
|
||||
|
@ -31,6 +31,6 @@ function teardown_file() { _default_teardown ; }
|
|||
assert_success
|
||||
|
||||
# message will be added to a queue with varying delay until amavis receives it
|
||||
run repeat_until_success_or_timeout 60 sh -c "docker logs ${CONTAINER_NAME} | grep 'Blocked SPAM {NoBounceInbound,Quarantined}'"
|
||||
run _repeat_until_success_or_timeout 60 sh -c "docker logs ${CONTAINER_NAME} | grep 'Blocked SPAM {NoBounceInbound,Quarantined}'"
|
||||
assert_success
|
||||
}
|
||||
|
|
|
@ -22,20 +22,20 @@ function teardown() { _default_teardown ; }
|
|||
--env SA_SPAM_SUBJECT="SPAM: "
|
||||
--env SPAMASSASSIN_SPAM_TO_INBOX=1
|
||||
)
|
||||
init_with_defaults
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
wait_for_smtp_port_in_container "${CONTAINER_NAME}"
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_wait_for_smtp_port_in_container
|
||||
|
||||
# send a spam message
|
||||
_run_in_container bash -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-spam.txt"
|
||||
_run_in_container_bash "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-spam.txt"
|
||||
assert_success
|
||||
|
||||
# message will be added to a queue with varying delay until amavis receives it
|
||||
run repeat_until_success_or_timeout 60 bash -c "docker logs ${CONTAINER_NAME} | grep 'Passed SPAM {RelayedTaggedInbound,Quarantined}'"
|
||||
run _repeat_until_success_or_timeout 60 bash -c "docker logs ${CONTAINER_NAME} | grep 'Passed SPAM {RelayedTaggedInbound,Quarantined}'"
|
||||
assert_success
|
||||
|
||||
# spam moved to Junk folder
|
||||
run repeat_until_success_or_timeout 20 bash -c "docker exec ${CONTAINER_NAME} sh -c 'grep \"Subject: SPAM: \" /var/mail/localhost.localdomain/user1/.Junk/new/ -R'"
|
||||
run _repeat_until_success_or_timeout 20 bash -c "docker exec ${CONTAINER_NAME} sh -c 'grep \"Subject: SPAM: \" /var/mail/localhost.localdomain/user1/.Junk/new/ -R'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
|
@ -49,19 +49,19 @@ function teardown() { _default_teardown ; }
|
|||
--env SA_SPAM_SUBJECT="SPAM: "
|
||||
--env SPAMASSASSIN_SPAM_TO_INBOX=1
|
||||
)
|
||||
init_with_defaults
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
wait_for_smtp_port_in_container "${CONTAINER_NAME}"
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_wait_for_smtp_port_in_container
|
||||
|
||||
# send a spam message
|
||||
_run_in_container /bin/bash -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-spam.txt"
|
||||
assert_success
|
||||
|
||||
# message will be added to a queue with varying delay until amavis receives it
|
||||
run repeat_until_success_or_timeout 60 bash -c "docker logs ${CONTAINER_NAME} | grep 'Passed SPAM {RelayedTaggedInbound,Quarantined}'"
|
||||
run _repeat_until_success_or_timeout 60 bash -c "docker logs ${CONTAINER_NAME} | grep 'Passed SPAM {RelayedTaggedInbound,Quarantined}'"
|
||||
assert_success
|
||||
|
||||
# spam moved to INBOX
|
||||
run repeat_until_success_or_timeout 20 bash -c "docker exec ${CONTAINER_NAME} sh -c 'grep \"Subject: SPAM: \" /var/mail/localhost.localdomain/user1/new/ -R'"
|
||||
run _repeat_until_success_or_timeout 20 bash -c "docker exec ${CONTAINER_NAME} sh -c 'grep \"Subject: SPAM: \" /var/mail/localhost.localdomain/user1/new/ -R'"
|
||||
assert_success
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ function teardown() { _default_teardown ; }
|
|||
--env ENABLE_SPAMASSASSIN=1
|
||||
--env SA_SPAM_SUBJECT='undef'
|
||||
)
|
||||
init_with_defaults
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
|
||||
_run_in_container bash -c "grep '\$sa_spam_subject_tag' /etc/amavis/conf.d/20-debian_defaults | grep '= undef'"
|
||||
_run_in_container_bash "grep '\$sa_spam_subject_tag' /etc/amavis/conf.d/20-debian_defaults | grep '= undef'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
|
@ -44,18 +44,18 @@ function teardown() { _default_teardown ; }
|
|||
# NOTE: ulimit required for `ENABLE_SRS=1` until running a newer `postsrsd`
|
||||
--ulimit "nofile=$(ulimit -Sn):$(ulimit -Hn)"
|
||||
)
|
||||
init_with_defaults
|
||||
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
|
||||
_run_in_container bash -c "grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= -5.0'"
|
||||
_run_in_container_bash "grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= -5.0'"
|
||||
assert_success
|
||||
|
||||
_run_in_container bash -c "grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'"
|
||||
_run_in_container_bash "grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'"
|
||||
assert_success
|
||||
|
||||
_run_in_container bash -c "grep '\$sa_kill_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 3.0'"
|
||||
_run_in_container_bash "grep '\$sa_kill_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 3.0'"
|
||||
assert_success
|
||||
|
||||
_run_in_container bash -c "grep '\$sa_spam_subject_tag' /etc/amavis/conf.d/20-debian_defaults | grep '= .SPAM: .'"
|
||||
_run_in_container_bash "grep '\$sa_spam_subject_tag' /etc/amavis/conf.d/20-debian_defaults | grep '= .SPAM: .'"
|
||||
assert_success
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue