Files
container-postfix/test/smoke.sh
T
unkin-agent 8736092555
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
Scaffold postfix smarthost image
2026-10-12 00:32:49 +11:00

32 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Delivers one STARTTLS message through every map type to an LMTP sink, starting from an
# empty spool as on a fresh queue volume.
set -euo pipefail
cd "$(dirname "$0")"
cp main.cf transport canonical header_checks.pcre client.regexp /etc/postfix/
postmap lmdb:/etc/postfix/transport
postmap hash:/etc/postfix/canonical
openssl req -x509 -newkey rsa:2048 -nodes -days 1 -subj /CN=smarthost.test \
-keyout /etc/postfix/tls.key -out /etc/postfix/tls.crt 2>/dev/null
rm -rf /var/spool/postfix/*
postfix check
mkdir -p /tmp/sink && chown postfix /tmp/sink
smtp-sink -L -u postfix -d /tmp/sink/%H%M%S. 127.0.0.1:2400 10 &
postfix start-fg >/tmp/postfix.log 2>&1 &
trap 'cat /tmp/postfix.log' ERR
for _ in $(seq 30); do (: </dev/tcp/127.0.0.1/25) 2>/dev/null && break; sleep 1; done
swaks --server 127.0.0.1:25 --tls --helo smoke.test --from smoke@example.com --to ben@unkin.net \
--header 'X-Smoke: 1' --silent 2
for _ in $(seq 30); do ls /tmp/sink/* >/dev/null 2>&1 && break; sleep 1; done
msg=$(cat /tmp/sink/*)
echo "$msg"
for want in 'relayed@unkin.net' 'X-Map-Pcre: hit' 'X-Map-Regexp: hit' 'using TLS' 'X-Smoke: 1'; do
grep -qF "$want" <<<"$msg" || { echo "missing in delivered message: $want"; false; }
done
postfix stop
echo "smoke test passed"