Files
husk-milter/e2e-tests/tests/51_add_locals.sh
T
Malte Meiboom 8b2f284916 Improve e2e tests
- Add a test for mail splitting.
- Cleanup the code, move common functionality into `common.sh`.
- Reduce noise in the test output.
2026-07-09 12:55:10 +02:00

43 lines
983 B
Bash

#!/usr/bin/bash
# source some functions
. common.sh
test_header "Add locals"
sq key generate --shared-key --without-password --email 'hubert@example.com' --output /tmp/hubert.pgp --rev-cert /tmp/hubert_rev.pgp > /dev/null 2>&1
cd $HUSK_DIR
$HUSK_BIN locals add --cert-file /tmp/hubert.pgp --config config/config.toml
if ! $HUSK_BIN locals list --config config/config.toml | grep -q "hubert@example.com" ; then
echo "adding failed"
exit 1
fi
# send a mail, husk should encrypt it
create_unix_user hubert
send_test_mail hubert@example.com
R=$(expect_mail hubert encrypted)
if [ $R != 0 ] ; then
delete_unix_user hubert
exit 1
fi
sleep 1
echo "removing hubert as local"
HUBERT_FPR=$(sq cert list --cert-email hubert@example.com 2>/dev/null | head -n 1 | cut -d ' ' -f 3)
$HUSK_BIN locals remove --cert $HUBERT_FPR --config config/config.toml
rm /var/mail/hubert
send_test_mail hubert@example.com
R=$(expect_mail hubert unencrypted)
delete_unix_user hubert
exit $R