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:
@@ -10,5 +10,10 @@ if [ "$RCPT_TO" == "blockme@testserver" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$RCPT_TO" == "permanent@testserver" ]; then
|
||||||
|
echo "Nos hacemos la permanente"
|
||||||
|
exit 20 # permanent
|
||||||
|
fi
|
||||||
|
|
||||||
echo "X-Post-Data: success"
|
echo "X-Post-Data: success"
|
||||||
|
|
||||||
|
|||||||
@@ -12,3 +12,4 @@ auth on
|
|||||||
user user@testserver
|
user user@testserver
|
||||||
password secretpassword
|
password secretpassword
|
||||||
|
|
||||||
|
logfile .logs/msmtp
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ generate_certs_for testserver
|
|||||||
add_user user@testserver secretpassword
|
add_user user@testserver secretpassword
|
||||||
add_user someone@testserver secretpassword
|
add_user someone@testserver secretpassword
|
||||||
add_user blockme@testserver secretpassword
|
add_user blockme@testserver secretpassword
|
||||||
|
add_user permanent@testserver secretpassword
|
||||||
|
|
||||||
mkdir -p .logs
|
mkdir -p .logs
|
||||||
chasquid -v=2 --logfile=.logs/chasquid.log --config_dir=config &
|
chasquid -v=2 --logfile=.logs/chasquid.log --config_dir=config &
|
||||||
@@ -45,10 +46,24 @@ check "REMOTE_ADDR="
|
|||||||
check "SPF_PASS=0"
|
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
|
if run_msmtp blockme@testserver < content 2>/dev/null; then
|
||||||
fail "ERROR: hook did not block email as expected"
|
fail "ERROR: hook did not block email as expected"
|
||||||
fi
|
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.
|
# Check that the bad hooks don't prevent delivery.
|
||||||
for i in config/hooks/post-data.bad*; do
|
for i in config/hooks/post-data.bad*; do
|
||||||
|
|||||||
Reference in New Issue
Block a user