mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Extrract disabled clamav tests into own file
This commit is contained in:
parent
94c2a68bd5
commit
d38ff4c122
9
Makefile
9
Makefile
|
@ -92,14 +92,6 @@ run:
|
|||
-h unknown.domain.tld \
|
||||
-t $(NAME)
|
||||
-@ sleep $(SLEEP)
|
||||
docker run --rm -d --name mail_disabled_clamav_spamassassin \
|
||||
-v "`pwd`/test/config":/tmp/docker-mailserver \
|
||||
-v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-e ENABLE_CLAMAV=0 \
|
||||
-e ENABLE_SPAMASSASSIN=0 \
|
||||
-e DMS_DEBUG=0 \
|
||||
-h mail.my-domain.com -t $(NAME)
|
||||
-@ sleep $(SLEEP)
|
||||
|
||||
generate-accounts-after-run:
|
||||
@ docker run --rm -e MAIL_USER=added@localhost.localdomain -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' >> test/config/postfix-accounts.cf
|
||||
|
@ -127,7 +119,6 @@ fixtures:
|
|||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/sieve-spam-folder.txt"
|
||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/sieve-pipe.txt"
|
||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/non-existing-user.txt"
|
||||
docker exec mail_disabled_clamav_spamassassin /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||
docker exec mail /bin/sh -c "sendmail root < /tmp/docker-mailserver-test/email-templates/root-email.txt"
|
||||
# postfix virtual transport lmtp
|
||||
docker exec mail_override_hostname /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||
|
|
60
test/mail_disabled_clamav_spamassassin.bats
Normal file
60
test/mail_disabled_clamav_spamassassin.bats
Normal file
|
@ -0,0 +1,60 @@
|
|||
load 'test_helper/common'
|
||||
|
||||
setup() {
|
||||
run_setup_file_if_necessary
|
||||
}
|
||||
|
||||
teardown() {
|
||||
run_teardown_file_if_necessary
|
||||
}
|
||||
|
||||
setup_file() {
|
||||
docker run --rm -d --name mail_disabled_clamav_spamassassin \
|
||||
-v "`pwd`/test/config":/tmp/docker-mailserver \
|
||||
-v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-e ENABLE_CLAMAV=0 \
|
||||
-e ENABLE_SPAMASSASSIN=0 \
|
||||
-e DMS_DEBUG=0 \
|
||||
-h mail.my-domain.com -t ${NAME}
|
||||
# TODO: find a better way to know when we have waited long enough
|
||||
# for clamav to should have come up, if it were enabled
|
||||
wait_for_smtp_port_in_container mail_disabled_clamav_spamassassin
|
||||
docker exec mail_disabled_clamav_spamassassin /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
docker rm -f mail_disabled_clamav_spamassassin
|
||||
}
|
||||
|
||||
@test "first" {
|
||||
skip 'only used to call setup_file from setup'
|
||||
}
|
||||
|
||||
@test "checking process: clamav (clamav disabled by ENABLED_CLAMAV=0)" {
|
||||
run docker exec mail_disabled_clamav_spamassassin /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/clamd'"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "checking spamassassin: should not be listed in amavis when disabled" {
|
||||
run docker exec mail_disabled_clamav_spamassassin /bin/sh -c "grep -i 'ANTI-SPAM-SA code' /var/log/mail/mail.log | grep 'NOT loaded'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking clamav: should not be listed in amavis when disabled" {
|
||||
run docker exec mail_disabled_clamav_spamassassin grep -i 'Found secondary av scanner ClamAV-clamscan' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "checking clamav: should not be called when disabled" {
|
||||
run docker exec mail_disabled_clamav_spamassassin grep -i 'connect to /var/run/clamav/clamd.ctl failed' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "checking restart of process: clamav (clamav disabled by ENABLED_CLAMAV=0)" {
|
||||
run docker exec mail_disabled_clamav_spamassassin /bin/bash -c "pkill -f clamd && sleep 10 && ps aux --forest | grep -v grep | grep '/usr/sbin/clamd'"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "last" {
|
||||
skip 'only used to call teardown_file from teardown'
|
||||
}
|
|
@ -7,6 +7,9 @@ NAME=tvial/docker-mailserver:testing
|
|||
TEST_TIMEOUT_IN_SECONDS=${TEST_TIMEOUT_IN_SECONDS-120}
|
||||
NUMBER_OF_LOG_LINES=${NUMBER_OF_LOG_LINES-10}
|
||||
|
||||
# @param $1 timeout
|
||||
# @param --fatal-test <command eval string> additional test whose failure aborts immediately
|
||||
# @param ... test to run
|
||||
function repeat_until_success_or_timeout {
|
||||
if ! [[ "$1" =~ ^[0-9]+$ ]]; then
|
||||
echo "First parameter for timeout must be an integer, recieved \"$1\""
|
||||
|
@ -15,20 +18,33 @@ function repeat_until_success_or_timeout {
|
|||
TIMEOUT=$1
|
||||
STARTTIME=$SECONDS
|
||||
shift 1
|
||||
local fatal_failure_test_command
|
||||
if [[ "$1" == "--fatal-test" ]]; then
|
||||
fatal_failure_test_command="$2"
|
||||
shift 2
|
||||
fi
|
||||
until "$@"
|
||||
do
|
||||
if [[ -n "$fatal_failure_test_command" ]] && ! eval "$fatal_failure_test_command"; then
|
||||
echo "\`$fatal_failure_test_command\` failed, early aborting repeat_until_success of \`$*\`" >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 5
|
||||
if [[ $(($SECONDS - $STARTTIME )) -gt $TIMEOUT ]]; then
|
||||
echo "Timed out on command: $@"
|
||||
echo "Timed out on command: $@" >&2
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function container_is_running() {
|
||||
[[ "$(docker inspect -f '{{.State.Running}}' "$1")" == "true" ]]
|
||||
}
|
||||
|
||||
# @param $1 port
|
||||
# @param $2 container name
|
||||
function wait_for_tcp_port_in_container() {
|
||||
repeat_until_success_or_timeout $TEST_TIMEOUT_IN_SECONDS docker exec $2 /bin/sh -c "nc -z 0.0.0.0 $1"
|
||||
repeat_until_success_or_timeout $TEST_TIMEOUT_IN_SECONDS --fatal-test "container_is_running $2" docker exec $2 /bin/sh -c "nc -z 0.0.0.0 $1"
|
||||
}
|
||||
|
||||
# @param $1 name of the postfix container
|
||||
|
|
|
@ -114,11 +114,6 @@ function count_processed_changes() {
|
|||
assert_failure
|
||||
}
|
||||
|
||||
@test "checking process: clamav (clamav disabled by ENABLED_CLAMAV=0)" {
|
||||
run docker exec mail_disabled_clamav_spamassassin /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/clamd'"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
#
|
||||
# imap
|
||||
#
|
||||
|
@ -384,11 +379,6 @@ EOF
|
|||
assert_failure
|
||||
}
|
||||
|
||||
@test "checking spamassassin: should not be listed in amavis when disabled" {
|
||||
run docker exec mail_disabled_clamav_spamassassin /bin/sh -c "grep -i 'ANTI-SPAM-SA code' /var/log/mail/mail.log | grep 'NOT loaded'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking spamassassin: all registered domains should see spam headers" {
|
||||
run docker exec mail /bin/sh -c "grep -ir 'X-Spam-' /var/mail/localhost.localdomain/user1/new"
|
||||
assert_success
|
||||
|
@ -406,16 +396,6 @@ EOF
|
|||
assert_success
|
||||
}
|
||||
|
||||
@test "checking clamav: should not be listed in amavis when disabled" {
|
||||
run docker exec mail_disabled_clamav_spamassassin grep -i 'Found secondary av scanner ClamAV-clamscan' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "checking clamav: should not be called when disabled" {
|
||||
run docker exec mail_disabled_clamav_spamassassin grep -i 'connect to /var/run/clamav/clamd.ctl failed' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
}
|
||||
|
||||
#
|
||||
# opendkim
|
||||
#
|
||||
|
@ -1604,11 +1584,6 @@ EOF
|
|||
assert_success
|
||||
}
|
||||
|
||||
@test "checking restart of process: clamav (clamav disabled by ENABLED_CLAMAV=0)" {
|
||||
run docker exec mail_disabled_clamav_spamassassin /bin/bash -c "pkill -f clamd && sleep 10 && ps aux --forest | grep -v grep | grep '/usr/sbin/clamd'"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
#
|
||||
# root mail delivery
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue