2019-08-16 20:42:55 +00:00
|
|
|
load 'test_helper/common'
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
# Getting mail container IP
|
|
|
|
MAIL_POSTSCREEN_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' mail_postscreen)
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_file() {
|
2020-10-20 07:33:47 +00:00
|
|
|
local PRIVATE_CONFIG
|
|
|
|
PRIVATE_CONFIG="$(duplicate_config_for_container .)"
|
2019-08-16 20:42:55 +00:00
|
|
|
docker run -d --name mail_postscreen \
|
2020-10-20 07:33:47 +00:00
|
|
|
-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
|
|
|
|
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
|
|
|
-e POSTSCREEN_ACTION=enforce \
|
|
|
|
--cap-add=NET_ADMIN \
|
2020-11-05 12:32:42 +00:00
|
|
|
-h mail.my-domain.com -t "${NAME}"
|
2019-08-16 20:42:55 +00:00
|
|
|
|
|
|
|
docker run --name mail_postscreen_sender \
|
|
|
|
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
2020-11-05 12:32:42 +00:00
|
|
|
-d "${NAME}" \
|
2019-08-16 20:42:55 +00:00
|
|
|
tail -f /var/log/faillog
|
|
|
|
|
|
|
|
wait_for_smtp_port_in_container mail_postscreen
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown_file() {
|
|
|
|
docker rm -f mail_postscreen mail_postscreen_sender
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "checking postscreen: talk too fast" {
|
2020-11-05 12:32:42 +00:00
|
|
|
docker exec mail_postscreen_sender /bin/sh -c "nc ${MAIL_POSTSCREEN_IP} 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login.txt"
|
2019-08-16 20:42:55 +00:00
|
|
|
|
|
|
|
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)" {
|
2020-11-05 12:32:42 +00:00
|
|
|
for _ in {1,2}; do
|
|
|
|
# shellcheck disable=SC1004
|
2019-08-16 20:42:55 +00:00
|
|
|
docker exec mail_postscreen_sender /bin/bash -c \
|
2020-11-05 12:32:42 +00:00
|
|
|
'exec 3<>/dev/tcp/'"${MAIL_POSTSCREEN_IP}"'/25 && \
|
2019-08-16 20:42:55 +00:00
|
|
|
while IFS= read -r cmd; do \
|
|
|
|
head -1 <&3; \
|
2021-12-21 16:01:40 +00:00
|
|
|
[[ ${cmd} == "EHLO"* ]] && sleep 6; \
|
2020-11-05 12:32:42 +00:00
|
|
|
echo ${cmd} >&3; \
|
2019-08-16 20:42:55 +00:00
|
|
|
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
|
|
|
|
}
|