1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-01-05 17:37:03 +00:00
Files
go-chasquid-smtp/test/t-15-driusan_dkim/run.sh
Alberto Bertogli d78056aff5 test: Skip integration tests if $HOSTALIASES is not functional
Most integration tests depend on the $HOSTALIASES environment variable
being functional. That variable works on most systems, but not all. In
particular, systems with `systemd-resolved` can cause the variable to be
ignored.

This was reported by Alex Ellwein in
https://github.com/albertito/chasquid/issues/20.

This patch makes the affected tests to be skipped if $HOSTALIASES is not
working properly. It also removes unnecessary hosts files from tests
which don't need it, and documents this behaviour.

Thanks to Alex Ellwein and foxcpp@ for reporting and helping investigate
this issue!
2021-07-15 00:20:21 +01:00

53 lines
1.4 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 ! which $binary > /dev/null; then
skip "$binary binary not found"
exit 0
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 1025
# Authenticated: user@testserver -> someone@testserver
# Should be signed.
run_msmtp 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.py --server=localhost:1025 < .signed_content
# Check that the signature fails on modified content.
echo "Added content, invalid and not signed" >> .signed_content
if smtpc.py --server=localhost:1025 < .signed_content 2> /dev/null; then
fail "DKIM verification succeeded on modified content"
fi
success