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.
50 lines
1.1 KiB
Bash
Executable File
50 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
. "$(dirname "$0")/../util/lib.sh"
|
|
|
|
init
|
|
check_hostaliases
|
|
|
|
mkdir -p .logs
|
|
|
|
generate_certs_for testserver
|
|
add_user user@testserver secretpassword
|
|
add_user someone@testserver secretpassword
|
|
|
|
function send_one() {
|
|
rm -f .logs/mail_log .logs/stdout .logs/stderr
|
|
envsubst < config/chasquid.conf.in > config/chasquid.conf
|
|
|
|
chasquid -v=2 --logfile=.logs/chasquid.log --config_dir=config \
|
|
> .logs/stdout 2> .logs/stderr &
|
|
wait_until_ready 1025
|
|
|
|
smtpc someone@testserver < content
|
|
wait_for_file .mail/someone@testserver
|
|
mail_diff content .mail/someone@testserver
|
|
|
|
pkill -s 0 chasquid
|
|
sleep 0.2
|
|
}
|
|
|
|
export MAIL_LOG_PATH="../.logs/mail_log"
|
|
send_one
|
|
if ! grep -q "from=user@testserver all done" .logs/mail_log; then
|
|
fail "entries not found in .logs/mail_log"
|
|
fi
|
|
|
|
export MAIL_LOG_PATH="<stdout>"
|
|
send_one
|
|
if ! grep -q "from=user@testserver all done" .logs/stdout; then
|
|
fail "entries not found in .logs/stdout"
|
|
fi
|
|
|
|
export MAIL_LOG_PATH="<stderr>"
|
|
send_one
|
|
if ! grep -q "from=user@testserver all done" .logs/stderr; then
|
|
fail "entries not found in .logs/stderr"
|
|
fi
|
|
|
|
success
|