mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
When resolving MX records, we need to distinguish between "no such domain" and other kinds of errors. Before Go 1.13, this was not possible, so we had a workaround that assumed any permanent error was a "no such domain", which is not great, but functional. Now that our minimum supported version is Go 1.15, we can remove the workaround. This patch replaces the workaround with proper logic using DNSError.IsNotFound to identify NXDOMAIN results when resolving MX records. This requires to adjust a few tests, that used to work on environments where resolving unknown domains (used for testing) returned a permanent error, and now they no longer do so. Instead of relying on this environmental property, we make the affected tests use our own DNS server, which should make them more hermetic and reproducible.
74 lines
2.1 KiB
Bash
Executable File
74 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# This test checks that we can send and receive mail to/from exim4.
|
|
#
|
|
# Setup:
|
|
# - chasquid listening on :1025.
|
|
# - exim listening on :2025.
|
|
# - hosts "srv-chasquid" and "srv-exim" pointing back to localhost.
|
|
# - exim configured to accept all email and forward it to
|
|
# someone@srv-chasquid.
|
|
#
|
|
# Test:
|
|
# msmtp --> chasquid --> exim --> chasquid --> local delivery
|
|
#
|
|
# msmtp will auth as user@srv-chasquid to chasquid, and send an email with
|
|
# recipient someone@srv-exim.
|
|
#
|
|
# chasquid will deliver the mail to exim.
|
|
#
|
|
# exim will deliver the mail back to chasquid (after changing the
|
|
# destination to someone@chasquid).
|
|
#
|
|
# chasquid will receive the email from exim, and deliver it locally.
|
|
|
|
set -e
|
|
. $(dirname ${0})/../util/lib.sh
|
|
|
|
init
|
|
check_hostaliases
|
|
|
|
if ! .exim4/exim4 --version > /dev/null; then
|
|
skip "exim4 binary at .exim4/exim4 is not functional"
|
|
exit 0
|
|
fi
|
|
|
|
# Create a temporary directory for exim4 to use, and generate the exim4
|
|
# config based on the template.
|
|
mkdir -p .exim4
|
|
EXIMDIR="$PWD/.exim4" envsubst < config/exim4.in > .exim4/config
|
|
|
|
# Build with the DNS override, so we can fake DNS records.
|
|
export GOTAGS="dnsoverride"
|
|
|
|
# Launch minidns in the background using our configuration.
|
|
minidns_bg --addr=":9053" -zones=zones >> .minidns.log 2>&1
|
|
|
|
generate_certs_for srv-chasquid
|
|
add_user user@srv-chasquid secretpassword
|
|
add_user someone@srv-chasquid secretpassword
|
|
|
|
# Launch chasquid at port 1025 (in config).
|
|
# Use outgoing port 2025 which is where exim will be at.
|
|
# Bypass MX lookup, so it can find srv-exim (via our host alias).
|
|
mkdir -p .logs
|
|
chasquid -v=2 --logfile=.logs/chasquid.log --config_dir=config \
|
|
--testing__dns_addr=127.0.0.1:9053 \
|
|
--testing__outgoing_smtp_port=2025 &
|
|
|
|
wait_until_ready 1025
|
|
wait_until_ready 9053
|
|
|
|
# Launch exim at port 2025
|
|
.exim4/exim4 -bd -d -C "$PWD/.exim4/config" > .exim4/log 2>&1 &
|
|
wait_until_ready 2025
|
|
|
|
# msmtp will use chasquid to send an email to someone@srv-exim.
|
|
run_msmtp someone@srv-exim < content
|
|
|
|
wait_for_file .mail/someone@srv-chasquid
|
|
|
|
mail_diff content .mail/someone@srv-chasquid
|
|
|
|
success
|