Commit 45a29440 authored by Alberto Bertogli's avatar Alberto Bertogli

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.
parent a1287516
......@@ -10,5 +10,10 @@ if [ "$RCPT_TO" == "[email protected]" ]; then
exit 1
fi
if [ "$RCPT_TO" == "[email protected]" ]; then
echo "Nos hacemos la permanente"
exit 20 # permanent
fi
echo "X-Post-Data: success"
......@@ -12,3 +12,4 @@ auth on
user [email protected]
password secretpassword
logfile .logs/msmtp
......@@ -9,6 +9,7 @@ generate_certs_for testserver
add_user [email protected] secretpassword
add_user [email protected] secretpassword
add_user [email protected] secretpassword
add_user [email protected] 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 [email protected] < 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 [email protected] < 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment