Add test framework to test
- Mail encryption (when expected) - Introducer listing, adding and removing - Locals listing, adding and removing
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# create a unix (shell) user
|
||||
create_unix_user() { # name
|
||||
adduser --quiet --shell /bin/bash --disabled-password --gecos "" $1 > /dev/null 2>&1
|
||||
}
|
||||
|
||||
# delete a unix user, plus remove $HOME and mails
|
||||
delete_unix_user() { # name
|
||||
deluser --remove-home $1
|
||||
}
|
||||
|
||||
# send a mail and wait for delivery
|
||||
send_test_mail() { # email_address
|
||||
echo "test mail" | sendmail $1
|
||||
inotifywait -qq -t 3 -e close_write /var/mail
|
||||
}
|
||||
|
||||
# test header
|
||||
test_header() { # text
|
||||
echo "##############################################"
|
||||
echo $1
|
||||
echo "Workdir: $WORKDIR"
|
||||
echo "##############################################"
|
||||
}
|
||||
|
||||
# Generate a key outside the cert store. The key will not be
|
||||
# authenticated.
|
||||
gen_key() { # email
|
||||
FILE=$(echo $1 | cut -f 1 -d '@')
|
||||
FPR=$(sq key generate --home none --shared-key --without-password \
|
||||
--email $1 \
|
||||
--output $WORKDIR/${FILE}_sk.pgp \
|
||||
--rev-cert $WORKDIR/${FILE}.rev |& grep "Fingerprint:" | cut -d ':' -f 2)
|
||||
echo $FPR
|
||||
}
|
||||
|
||||
expect_mail() { # unix_user mode
|
||||
if [ -f /var/mail/$1 ] ; then
|
||||
case $2 in
|
||||
encrypted)
|
||||
if grep -q "BEGIN PGP MESSAGE" /var/mail/$1 ; then
|
||||
R=0
|
||||
else
|
||||
echo "expected encrypted mail for $1" >&2
|
||||
R=1
|
||||
fi
|
||||
;;
|
||||
unencrypted)
|
||||
if grep -q "BEGIN PGP MESSAGE" /var/mail/$1 ; then
|
||||
echo "expected unencrypted mail for $1" >&2
|
||||
R=1
|
||||
else
|
||||
R=0
|
||||
fi
|
||||
;;
|
||||
delivered)
|
||||
R=0
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "no mail for $1" >&2
|
||||
R=1
|
||||
fi
|
||||
echo $R
|
||||
}
|
||||
Reference in New Issue
Block a user