Improve e2e tests
- Add a test for mail splitting. - Cleanup the code, move common functionality into `common.sh`. - Reduce noise in the test output.
This commit is contained in:
@@ -14,12 +14,11 @@ $HUSK_BIN introducer list --config config/config.toml
|
||||
create_unix_user fred
|
||||
FRED_FPR=$(sq key generate --shared-key --without-password --name "Fred" --email "fred@example.org" 2>&1 | grep "Fingerprint:" | cut -d ':' -f 2)
|
||||
sleep 1
|
||||
sq pki link retract --cert $FRED_FPR --all
|
||||
sq pki link retract --cert $FRED_FPR --all > /dev/null 2>&1
|
||||
|
||||
sq pki vouch add --certifier $ELLEN_FPR --cert $FRED_FPR --email "fred@example.org"
|
||||
sq pki vouch add --certifier $ELLEN_FPR --cert $FRED_FPR --email "fred@example.org" > /dev/null 2>&1
|
||||
|
||||
send_test_mail fred@example.org
|
||||
|
||||
RESULT_CODE=$(expect_mail fred encrypted)
|
||||
|
||||
if [ "$RESULT_CODE" == "1" ] ; then
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
@@ -16,47 +16,27 @@ if ! $HUSK_BIN locals list --config config/config.toml | grep -q "hubert@example
|
||||
fi
|
||||
|
||||
# send a mail, husk should encrypt it
|
||||
echo "send mail to hubert@example.com"
|
||||
create_unix_user hubert
|
||||
send_test_mail hubert@example.com
|
||||
|
||||
if [ -f /var/mail/hubert ] ; then
|
||||
if grep -q "BEGIN PGP MESSAGE" /var/mail/hubert ; then
|
||||
RESULT_CODE=0
|
||||
else
|
||||
echo "no encryption detected"
|
||||
delete_unix_user hubert
|
||||
exit 1
|
||||
fi
|
||||
# remove mail
|
||||
rm /var/mail/hubert
|
||||
else
|
||||
echo "no mail detected"
|
||||
R=$(expect_mail hubert encrypted)
|
||||
if [ $R != 0 ] ; then
|
||||
delete_unix_user hubert
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
# remove hubert as local
|
||||
|
||||
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
|
||||
|
||||
echo "send mail to hubert@example.com"
|
||||
rm /var/mail/hubert
|
||||
send_test_mail hubert@example.com
|
||||
|
||||
if [ -f /var/mail/hubert ] ; then
|
||||
if grep -q "BEGIN PGP MESSAGE" /var/mail/hubert ; then
|
||||
echo "encryption detected where there should be none"
|
||||
RESULT_CODE=1
|
||||
else
|
||||
RESULT_CODE=0
|
||||
fi
|
||||
else
|
||||
echo "no mail detected"
|
||||
RESULT_CODE=1
|
||||
fi
|
||||
R=$(expect_mail hubert unencrypted)
|
||||
|
||||
delete_unix_user hubert
|
||||
|
||||
exit $RESULT_CODE
|
||||
exit $R
|
||||
|
||||
|
||||
@@ -5,39 +5,28 @@
|
||||
|
||||
test_header "Signing"
|
||||
|
||||
# sq key generate --shared-key --without-password --email 'signing@example.com' --output /tmp/signing.pgp --rev-cert /tmp/signing.rev
|
||||
|
||||
SIGN_FPR=$(sq key generate --own-key --without-password --name "Signing Key" 2>&1 | grep "Fingerprint:" | cut -d ':' -f 2)
|
||||
SIGN_FPR_GEN=$(sq key generate --own-key --without-password --name "Signing Key" 2>&1 | grep "Fingerprint:" | cut -d ':' -f 2 | tr -d ' ')
|
||||
|
||||
cd $HUSK_DIR
|
||||
|
||||
$HUSK_BIN --config config/config.toml signkey set --cert $SIGN_FPR
|
||||
$HUSK_BIN --config config/config.toml signkey set --cert $SIGN_FPR_GEN
|
||||
SIGN_FPR=$($HUSK_BIN --config config/config.toml signkey show | cut -d ':' -f 2 | tr -d ' ')
|
||||
echo "found signing key $SIGN_FPR"
|
||||
|
||||
if [ "$SIGN_FPR" != "$SIGN_FPR_GEN" ] ; then
|
||||
echo "setting new siging key failed, found $SIGN_FPR expected $SIGN_FPR_GEN"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
create_unix_user juliette
|
||||
JULIETTE_FPR=$(sq key generate --own-key --without-password --name "Juliette" --email "juliette@example.com" 2>&1 | grep "Fingerprint:" | cut -d ':' -f 2)
|
||||
sq pki vouch add --certifier-userid "CA" --cert $JULIETTE_FPR --all > /dev/null 2>&1
|
||||
# sq pki vouch add --certifier-userid "CA" --cert $JULIETTE_FPR --all > /dev/null 2>&1
|
||||
|
||||
# send a mail, husk should encrypt it
|
||||
echo "send mail to juliette@example.com"
|
||||
send_test_mail juliette@example.com
|
||||
|
||||
if [ -f /var/mail/juliette ] ; then
|
||||
if grep -q "BEGIN PGP MESSAGE" /var/mail/juliette ; then
|
||||
|
||||
FOUND_FPR=$(sq packet dump /var/mail/juliette | grep "Issuer Fingerprint:" | cut -d ':' -f 2 | tr -d ' ')
|
||||
|
||||
if [ "$SIGN_FPR" != "$FOUND_FPR" ] ; then
|
||||
echo "Found wrong fingerprint '$FOUND_FPR' - expected '$SIGN_FPR'"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "no encryption detected"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "no mail detected"
|
||||
R=$(expect_mail juliette encrypted $SIGN_FPR)
|
||||
if [ $R != 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -50,23 +39,6 @@ echo "new signing key $SIGN_FPR"
|
||||
# remove old mail
|
||||
rm /var/mail/juliette
|
||||
|
||||
echo "send mail to juliette@example.com"
|
||||
send_test_mail juliette@example.com
|
||||
|
||||
if [ -f /var/mail/juliette ] ; then
|
||||
if grep -q "BEGIN PGP MESSAGE" /var/mail/juliette ; then
|
||||
|
||||
FOUND_FPR=$(sq packet dump /var/mail/juliette | grep "Issuer Fingerprint:" | cut -d ':' -f 2 | tr -d ' ')
|
||||
|
||||
if [ "$SIGN_FPR" != "$FOUND_FPR" ] ; then
|
||||
echo "Found wrong fingerprint '$FOUND_FPR' - expected '$SIGN_FPR'"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "no encryption detected"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "no mail detected"
|
||||
exit 1
|
||||
fi
|
||||
exit $(expect_mail juliette encrypted $SIGN_FPR)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# source some functions
|
||||
. common.sh
|
||||
|
||||
test_header "Mail split"
|
||||
|
||||
create_unix_user karl
|
||||
KARL_FPR=$(gen_cert karl@example.com)
|
||||
authenticate $KARL_FPR
|
||||
|
||||
create_unix_user laura
|
||||
|
||||
echo -e "To: karl@example.com, Laura <laura@example.com>\nSubject: Testmail\n\nTestmail." | sendmail -t
|
||||
sleep 1
|
||||
|
||||
R=1
|
||||
if [ $(expect_mail karl encrypted) == 0 ] ; then
|
||||
if [ $(expect_mail laura unencrypted) == 0 ] ; then
|
||||
R=0
|
||||
fi
|
||||
fi
|
||||
|
||||
exit $R
|
||||
Reference in New Issue
Block a user