mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-26 16:07:04 +00:00
test: Unify (most) SMTP client calls
To send mails, today some tests use msmtp and others our internal smtpc.py. This works, but msmtp slows down the tests significantly, and smtpc.py is also not particularly fast, and also has some limitations. This patch introduces a new SMTP client tool written in Go, and makes almost all the tests use it. Some tests still remain on msmtp, mainly for client-check compatibility. It's likely that this will be moved in later patches to a separate special-purpose test. With this patch, integration tests take ~20% less time than before.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
smtp_address: ":1025"
|
||||
submission_address: ":1587"
|
||||
submission_over_tls_address: ":1465"
|
||||
monitoring_address: ":1099"
|
||||
|
||||
mail_delivery_agent_bin: "test-mda"
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
account default
|
||||
|
||||
host testserver
|
||||
port 1587
|
||||
|
||||
tls on
|
||||
tls_trust_file config/certs/testserver/fullchain.pem
|
||||
|
||||
from user@testserver
|
||||
|
||||
auth on
|
||||
user user@testserver
|
||||
password secretpassword
|
||||
|
||||
logfile .logs/msmtp
|
||||
@@ -18,7 +18,7 @@ wait_until_ready 1025
|
||||
|
||||
cp config/hooks/post-data.good config/hooks/post-data
|
||||
|
||||
run_msmtp someone@testserver < content
|
||||
smtpc someone@testserver < content
|
||||
|
||||
wait_for_file .mail/someone@testserver
|
||||
|
||||
@@ -51,20 +51,20 @@ check "SPF_PASS=0"
|
||||
|
||||
# Check that failures in the script result in failing delivery.
|
||||
# Transient failure.
|
||||
if run_msmtp blockme@testserver < content 2>/dev/null; then
|
||||
if smtpc blockme@testserver < content >.logs/smtpc.log 2>&1; 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
|
||||
if ! grep -q "451 ¡No pasarán!" .logs/smtpc.log; then
|
||||
cat .logs/smtpc.log
|
||||
fail "ERROR: transient hook error not returned correctly"
|
||||
fi
|
||||
|
||||
# Permanent failure.
|
||||
if run_msmtp permanent@testserver < content 2>/dev/null; then
|
||||
if smtpc permanent@testserver < content >.logs/smtpc.log 2>&1; 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
|
||||
if ! grep -q "554 Nos hacemos la permanente" .logs/smtpc.log; then
|
||||
cat .logs/smtpc.log
|
||||
fail "ERROR: permanent hook error not returned correctly"
|
||||
fi
|
||||
|
||||
@@ -72,7 +72,7 @@ fi
|
||||
for i in config/hooks/post-data.bad*; do
|
||||
cp "$i" config/hooks/post-data
|
||||
|
||||
run_msmtp someone@testserver < content
|
||||
smtpc someone@testserver < content
|
||||
wait_for_file .mail/someone@testserver
|
||||
mail_diff content .mail/someone@testserver
|
||||
done
|
||||
|
||||
4
test/t-10-hooks/smtpc.conf
Normal file
4
test/t-10-hooks/smtpc.conf
Normal file
@@ -0,0 +1,4 @@
|
||||
addr localhost:1465
|
||||
server_cert config/certs/testserver/fullchain.pem
|
||||
user user@testserver
|
||||
password secretpassword
|
||||
Reference in New Issue
Block a user