mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-01-09 17:55:57 +00:00
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.
58 lines
1.7 KiB
Bash
Executable File
58 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Test integration with driusan's DKIM tools.
|
|
# https://github.com/driusan/dkim
|
|
|
|
set -e
|
|
. "$(dirname "$0")/../util/lib.sh"
|
|
|
|
init
|
|
check_hostaliases
|
|
|
|
for binary in dkimsign dkimverify dkimkeygen; do
|
|
if ! command -v $binary > /dev/null; then
|
|
skip "$binary binary not found"
|
|
fi
|
|
done
|
|
|
|
generate_certs_for testserver
|
|
( mkdir -p .dkimcerts; cd .dkimcerts; dkimkeygen )
|
|
|
|
add_user user@testserver secretpassword
|
|
add_user someone@testserver secretpassword
|
|
|
|
mkdir -p .logs
|
|
chasquid -v=2 --logfile=.logs/chasquid.log --config_dir=config &
|
|
wait_until_ready 1465
|
|
|
|
# Authenticated: user@testserver -> someone@testserver
|
|
# Should be signed.
|
|
smtpc --addr=localhost:1465 \
|
|
--server_cert=config/certs/testserver/fullchain.pem \
|
|
--user=user@testserver --password=secretpassword \
|
|
someone@testserver < content
|
|
wait_for_file .mail/someone@testserver
|
|
mail_diff content .mail/someone@testserver
|
|
grep -q "DKIM-Signature:" .mail/someone@testserver
|
|
|
|
# Verify the signature manually, just in case.
|
|
dkimverify -txt .dkimcerts/dns.txt < .mail/someone@testserver
|
|
|
|
# Save the signed mail so we can verify it later.
|
|
# Drop the first line ("From blah") so it can be used as email contents.
|
|
tail -n +2 .mail/someone@testserver > .signed_content
|
|
|
|
# Not authenticated: someone@testserver -> someone@testserver
|
|
smtpc --addr=localhost:1025 \
|
|
--from=someone@testserver someone@testserver < .signed_content
|
|
|
|
# Check that the signature fails on modified content.
|
|
echo "Added content, invalid and not signed" >> .signed_content
|
|
if smtpc --addr=localhost:1025 \
|
|
--from=someone@testserver someone@testserver < .signed_content \
|
|
> /dev/null 2>&1 ; then
|
|
fail "DKIM verification succeeded on modified content"
|
|
fi
|
|
|
|
success
|