Add end-to-end Test
- Add an infrastructur to run local e2e tests. - Add some tests.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
cargo build --release
|
||||
|
||||
docker run -ti \
|
||||
--rm \
|
||||
--mount type=bind,src=$(pwd),dst=/opt/husk/mapped/ \
|
||||
localhost/mta \
|
||||
bash -c "/usr/bin/prepare.sh && bash /opt/husk/mapped/e2e-tests/runner.sh"
|
||||
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
for TEST in ./tests/* ; do
|
||||
if bash $TEST ; then
|
||||
echo "success"
|
||||
else
|
||||
echo "failure"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
echo "Basic: Test if MTA is working"
|
||||
|
||||
adduser --shell /bin/bash --disabled-password --gecos "" mtatest
|
||||
echo "test mail" | sendmail mtatest@example.com
|
||||
|
||||
sleep 1
|
||||
|
||||
if [ -f /var/mail/mtatest ] ; then
|
||||
RESULT_CODE=0
|
||||
else
|
||||
RESULT_CODE=1
|
||||
fi
|
||||
|
||||
deluser --remove-home mtatest
|
||||
|
||||
exit $RESULT_CODE
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
echo "Simple: Test encryption for available certificate"
|
||||
|
||||
# There is an authenticated certificate for bob in the cert store
|
||||
adduser --shell /bin/bash --disabled-password --gecos "" bob
|
||||
echo "test mail" | sendmail bob@example.com
|
||||
|
||||
sleep 1
|
||||
|
||||
if [ -f /var/mail/bob ] ; then
|
||||
if grep -q "BEGIN PGP MESSAGE" /var/mail/bob ; then
|
||||
RESULT_CODE=0
|
||||
else
|
||||
echo "no encryption detected"
|
||||
RESULT_CODE=1
|
||||
fi
|
||||
else
|
||||
echo "no mail detected"
|
||||
RESULT_CODE=1
|
||||
fi
|
||||
|
||||
deluser --remove-home bob
|
||||
|
||||
exit $RESULT_CODE
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
echo "Simple: Test encryption for unavailable certificate"
|
||||
|
||||
# There is no authenticated certificate for alice in the cert store
|
||||
adduser --shell /bin/bash --disabled-password --gecos "" alice
|
||||
echo "test mail" | sendmail alice@example.com
|
||||
|
||||
sleep 1
|
||||
|
||||
if [ -f /var/mail/alice ] ; then
|
||||
if grep -q "BEGIN PGP MESSAGE" /var/mail/alice ; then
|
||||
echo "encryption detected - that is wrong"
|
||||
RESULT_CODE=1
|
||||
else
|
||||
RESULT_CODE=0
|
||||
fi
|
||||
else
|
||||
echo "no mail detected"
|
||||
RESULT_CODE=1
|
||||
fi
|
||||
|
||||
deluser --remove-home alice
|
||||
|
||||
exit $RESULT_CODE
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
echo "Test encryption for certificate an a keyserver"
|
||||
|
||||
# There is a certificate for carol on the keyserver
|
||||
# it's certified by an introducer
|
||||
adduser --shell /bin/bash --disabled-password --gecos "" carol
|
||||
echo "test mail" | sendmail carol@example.com
|
||||
|
||||
sleep 1
|
||||
|
||||
if [ -f /var/mail/carol ] ; then
|
||||
if grep -q "BEGIN PGP MESSAGE" /var/mail/carol ; then
|
||||
RESULT_CODE=0
|
||||
else
|
||||
echo "no encryption detected"
|
||||
RESULT_CODE=1
|
||||
fi
|
||||
else
|
||||
echo "no mail detected"
|
||||
RESULT_CODE=1
|
||||
fi
|
||||
|
||||
deluser --remove-home carol
|
||||
|
||||
exit $RESULT_CODE
|
||||
Reference in New Issue
Block a user