You've already forked docker-mailserver
mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-09 23:07:35 +02:00
tests: Adjust parallel tests
- The usual serial to parallel test conversion to utilize the `setup.bash` common setup structure, and adding a `TEST_PREFIX` var for each test case to leverage. - Standardize on parallel test naming conventions for variables / values. - More consistent use of `bash -c` instead of `/bin/bash -c` or `/bin/sh -c`. - Using the `_run_in_container` helper instead of `run docker exec ${CONTAINER_NAME}`. - Updates tests to use the `check_if_process_is_running` helper. --- chore: Revise inline docs for the `ssl_letsencrypt` test - Moves the override to be in closer proximity to the `initial_setup` call, and better communicates the intent to override. - Removes top comment block that is no longer providing value or correct information to maintainers. - Revised `acme.json` test case inline doc comments.
This commit is contained in:
@ -1,67 +1,67 @@
|
||||
load "${REPOSITORY_ROOT}/test/test_helper/common"
|
||||
load "${REPOSITORY_ROOT}/test/helper/setup"
|
||||
load "${REPOSITORY_ROOT}/test/helper/common"
|
||||
|
||||
TEST_NAME_PREFIX='Spam junk folder:'
|
||||
CONTAINER1_NAME='dms-test_spam-junk-folder_1'
|
||||
CONTAINER2_NAME='dms-test_spam-junk-folder_2'
|
||||
|
||||
function teardown() { _default_teardown ; }
|
||||
|
||||
# Test case
|
||||
# ---------
|
||||
# When SPAMASSASSIN_SPAM_TO_INBOX=1, spam messages must be delivered and eventually (MOVE_SPAM_TO_JUNK=1) moved to the Junk folder.
|
||||
# When SPAMASSASSIN_SPAM_TO_INBOX=1, spam messages must be delivered
|
||||
# and eventually (MOVE_SPAM_TO_JUNK=1) moved to the Junk folder.
|
||||
|
||||
@test "checking amavis: spam message is delivered and moved to the Junk folder (MOVE_SPAM_TO_JUNK=1)" {
|
||||
local PRIVATE_CONFIG
|
||||
PRIVATE_CONFIG=$(duplicate_config_for_container . mail_spam_moved_junk)
|
||||
|
||||
docker run -d --name mail_spam_moved_junk \
|
||||
-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
|
||||
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-e ENABLE_SPAMASSASSIN=1 \
|
||||
-e MOVE_SPAM_TO_JUNK=1 \
|
||||
-e PERMIT_DOCKER=container \
|
||||
-e SA_SPAM_SUBJECT="SPAM: " \
|
||||
-e SPAMASSASSIN_SPAM_TO_INBOX=1 \
|
||||
-h mail.my-domain.com -t "${NAME}"
|
||||
|
||||
teardown() { docker rm -f mail_spam_moved_junk; }
|
||||
|
||||
wait_for_smtp_port_in_container mail_spam_moved_junk
|
||||
@test "${TEST_NAME_PREFIX} (Amavis) spam message delivered & moved to Junk folder" {
|
||||
export CONTAINER_NAME=${CONTAINER1_NAME}
|
||||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env ENABLE_AMAVIS=1
|
||||
--env ENABLE_SPAMASSASSIN=1
|
||||
--env MOVE_SPAM_TO_JUNK=1
|
||||
--env PERMIT_DOCKER=container
|
||||
--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}"
|
||||
|
||||
# send a spam message
|
||||
run docker exec mail_spam_moved_junk /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-spam.txt"
|
||||
_run_in_container 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 sh -c "docker logs mail_spam_moved_junk | 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 sh -c "docker exec mail_spam_moved_junk 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
|
||||
}
|
||||
|
||||
@test "checking amavis: spam message is delivered to INBOX (MOVE_SPAM_TO_JUNK=0)" {
|
||||
local PRIVATE_CONFIG
|
||||
PRIVATE_CONFIG=$(duplicate_config_for_container . mail_spam_moved_new)
|
||||
|
||||
docker run -d --name mail_spam_moved_new \
|
||||
-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
|
||||
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-e ENABLE_SPAMASSASSIN=1 \
|
||||
-e MOVE_SPAM_TO_JUNK=0 \
|
||||
-e PERMIT_DOCKER=container \
|
||||
-e SA_SPAM_SUBJECT="SPAM: " \
|
||||
-e SPAMASSASSIN_SPAM_TO_INBOX=1 \
|
||||
-h mail.my-domain.com -t "${NAME}"
|
||||
|
||||
teardown() { docker rm -f mail_spam_moved_new; }
|
||||
|
||||
wait_for_smtp_port_in_container mail_spam_moved_new
|
||||
@test "${TEST_NAME_PREFIX} (Amavis) spam message delivered to INBOX" {
|
||||
export CONTAINER_NAME=${CONTAINER2_NAME}
|
||||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env ENABLE_AMAVIS=1
|
||||
--env ENABLE_SPAMASSASSIN=1
|
||||
--env MOVE_SPAM_TO_JUNK=0
|
||||
--env PERMIT_DOCKER=container
|
||||
--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}"
|
||||
|
||||
# send a spam message
|
||||
run docker exec mail_spam_moved_new /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-spam.txt"
|
||||
_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 sh -c "docker logs mail_spam_moved_new | 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 sh -c "docker exec mail_spam_moved_new 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
|
||||
}
|
||||
|
Reference in New Issue
Block a user