From 8845aaa6536c7049dcfffbaf93f7dce79bab1547 Mon Sep 17 00:00:00 2001 From: Heiko Reese Date: Sat, 11 Sep 2021 11:41:12 +0200 Subject: [PATCH] Fixed test numbering --- src/meson.build | 4 +- ...ibexim-encrypt-dlfunc-decrypt-secretbox.sh | 39 +++++++++++++------ src/test_libexim-encrypt-dlfunc.sh | 3 -- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/meson.build b/src/meson.build index 3f8540e..57b39ce 100644 --- a/src/meson.build +++ b/src/meson.build @@ -17,7 +17,7 @@ shared_library('exim-encrypt-dlfunc', 'libexim-encrypt-dlfunc.c', install: true) dlfunc_test = find_program('test_libexim-encrypt-dlfunc.sh') -test('simple test', dlfunc_test, protocol: tap) +test('libexim-encrypt-dlfunc', dlfunc_test, protocol: 'tap') decrypt_secretbox_test = find_program('test_libexim-encrypt-dlfunc-decrypt-secretbox.sh') -test('decrypt-secretbox', decrypt_secretbox_test) \ No newline at end of file +test('decrypt-secretbox', decrypt_secretbox_test, protocol: 'tap') \ No newline at end of file diff --git a/src/test_libexim-encrypt-dlfunc-decrypt-secretbox.sh b/src/test_libexim-encrypt-dlfunc-decrypt-secretbox.sh index b9d915f..6c1f04e 100755 --- a/src/test_libexim-encrypt-dlfunc-decrypt-secretbox.sh +++ b/src/test_libexim-encrypt-dlfunc-decrypt-secretbox.sh @@ -1,30 +1,45 @@ #!/bin/bash # shellcheck disable=SC2034 -set -e - PATH=/sbin:/usr/sbin:$PATH +# this script implements the TAP protocol (https://testanything.org) +echo 1..4 + TEST_PASSWORD='ThisIsAPassword' TEST_CLEARTEXT='This is my cleartext' TEST_CIPHERTEXT01='RCHI+VukmWIsVE3eixbWIAtPPBW63nmV1ITpSBEDYXC9Y5QMBd1zmGLLhE+S9yg0sHfOF/1+wmfF7YXv' TEST_CIPHERTEXT02='sEG09WnEKIN2nyJYGNNVo14o7wV6X9HQxW+zxAxMLX9jVdashdaoHqLXQGM8lzpJhG6629lccjzAfrq8' +CIPHERTEXT_FILE01="$(mktemp)" +CIPHERTEXT_FILE02="$(mktemp)" +echo "${TEST_CIPHERTEXT01}" > "${CIPHERTEXT_FILE01}" +echo "${TEST_CIPHERTEXT02}" > "${CIPHERTEXT_FILE02}" DECRYPTED01="$(LIBEXIM_PASSWORD="${TEST_PASSWORD}" src/libexim-encrypt-dlfunc-decrypt-secretbox ${TEST_CIPHERTEXT01})" - if [ "${DECRYPTED01}" == "${TEST_CLEARTEXT}" ] ; then - echo "decryption with password from environment successful" + echo "ok 1 - decrypt commandline argument with password from environment successful" else - echo "decryption with password from environment unsuccessful" - exit 127 + echo "not ok 1 - decrypt commandline argument with password from environment unsuccessful" fi -unset LIBEXIM_PASSWORD -DECRYPTED02="$(src/libexim-encrypt-dlfunc-decrypt-secretbox -p ${TEST_PASSWORD} ${TEST_CIPHERTEXT02})" - +DECRYPTED02="$(LIBEXIM_PASSWORD="${TEST_PASSWORD}" src/libexim-encrypt-dlfunc-decrypt-secretbox --infile ${CIPHERTEXT_FILE01})" if [ "${DECRYPTED02}" == "${TEST_CLEARTEXT}" ] ; then - echo "decryption with password from commandline successful" + echo "ok 2 - decrypt file contents with password from environment successful" else - echo "decryption with password from commandline unsuccessful" - exit 128 + echo "not ok 2 - decrypt file contents with password from environment unsuccessful" +fi +unset LIBEXIM_PASSWORD + +DECRYPTED03="$(src/libexim-encrypt-dlfunc-decrypt-secretbox -p ${TEST_PASSWORD} ${TEST_CIPHERTEXT02})" +if [ "${DECRYPTED03}" == "${TEST_CLEARTEXT}" ] ; then + echo "ok 3 - decrypt commandline argument with password from commandline successful" +else + echo "not ok 3 - decrypt commandline argument with password from commandline unsuccessful" +fi + +DECRYPTED04="$(src/libexim-encrypt-dlfunc-decrypt-secretbox -p ${TEST_PASSWORD} --infile ${CIPHERTEXT_FILE02})" +if [ "${DECRYPTED04}" == "${TEST_CLEARTEXT}" ] ; then + echo "ok 4 - decrypt commandline argument with password from commandline successful" +else + echo "not ok 4 - decrypt commandline argument with password from commandline unsuccessful" fi \ No newline at end of file diff --git a/src/test_libexim-encrypt-dlfunc.sh b/src/test_libexim-encrypt-dlfunc.sh index fe0b3cd..1177e98 100755 --- a/src/test_libexim-encrypt-dlfunc.sh +++ b/src/test_libexim-encrypt-dlfunc.sh @@ -1,6 +1,5 @@ #!/bin/bash -set -e PATH=/sbin:/usr/sbin:$PATH # this script implements the TAP protocol (https://testanything.org) @@ -20,7 +19,6 @@ if [ "${CLEARTEXT}" == "${DECRYPTED}" ] ; then echo "ok 1 - secretbox test successful" else echo "not ok 1 - secretbox test unsuccessful" - exit 127 fi # { 0xb6, 0x01, 0x45, 0x20, 0x9f, 0x55, 0x06, 0x74, 0x29, 0x71, 0x7b, 0x5e, 0xa9, 0x68, 0x60, 0x5e, 0x81, 0x1a, 0x54, 0x6b, 0xc9, 0x80, 0x97, 0x78, 0x41, 0xc6, 0x20, 0xae, 0x66, 0x9f, 0xd9, 0x53 }; @@ -35,5 +33,4 @@ if [ "${CLEARTEXT}" == "${DECRYPTED}" ] ; then echo "ok 2 - sealed_box test successful" else echo "ok 2 - sealed_box test unsuccessful" - exit 128 fi