2022-11-25 22:37:58 +00:00
|
|
|
load "${REPOSITORY_ROOT}/test/helper/setup"
|
|
|
|
load "${REPOSITORY_ROOT}/test/helper/common"
|
2021-11-04 20:35:01 +00:00
|
|
|
|
2023-01-09 07:54:04 +00:00
|
|
|
BATS_TEST_NAME_PREFIX='[Spam] (bounced) '
|
2023-01-03 05:58:09 +00:00
|
|
|
CONTAINER_NAME='dms-test_spam-bounced'
|
2020-05-02 16:39:51 +00:00
|
|
|
|
|
|
|
function setup_file() {
|
2023-01-21 23:05:28 +00:00
|
|
|
_init_with_defaults
|
2020-05-02 16:39:51 +00:00
|
|
|
|
2022-11-25 21:59:14 +00:00
|
|
|
local CUSTOM_SETUP_ARGUMENTS=(
|
|
|
|
--env ENABLE_AMAVIS=1
|
2021-11-04 20:35:01 +00:00
|
|
|
--env ENABLE_SPAMASSASSIN=1
|
2022-03-02 15:03:40 +00:00
|
|
|
--env PERMIT_DOCKER=container
|
2022-02-17 08:31:45 +00:00
|
|
|
--env SPAMASSASSIN_SPAM_TO_INBOX=0
|
2021-11-04 20:35:01 +00:00
|
|
|
)
|
|
|
|
|
2023-01-21 23:05:28 +00:00
|
|
|
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
|
|
|
_wait_for_smtp_port_in_container_to_respond
|
2020-05-02 16:39:51 +00:00
|
|
|
}
|
|
|
|
|
2022-11-25 21:59:14 +00:00
|
|
|
function teardown_file() { _default_teardown ; }
|
2021-09-20 07:35:03 +00:00
|
|
|
|
2022-11-25 21:59:14 +00:00
|
|
|
# Test case
|
|
|
|
# ---------
|
|
|
|
# When SPAMASSASSIN_SPAM_TO_INBOX=0, spam messages must be bounced (rejected).
|
|
|
|
# SPAMASSASSIN_SPAM_TO_INBOX=1 is covered in `mail_spam_junk_folder.bats`.
|
|
|
|
# Original test PR: https://github.com/docker-mailserver/docker-mailserver/pull/1485
|
2023-01-09 07:54:04 +00:00
|
|
|
@test "spam message is bounced (rejected)" {
|
2021-09-20 07:35:03 +00:00
|
|
|
# send a spam message
|
2022-11-25 21:59:14 +00:00
|
|
|
_run_in_container /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-spam.txt"
|
2021-09-20 07:35:03 +00:00
|
|
|
assert_success
|
|
|
|
|
2022-05-30 00:53:30 +00:00
|
|
|
# message will be added to a queue with varying delay until amavis receives it
|
2023-01-21 23:05:28 +00:00
|
|
|
run _repeat_until_success_or_timeout 60 sh -c "docker logs ${CONTAINER_NAME} | grep 'Blocked SPAM {NoBounceInbound,Quarantined}'"
|
2021-09-20 07:35:03 +00:00
|
|
|
assert_success
|
|
|
|
}
|