1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-30 16:47:02 +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:
Alberto Bertogli
2024-03-09 19:10:08 +00:00
parent 7f44db008d
commit 5eded4edc3
54 changed files with 281 additions and 331 deletions

View File

@@ -1,3 +1,4 @@
From: user@testserver
Subject: Prueba desde el test
Crece desde el test el futuro

View File

@@ -1,14 +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

View File

@@ -14,7 +14,7 @@ chasquid -v=2 --logfile=.logs/chasquid.log --config_dir=config &
wait_until_ready 1025
function send_and_check() {
run_msmtp "$1@testserver" < content
smtpc "$1@testserver" < content
shift
for i in "$@"; do
wait_for_file ".mail/$i@testserver"
@@ -42,7 +42,7 @@ send_and_check añil+blah azul índigo
# Test the pipe alias separately.
rm -f .data/pipe_alias_worked
run_msmtp tubo@testserver < content
smtpc tubo@testserver < content
wait_for_file .data/pipe_alias_worked
mail_diff content .data/pipe_alias_worked
@@ -58,17 +58,17 @@ send_and_check vic.uña+abc uña
# Test the pipe alias separately.
rm -f .data/pipe_alias_worked
run_msmtp ñandú@testserver < content
smtpc ñandú@testserver < content
wait_for_file .data/pipe_alias_worked
mail_diff content .data/pipe_alias_worked
# Test when alias-resolve exits with an error
if run_msmtp roto@testserver < content 2> .logs/msmtp.out; then
if smtpc roto@testserver < content 2> .logs/smtpc.out; then
fail "expected delivery to roto@ to fail, but succeeded"
fi
# Test a non-existent alias.
if run_msmtp nono@testserver < content 2> .logs/msmtp.out; then
if smtpc nono@testserver < content 2> .logs/smtpc.out; then
fail "expected delivery to nono@ to fail, but succeeded"
fi

View File

@@ -0,0 +1,4 @@
addr localhost:1465
server_cert config/certs/testserver/fullchain.pem
user user@testserver
password secretpassword