1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00
Files
go-chasquid-smtp/test/t-14-tls_tracking/run.sh
Alberto Bertogli e6c6df457d chasquid-util: Use server for aliases-resolve and domaininfo-remove
This patch makes chasquid-util's aliases-resolve and domaininfo-remove
commands talk to the chasquid server (via the new localrpc server).

For aliases-resolve, currently has fairly hacky logic which reimplements
a bunch of the servers', and is also incomplete because it does not
support hooks.

In this patch we fix that by having it talk to the server, where we get
authoritative responses and have no issues with aliases hooks. This
resolves https://github.com/albertito/chasquid/issues/18.

For domaininfo-remove, currently its implementation is also very hacky
since it manipulates files behind the servers' back and without even
using the internal library.

In this patch we fix that by doing the operation through the server,
avoiding the need for those hacks, and also remove the need to manually
reload the server afterwards.
2023-07-30 13:21:07 +01:00

81 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# Test TLS tracking features, which require faking SPF.
set -e
. "$(dirname "$0")/../util/lib.sh"
init
check_hostaliases
# 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
# Two chasquid servers:
# A - listens on :1025, hosts srv-A
# B - listens on :2025, hosts srv-B
CONFDIR=A generate_certs_for srv-A
CONFDIR=A add_user usera@srv-A userA
CONFDIR=B generate_certs_for srv-B
CONFDIR=B add_user userb@srv-B userB
rm -rf .data-A .data-B .mail .certs
mkdir -p .logs-A .logs-B .mail .certs
# Put public certs in .certs, and use it as our trusted cert dir.
cp A/certs/srv-A/fullchain.pem .certs/srv-a.pem
cp B/certs/srv-B/fullchain.pem .certs/srv-b.pem
export SSL_CERT_DIR=$PWD/.certs/
chasquid -v=2 --logfile=.logs-A/chasquid.log --config_dir=A \
--testing__dns_addr=127.0.0.1:9053 \
--testing__max_received_headers=5 \
--testing__outgoing_smtp_port=2025 &
chasquid -v=2 --logfile=.logs-B/chasquid.log --config_dir=B \
--testing__dns_addr=127.0.0.1:9053 \
--testing__outgoing_smtp_port=1025 &
wait_until_ready 1025
wait_until_ready 2025
wait_until_ready 9053
run_msmtp userB@srv-B < content
wait_for_file .mail/userb@srv-b
mail_diff content .mail/userb@srv-b
# A should have a secure outgoing connection to srv-b.
if ! grep -q 'outgoing_sec_level:\s*TLS_SECURE' ".data-A/domaininfo/s:srv-b";
then
fail "A is missing the domaininfo for srv-b"
fi
# B should have a secure incoming connection from srv-a.
if ! grep -q 'incoming_sec_level:\s*TLS_CLIENT' ".data-B/domaininfo/s:srv-a";
then
fail "B is missing the domaininfo for srv-a"
fi
# In A, remove domaininfo data about srv-B.
# Check that it was cleared successfully.
CONFDIR=A chasquid-util domaininfo-remove srv-b
if grep -q 'outgoing_sec_level:' ".data-A/domaininfo/s:srv-b";
then
fail "Error clearing A's domaininfo about srv-b"
fi
# While at it, check that a domaininfo-remove for an unknown domain results in
# an error.
if CONFDIR=A chasquid-util domaininfo-remove srv-X > .cdu-di-r-x.log 2>&1; then
fail "Expected error on chasquid-util domaininfo-remove srv-X"
fi
success