2023-01-03 05:58:09 +00:00
|
|
|
load "${REPOSITORY_ROOT}/test/helper/setup"
|
|
|
|
load "${REPOSITORY_ROOT}/test/helper/common"
|
|
|
|
|
2023-01-09 07:54:04 +00:00
|
|
|
BATS_TEST_NAME_PREFIX='[ClamAV + SA] (disabled) '
|
2023-01-03 05:58:09 +00:00
|
|
|
CONTAINER_NAME='dms-test_clamav-spamassasin_disabled'
|
|
|
|
|
|
|
|
function setup_file() {
|
2023-01-21 23:05:28 +00:00
|
|
|
_init_with_defaults
|
2023-01-03 05:58:09 +00:00
|
|
|
|
|
|
|
local CUSTOM_SETUP_ARGUMENTS=(
|
|
|
|
--env ENABLE_AMAVIS=1
|
|
|
|
--env ENABLE_CLAMAV=0
|
|
|
|
--env ENABLE_SPAMASSASSIN=0
|
|
|
|
--env AMAVIS_LOGLEVEL=2
|
|
|
|
)
|
2020-09-17 21:40:39 +00:00
|
|
|
|
2023-01-21 23:05:28 +00:00
|
|
|
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
|
|
|
_wait_for_smtp_port_in_container
|
2023-01-03 05:58:09 +00:00
|
|
|
|
2023-02-24 09:44:18 +00:00
|
|
|
_send_email 'email-templates/existing-user1'
|
2023-01-21 23:05:28 +00:00
|
|
|
_wait_for_empty_mail_queue_in_container
|
2020-09-17 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
2023-01-03 05:58:09 +00:00
|
|
|
function teardown_file() { _default_teardown ; }
|
|
|
|
|
2023-01-09 07:54:04 +00:00
|
|
|
@test "ClamAV - Amavis integration should not be active" {
|
2023-01-03 05:58:09 +00:00
|
|
|
_run_in_container grep -i 'Found secondary av scanner ClamAV-clamscan' /var/log/mail/mail.log
|
2020-09-17 21:40:39 +00:00
|
|
|
assert_failure
|
|
|
|
}
|
|
|
|
|
2023-01-09 07:54:04 +00:00
|
|
|
@test "SA - Amavis integration should not be active" {
|
2023-01-21 23:05:28 +00:00
|
|
|
_run_in_container_bash "grep -i 'ANTI-SPAM-SA code' /var/log/mail/mail.log | grep 'NOT loaded'"
|
refactor: Parallel Tests
- `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).
2023-01-03 06:11:36 +00:00
|
|
|
assert_success
|
2020-09-17 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
2023-01-09 07:54:04 +00:00
|
|
|
@test "SA - should not have been called" {
|
refactor: Parallel Tests
- `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).
2023-01-03 06:11:36 +00:00
|
|
|
_run_in_container grep -i 'connect to /var/run/clamav/clamd.ctl failed' /var/log/mail/mail.log
|
2020-09-17 21:40:39 +00:00
|
|
|
assert_failure
|
|
|
|
}
|