Tests: extract mail_privacy into own .bats file
This commit is contained in:
parent
533ac7ed29
commit
604a65024e
18
Makefile
18
Makefile
|
@ -48,23 +48,6 @@ run:
|
||||||
-e DMS_DEBUG=0 \
|
-e DMS_DEBUG=0 \
|
||||||
-h mail.my-domain.com -t $(NAME)
|
-h mail.my-domain.com -t $(NAME)
|
||||||
sleep 15
|
sleep 15
|
||||||
docker run --rm -d --name mail_privacy \
|
|
||||||
-v "`pwd`/test/config":/tmp/docker-mailserver \
|
|
||||||
-v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \
|
|
||||||
-e ENABLE_CLAMAV=1 \
|
|
||||||
-e ENABLE_SPAMASSASSIN=1 \
|
|
||||||
-e SA_TAG=-5.0 \
|
|
||||||
-e SA_TAG2=2.0 \
|
|
||||||
-e SA_KILL=3.0 \
|
|
||||||
-e SA_SPAM_SUBJECT="SPAM: " \
|
|
||||||
-e VIRUSMAILS_DELETE_DELAY=7 \
|
|
||||||
-e SASL_PASSWD="external-domain.com username:password" \
|
|
||||||
-e ENABLE_MANAGESIEVE=1 \
|
|
||||||
--cap-add=SYS_PTRACE \
|
|
||||||
-e PERMIT_DOCKER=host \
|
|
||||||
-e DMS_DEBUG=0 \
|
|
||||||
-h mail.my-domain.com -t $(NAME)
|
|
||||||
sleep 15
|
|
||||||
docker run --rm -d --name mail_smtponly_without_config \
|
docker run --rm -d --name mail_smtponly_without_config \
|
||||||
-e SMTP_ONLY=1 \
|
-e SMTP_ONLY=1 \
|
||||||
-e ENABLE_LDAP=1 \
|
-e ENABLE_LDAP=1 \
|
||||||
|
@ -143,7 +126,6 @@ fixtures:
|
||||||
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_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"
|
docker exec mail /bin/sh -c "sendmail root < /tmp/docker-mailserver-test/email-templates/root-email.txt"
|
||||||
# postfix virtual transport lmtp
|
# postfix virtual transport lmtp
|
||||||
docker exec mail_privacy /bin/sh -c "openssl s_client -quiet -starttls smtp -connect 0.0.0.0:587 < /tmp/docker-mailserver-test/email-templates/send-privacy-email.txt"
|
|
||||||
docker exec mail_override_hostname /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
docker exec mail_override_hostname /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||||
# Wait for mails to be analyzed
|
# Wait for mails to be analyzed
|
||||||
sleep 80
|
sleep 80
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
load 'test_helper/common'
|
||||||
|
|
||||||
|
function setup() {
|
||||||
|
run_setup_file_if_necessary
|
||||||
|
}
|
||||||
|
|
||||||
|
function teardown() {
|
||||||
|
run_teardown_file_if_necessary
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup_file() {
|
||||||
|
docker run -d --name mail_privacy \
|
||||||
|
-v "`pwd`/test/config":/tmp/docker-mailserver \
|
||||||
|
-v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||||
|
-e ENABLE_CLAMAV=1 \
|
||||||
|
-e ENABLE_SPAMASSASSIN=1 \
|
||||||
|
-e SA_TAG=-5.0 \
|
||||||
|
-e SA_TAG2=2.0 \
|
||||||
|
-e SA_KILL=3.0 \
|
||||||
|
-e SA_SPAM_SUBJECT="SPAM: " \
|
||||||
|
-e VIRUSMAILS_DELETE_DELAY=7 \
|
||||||
|
-e SASL_PASSWD="external-domain.com username:password" \
|
||||||
|
-e ENABLE_MANAGESIEVE=1 \
|
||||||
|
--cap-add=SYS_PTRACE \
|
||||||
|
-e PERMIT_DOCKER=host \
|
||||||
|
-e DMS_DEBUG=0 \
|
||||||
|
-h mail.my-domain.com -t ${NAME}
|
||||||
|
|
||||||
|
wait_for_amavis_port_in_container mail_privacy
|
||||||
|
}
|
||||||
|
|
||||||
|
function teardown_file() {
|
||||||
|
docker rm -f mail_privacy
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "first" {
|
||||||
|
skip 'this test must come first to reliably identify when to run setup_file'
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# LDAP
|
||||||
|
#
|
||||||
|
|
||||||
|
# postfix
|
||||||
|
|
||||||
|
@test "checking postfix: remove privacy details of the sender" {
|
||||||
|
docker exec mail_privacy /bin/sh -c "openssl s_client -quiet -starttls smtp -connect 0.0.0.0:587 < /tmp/docker-mailserver-test/email-templates/send-privacy-email.txt"
|
||||||
|
repeat_until_success_or_timeout 120 docker exec mail_privacy /bin/sh -c '[ $(ls /var/mail/localhost.localdomain/user1/new | wc -l) -eq 1 ]'
|
||||||
|
docker logs mail_privacy
|
||||||
|
run docker exec mail_privacy /bin/sh -c "ls /var/mail/localhost.localdomain/user1/new | wc -l"
|
||||||
|
assert_success
|
||||||
|
assert_output 1
|
||||||
|
run docker exec mail_privacy /bin/sh -c "grep -rE "^User-Agent:" /var/mail/localhost.localdomain/user1/new | wc -l"
|
||||||
|
assert_success
|
||||||
|
assert_output 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@test "last" {
|
||||||
|
skip 'this test is only there to reliably mark the end for the teardown_file'
|
||||||
|
}
|
|
@ -25,9 +25,20 @@ function repeat_until_success_or_timeout {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# @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"
|
||||||
|
}
|
||||||
|
|
||||||
# @param $1 name of the postfix container
|
# @param $1 name of the postfix container
|
||||||
function wait_for_smtp_port_in_container() {
|
function wait_for_smtp_port_in_container() {
|
||||||
repeat_until_success_or_timeout $TEST_TIMEOUT_IN_SECONDS docker exec $1 /bin/sh -c "nc -z 0.0.0.0 25"
|
wait_for_tcp_port_in_container 25 $1
|
||||||
|
}
|
||||||
|
|
||||||
|
# @param $1 name of the postfix container
|
||||||
|
function wait_for_amavis_port_in_container() {
|
||||||
|
wait_for_tcp_port_in_container 10024 $1
|
||||||
}
|
}
|
||||||
|
|
||||||
# @param $1 name of the postfix container
|
# @param $1 name of the postfix container
|
||||||
|
|
|
@ -1144,15 +1144,6 @@ function count_processed_changes() {
|
||||||
|
|
||||||
# postfix
|
# postfix
|
||||||
|
|
||||||
@test "checking postfix: remove privacy details of the sender" {
|
|
||||||
run docker exec mail_privacy /bin/sh -c "ls /var/mail/localhost.localdomain/user1/new | wc -l"
|
|
||||||
assert_success
|
|
||||||
assert_output 1
|
|
||||||
run docker exec mail_privacy /bin/sh -c "grep -rE "^User-Agent:" /var/mail/localhost.localdomain/user1/new | wc -l"
|
|
||||||
assert_success
|
|
||||||
assert_output 0
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "checking dovecot: postmaster address" {
|
@test "checking dovecot: postmaster address" {
|
||||||
run docker exec mail /bin/sh -c "grep 'postmaster_address = postmaster@my-domain.com' /etc/dovecot/conf.d/15-lda.conf"
|
run docker exec mail /bin/sh -c "grep 'postmaster_address = postmaster@my-domain.com' /etc/dovecot/conf.d/15-lda.conf"
|
||||||
assert_success
|
assert_success
|
||||||
|
|
Loading…
Reference in New Issue