mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Extract mail_postscreen into own test file
This commit is contained in:
parent
3b728848bb
commit
9019b98394
8
Makefile
8
Makefile
|
@ -198,13 +198,6 @@ run:
|
|||
-e DMS_DEBUG=0 \
|
||||
-h mail.my-domain.com -t $(NAME)
|
||||
sleep 15
|
||||
docker run -d --name mail_postscreen \
|
||||
-v "`pwd`/test/config":/tmp/docker-mailserver \
|
||||
-v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-e POSTSCREEN_ACTION=enforce \
|
||||
--cap-add=NET_ADMIN \
|
||||
-h mail.my-domain.com -t $(NAME)
|
||||
sleep 15
|
||||
|
||||
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
|
||||
|
@ -272,7 +265,6 @@ clean:
|
|||
ldap_for_mail \
|
||||
mail_with_ldap \
|
||||
mail_with_imap \
|
||||
mail_postscreen \
|
||||
mail_override_hostname \
|
||||
mail_domainname \
|
||||
mail_srs_domainname
|
||||
|
|
62
test/mail_postscreen.bats
Normal file
62
test/mail_postscreen.bats
Normal file
|
@ -0,0 +1,62 @@
|
|||
load 'test_helper/common'
|
||||
|
||||
setup() {
|
||||
run_setup_file_if_necessary
|
||||
|
||||
# Getting mail container IP
|
||||
MAIL_POSTSCREEN_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' mail_postscreen)
|
||||
}
|
||||
|
||||
teardown() {
|
||||
run_teardown_file_if_necessary
|
||||
}
|
||||
|
||||
setup_file() {
|
||||
docker run -d --name mail_postscreen \
|
||||
-v "`pwd`/test/config":/tmp/docker-mailserver \
|
||||
-v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-e POSTSCREEN_ACTION=enforce \
|
||||
--cap-add=NET_ADMIN \
|
||||
-h mail.my-domain.com -t ${NAME}
|
||||
|
||||
docker run --name mail_postscreen_sender \
|
||||
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-d ${NAME} \
|
||||
tail -f /var/log/faillog
|
||||
|
||||
wait_for_smtp_port_in_container mail_postscreen
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
docker rm -f mail_postscreen mail_postscreen_sender
|
||||
}
|
||||
|
||||
@test "first" {
|
||||
skip 'only used to call setup_file from setup'
|
||||
}
|
||||
|
||||
@test "checking postscreen: talk too fast" {
|
||||
docker exec mail_postscreen_sender /bin/sh -c "nc $MAIL_POSTSCREEN_IP 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login.txt"
|
||||
|
||||
repeat_until_success_or_timeout 10 run docker exec mail_postscreen grep 'COMMAND PIPELINING' /var/log/mail/mail.log
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking postscreen: positive test (respecting postscreen_greet_wait time and talking in turn)" {
|
||||
for i in {1,2}; do
|
||||
docker exec mail_postscreen_sender /bin/bash -c \
|
||||
'exec 3<>/dev/tcp/'$MAIL_POSTSCREEN_IP'/25 && \
|
||||
while IFS= read -r cmd; do \
|
||||
head -1 <&3; \
|
||||
[[ "$cmd" == "EHLO"* ]] && sleep 6; \
|
||||
echo $cmd >&3; \
|
||||
done < "/tmp/docker-mailserver-test/auth/smtp-auth-login.txt"'
|
||||
done
|
||||
|
||||
repeat_until_success_or_timeout 10 run docker exec mail_postscreen grep 'PASS NEW ' /var/log/mail/mail.log
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "last" {
|
||||
skip 'only used to call teardown_file from teardown'
|
||||
}
|
|
@ -872,39 +872,6 @@ function count_processed_changes() {
|
|||
assert_failure
|
||||
}
|
||||
|
||||
#
|
||||
# postscreen
|
||||
#
|
||||
|
||||
@test "checking postscreen" {
|
||||
# Getting mail container IP
|
||||
MAIL_POSTSCREEN_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' mail_postscreen)
|
||||
|
||||
# talk too fast:
|
||||
|
||||
docker exec fail-auth-mailer /bin/sh -c "nc $MAIL_POSTSCREEN_IP 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login.txt"
|
||||
sleep 5
|
||||
|
||||
run docker exec mail_postscreen grep 'COMMAND PIPELINING' /var/log/mail/mail.log
|
||||
assert_success
|
||||
|
||||
# positive test. (respecting postscreen_greet_wait time and talking in turn):
|
||||
for i in {1,2}; do
|
||||
docker exec fail-auth-mailer /bin/bash -c \
|
||||
'exec 3<>/dev/tcp/'$MAIL_POSTSCREEN_IP'/25 && \
|
||||
while IFS= read -r cmd; do \
|
||||
head -1 <&3; \
|
||||
[[ "$cmd" == "EHLO"* ]] && sleep 6; \
|
||||
echo $cmd >&3; \
|
||||
done < "/tmp/docker-mailserver-test/auth/smtp-auth-login.txt"'
|
||||
done
|
||||
|
||||
sleep 5
|
||||
|
||||
run docker exec mail_postscreen grep 'PASS NEW ' /var/log/mail/mail.log
|
||||
assert_success
|
||||
}
|
||||
|
||||
#
|
||||
# fetchmail
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue