1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-18 14:47:03 +00:00

test: Test permanent hook failure

This patch adds a test to make sure we handle correctly the case where a
hook exits with a permanent failure.
This commit is contained in:
Alberto Bertogli
2019-12-01 20:31:59 +00:00
parent a12875162f
commit 45a294403d
3 changed files with 22 additions and 1 deletions

View File

@@ -10,5 +10,10 @@ if [ "$RCPT_TO" == "blockme@testserver" ]; then
exit 1
fi
if [ "$RCPT_TO" == "permanent@testserver" ]; then
echo "Nos hacemos la permanente"
exit 20 # permanent
fi
echo "X-Post-Data: success"

View File

@@ -12,3 +12,4 @@ auth on
user user@testserver
password secretpassword
logfile .logs/msmtp

View File

@@ -9,6 +9,7 @@ generate_certs_for testserver
add_user user@testserver secretpassword
add_user someone@testserver secretpassword
add_user blockme@testserver secretpassword
add_user permanent@testserver secretpassword
mkdir -p .logs
chasquid -v=2 --logfile=.logs/chasquid.log --config_dir=config &
@@ -45,10 +46,24 @@ check "REMOTE_ADDR="
check "SPF_PASS=0"
# Check that a failure in the script results in failing delivery.
# Check that failures in the script result in failing delivery.
# Transient failure.
if run_msmtp blockme@testserver < content 2>/dev/null; then
fail "ERROR: hook did not block email as expected"
fi
if ! tail -n 1 .logs/msmtp | grep -q "smtpstatus=451"; then
tail -n 1 .logs/msmtp
fail "ERROR: transient hook error not returned correctly"
fi
# Permanent failure.
if run_msmtp permanent@testserver < content 2>/dev/null; then
fail "ERROR: hook did not block email as expected"
fi
if ! tail -n 1 .logs/msmtp | grep -q "smtpstatus=554"; then
tail -n 1 .logs/msmtp
fail "ERROR: permanent hook error not returned correctly"
fi
# Check that the bad hooks don't prevent delivery.
for i in config/hooks/post-data.bad*; do