author | Alberto Bertogli
<albertito@blitiri.com.ar> 2019-12-01 20:31:59 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2019-12-01 20:31:59 UTC |
parent | a12875162f7afae8c427c362b7de1b3a366d60be |
test/t-10-hooks/config/hooks/post-data.good | +5 | -0 |
test/t-10-hooks/msmtprc | +1 | -0 |
test/t-10-hooks/run.sh | +16 | -1 |
diff --git a/test/t-10-hooks/config/hooks/post-data.good b/test/t-10-hooks/config/hooks/post-data.good index 70a1561..0bc7b7b 100755 --- a/test/t-10-hooks/config/hooks/post-data.good +++ b/test/t-10-hooks/config/hooks/post-data.good @@ -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" diff --git a/test/t-10-hooks/msmtprc b/test/t-10-hooks/msmtprc index 8d191e1..0c00237 100644 --- a/test/t-10-hooks/msmtprc +++ b/test/t-10-hooks/msmtprc @@ -12,3 +12,4 @@ auth on user user@testserver password secretpassword +logfile .logs/msmtp diff --git a/test/t-10-hooks/run.sh b/test/t-10-hooks/run.sh index f9ecaa5..8e41301 100755 --- a/test/t-10-hooks/run.sh +++ b/test/t-10-hooks/run.sh @@ -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