mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
0bbec09529
- `disabled_clamav_spamassassin`: - Just shuffling the test order around, and removing the restart test at the end which doesn't make sense. - `postscreen`: - Now uses common helper for getting container IP - Does not appear to need the `NET_ADMIN` capability? - Reduced startup time for the 2nd container + additional context about it's relevance. - Test cases are largely the same, but refactored the `nc` alternative that properly waits it's turn. This only needs to run once. Added additional commentary and made into a generic method if needed in other tests. - `fail2ban`: - Use the common container IP helper method. - Postscreen isn't affecting this test, it's not required to do the much slower exchange with the mail server when sending a login failure. - IP being passed into ENV is no longer necessary. - `sleep 5` in the related test cases doesn't seem necessary, can better rely on polling with timeout. - `sleep 10` for `setup.sh` also doesn't appear to be necessary. - `postgrey`: - Reduced POSTGREY_DELAY to 3, which shaves a fair amount of wasted time while still verifying the delay works. - One of the checks in `main.cf` doesn't seem to need to know about the earlier spamhaus portion of the line to work, removed. - Better test case descriptions. - Improved log matching via standard method that better documents the expected triplet under test. - Removed a redundant whitelist file and test that didn't seem to have any relevance. Added a TODO with additional notes about a concern with these tests. - Reduced test time as 8 second timeouts from `-w 8` don't appear to be required, better to poll with grep instead. - Replaced `wc -l` commands with a new method to assert expected line count, better enabling assertions on the actual output. - `undef_spam_subject`: - Split to two separate test cases, and initialize each container in their case instead of `setup_file()`, allowing for using the default `teardown()` method (and slight benefit if running in parallel). - `permit_docker`: - Not a parallel test, but I realized that the repeat helper methods don't necessarily play well with `run` as the command (can cause false positive of what was successful).
62 lines
2.1 KiB
Bash
62 lines
2.1 KiB
Bash
load "${REPOSITORY_ROOT}/test/helper/setup"
|
|
load "${REPOSITORY_ROOT}/test/helper/common"
|
|
|
|
TEST_NAME_PREFIX='Undefined spam subject:'
|
|
|
|
CONTAINER1_NAME='dms-test_spam-undef-subject_1'
|
|
CONTAINER2_NAME='dms-test_spam-undef-subject_2'
|
|
CONTAINER_NAME=${CONTAINER2_NAME}
|
|
|
|
function teardown() { _default_teardown ; }
|
|
|
|
@test "${TEST_NAME_PREFIX} 'SA_SPAM_SUBJECT=undef' should update Amavis config" {
|
|
export CONTAINER_NAME=${CONTAINER1_NAME}
|
|
local CUSTOM_SETUP_ARGUMENTS=(
|
|
--env ENABLE_AMAVIS=1
|
|
--env ENABLE_SPAMASSASSIN=1
|
|
--env SA_SPAM_SUBJECT='undef'
|
|
)
|
|
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'"
|
|
assert_success
|
|
}
|
|
|
|
# TODO: Unclear why some of these ENV are relevant for the test?
|
|
@test "${TEST_NAME_PREFIX} Docker env variables are set correctly (custom)" {
|
|
export CONTAINER_NAME=${CONTAINER2_NAME}
|
|
|
|
local CUSTOM_SETUP_ARGUMENTS=(
|
|
--env ENABLE_CLAMAV=1
|
|
--env SPOOF_PROTECTION=1
|
|
--env ENABLE_SPAMASSASSIN=1
|
|
--env REPORT_RECIPIENT=user1@localhost.localdomain
|
|
--env REPORT_SENDER=report1@mail.my-domain.com
|
|
--env SA_TAG=-5.0
|
|
--env SA_TAG2=2.0
|
|
--env SA_KILL=3.0
|
|
--env SA_SPAM_SUBJECT="SPAM: "
|
|
--env VIRUSMAILS_DELETE_DELAY=7
|
|
--env ENABLE_SRS=1
|
|
--env ENABLE_MANAGESIEVE=1
|
|
--env PERMIT_DOCKER=host
|
|
# 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'
|
|
|
|
_run_in_container bash -c "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'"
|
|
assert_success
|
|
|
|
_run_in_container bash -c "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: .'"
|
|
assert_success
|
|
}
|