#!/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 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 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" delete_unix_user hubert exit 1 fi sleep 1 # remove 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" 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 delete_unix_user hubert exit $RESULT_CODE