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='[Spam] (undefined subject) '
|
2023-01-03 05:58:09 +00:00
|
|
|
|
|
|
|
CONTAINER1_NAME='dms-test_spam-undef-subject_1'
|
|
|
|
CONTAINER2_NAME='dms-test_spam-undef-subject_2'
|
|
|
|
CONTAINER_NAME=${CONTAINER2_NAME}
|
|
|
|
|
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
|
|
|
function teardown() { _default_teardown ; }
|
|
|
|
|
2023-01-09 07:54:04 +00:00
|
|
|
@test "'SA_SPAM_SUBJECT=undef' should update Amavis config" {
|
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
|
|
|
export CONTAINER_NAME=${CONTAINER1_NAME}
|
2023-01-03 05:58:09 +00:00
|
|
|
local CUSTOM_SETUP_ARGUMENTS=(
|
|
|
|
--env ENABLE_AMAVIS=1
|
|
|
|
--env ENABLE_SPAMASSASSIN=1
|
|
|
|
--env SA_SPAM_SUBJECT='undef'
|
|
|
|
)
|
2023-01-21 23:05:28 +00:00
|
|
|
_init_with_defaults
|
|
|
|
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
2023-01-03 05:58:09 +00:00
|
|
|
|
2023-01-21 23:05:28 +00:00
|
|
|
_run_in_container_bash "grep '\$sa_spam_subject_tag' /etc/amavis/conf.d/20-debian_defaults | grep '= undef'"
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
# TODO: Unclear why some of these ENV are relevant for the test?
|
2023-01-09 07:54:04 +00:00
|
|
|
@test "Docker env variables are set correctly (custom)" {
|
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
|
|
|
export CONTAINER_NAME=${CONTAINER2_NAME}
|
|
|
|
|
2023-01-03 05:58:09 +00:00
|
|
|
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
|
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
|
|
|
# NOTE: ulimit required for `ENABLE_SRS=1` until running a newer `postsrsd`
|
2023-01-03 05:58:09 +00:00
|
|
|
--ulimit "nofile=$(ulimit -Sn):$(ulimit -Hn)"
|
|
|
|
)
|
2023-01-21 23:05:28 +00:00
|
|
|
_init_with_defaults
|
|
|
|
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
2019-08-16 17:20:54 +00:00
|
|
|
|
2023-01-21 23:05:28 +00:00
|
|
|
_run_in_container_bash "grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= -5.0'"
|
2019-08-16 17:20:54 +00:00
|
|
|
assert_success
|
2022-05-30 00:53:30 +00:00
|
|
|
|
2023-01-21 23:05:28 +00:00
|
|
|
_run_in_container_bash "grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'"
|
2019-08-16 17:20:54 +00:00
|
|
|
assert_success
|
2022-05-30 00:53:30 +00:00
|
|
|
|
2023-01-21 23:05:28 +00:00
|
|
|
_run_in_container_bash "grep '\$sa_kill_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 3.0'"
|
2019-08-16 17:20:54 +00:00
|
|
|
assert_success
|
2022-05-30 00:53:30 +00:00
|
|
|
|
2023-01-21 23:05:28 +00:00
|
|
|
_run_in_container_bash "grep '\$sa_spam_subject_tag' /etc/amavis/conf.d/20-debian_defaults | grep '= .SPAM: .'"
|
2019-08-16 17:20:54 +00:00
|
|
|
assert_success
|
2020-10-19 11:13:42 +00:00
|
|
|
}
|