Added test fo password decryption command

This commit is contained in:
Heiko Reese
2021-09-11 02:46:32 +02:00
parent 5a1bd58452
commit 1f8aa5fc4c
3 changed files with 36 additions and 3 deletions

View File

@ -0,0 +1,31 @@
#!/bin/bash
# shellcheck disable=SC2034
set -e
PATH=/sbin:/usr/sbin:$PATH
TEST_PASSWORD='ThisIsAPassword'
TEST_CLEARTEXT='This is my cleartext'
TEST_CIPHERTEXT01='RCHI+VukmWIsVE3eixbWIAtPPBW63nmV1ITpSBEDYXC9Y5QMBd1zmGLLhE+S9yg0sHfOF/1+wmfF7YXv'
TEST_CIPHERTEXT02='sEG09WnEKIN2nyJYGNNVo14o7wV6X9HQxW+zxAxMLX9jVdashdaoHqLXQGM8lzpJhG6629lccjzAfrq8'
LIBEXIM_PASSWORD="${TEST_PASSWORD}"
DECRYPTED01="$(src/libexim-encrypt-dlfunc-decrypt-secretbox ${TEST_CIPHERTEXT01})"
if [ "${DECRYPTED01}" == "${TEST_CLEARTEXT}" ] ; then
echo "decryption with password from environment successful"
else
echo "decryption with password from environment unsuccessful"
exit 127
fi
unset LIBEXIM_PASSWORD
DECRYPTED02="$(src/libexim-encrypt-dlfunc-decrypt-secretbox -p ${TEST_PASSWORD} ${TEST_CIPHERTEXT02})"
if [ "${DECRYPTED02}" == "${TEST_CLEARTEXT}" ] ; then
echo "decryption with password from commandline successful"
else
echo "decryption with password from commandline unsuccessful"
exit 128
fi