Files
husk-milter/docker/mta_provision/usr/bin/test_1.sh
T
Malte Meiboom 1f8d7e9a3f Add test framework to test
- Mail encryption (when expected)
- Introducer listing, adding and removing
- Locals listing, adding and removing
2026-05-20 14:27:28 +02:00

51 lines
1.1 KiB
Bash

#!/usr/bin/bash
adduser --shell /bin/bash --disabled-password --gecos "" mtatest
echo "test message" | sendmail -t mtatest@example.com
sleep 1
## simple test if mail passes
if [ -f /var/mail/mtatest ] ; then
echo "success"
rm /var/mail/mtatest
else
echo "failure"
exit 1
fi
## test encryption
## bob@example.com has an authenticated certificate in
## the cert store
echo "test message" | sendmail -t bob@example.com
sleep 1
if [ -f /var/mail/bob ] ; then
if grep -q "BEGIN PGP MESSAGE" /var/mail/bob ; then
echo "encryption test: success"
else
echo "encryption test: failure"
exit 1
fi
else
echo "failure: mail didn't pass"
exit 1
fi
## test encryption 2
## alice@example.com has a certificate in the cert store, but
## it is not authenticated -> this should fail
echo "test message" | sendmail -t alice@example.com
sleep 1
if [ -f /var/mail/alice ] ; then
if grep -q "BEGIN PGP MESSAGE" /var/mail/alice ; then
echo "encryption test 2: failure"
exit 1
else
echo "encryption test 2: success"
fi
else
echo "failure: mail didn't pass"
exit 1
fi