mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
75ee0c1145
- Introduced `CONTAINER_NAME` and `TEST_NAME_PREFIX` as new vars for better managing test consistency (DRY). - `CONTAINER_NAME` replaces any repeated container name with the variable. The value will differ slightly as the prior prefix (`mail_`) has been changed to `dms-test-`. - `TEST_NAME_PREFIX` provides a prefix value for each `@test` description string. --- chore: Add a reference template for tests
37 lines
1.2 KiB
Bash
37 lines
1.2 KiB
Bash
load "${REPOSITORY_ROOT}/test/helper/setup"
|
|
load "${REPOSITORY_ROOT}/test/helper/common"
|
|
|
|
TEST_NAME_PREFIX='spam (Amavis):'
|
|
CONTAINER_NAME='dms-test-spam_bounced'
|
|
|
|
function setup_file() {
|
|
init_with_defaults
|
|
|
|
local CUSTOM_SETUP_ARGUMENTS=(
|
|
--env ENABLE_AMAVIS=1
|
|
--env ENABLE_SPAMASSASSIN=1
|
|
--env PERMIT_DOCKER=container
|
|
--env SPAMASSASSIN_SPAM_TO_INBOX=0
|
|
)
|
|
|
|
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
|
wait_for_smtp_port_in_container_to_respond "${CONTAINER_NAME}"
|
|
}
|
|
|
|
function teardown_file() { _default_teardown ; }
|
|
|
|
# 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
|
|
@test "${TEST_NAME_PREFIX} spam message is bounced (rejected)" {
|
|
# send a spam message
|
|
_run_in_container /bin/sh -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 sh -c "docker logs ${CONTAINER_NAME} | grep 'Blocked SPAM {NoBounceInbound,Quarantined}'"
|
|
assert_success
|
|
}
|