From d16e1e13c3287239f76be23ca6eb0f84095b7850 Mon Sep 17 00:00:00 2001 From: deajan Date: Sat, 31 Dec 2016 00:00:32 +0100 Subject: [PATCH] Improved GPG tests --- dev/tests/run_tests.sh | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/dev/tests/run_tests.sh b/dev/tests/run_tests.sh index 6b72aaf..9a42606 100755 --- a/dev/tests/run_tests.sh +++ b/dev/tests/run_tests.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash -## obackup basic tests suite 2016122801 +#TODO Encrypted Pull runs on F25 fail for decryption + +## obackup basic tests suite 2016123001 OBACKUP_DIR="$(pwd)" OBACKUP_DIR=${OBACKUP_DIR%%/dev*} @@ -138,6 +140,8 @@ function SetupGPG { echo "No gpg support" fi + echo "Crypt tool=$CRYPT_TOOL" + if ! $CRYPT_TOOL --list-keys | grep "John Doe" > /dev/null; then cat >gpgcommand <= 2.1 that does not allow automatic pin entry anymore + cryptToolVersion=$($CRYPT_TOOL --version | head -1 | awk '{print $3}') + cryptToolMajorVersion=${cryptToolVersion%%.*} + cryptToolSubVersion=${cryptToolVersion#*.} + cryptToolSubVersion=${cryptToolSubVersion%.*} + + if [ $cryptToolMajorVersion -eq 2 ] && [ $cryptToolSubVersion -ge 1 ]; then + additionalParameters="--pinentry-mode loopback" + fi + + if [ "$CRYPT_TOOL" == "gpg2" ]; then + options="--batch --yes" + elif [ "$CRYPT_TOOL" == "gpg" ]; then + options="--no-use-agent --batch" + fi + + echo "Decrypt using passphrase file" - $CRYPT_TOOL --out "$TESTS_DIR/$CRYPT_TESTFILE" --batch --yes --passphrase-file="$TESTS_DIR/$PASSFILE" --decrypt "$TESTS_DIR/$CRYPT_TESTFILE$CRYPT_EXTENSION" + $CRYPT_TOOL $options --out "$TESTS_DIR/$CRYPT_TESTFILE" --batch --yes $additionalParameters --passphrase-file="$TESTS_DIR/$PASSFILE" --decrypt "$TESTS_DIR/$CRYPT_TESTFILE$CRYPT_EXTENSION" assertEquals "Decrypt file using passfile" "0" $? echo "Decrypt using passphrase" - $CRYPT_TOOL --out "$TESTS_DIR/$CRYPT_TESTFILE" --batch --yes --passphrase PassPhrase123 --decrypt "$TESTS_DIR/$CRYPT_TESTFILE$CRYPT_EXTENSION" + $CRYPT_TOOL $options --out "$TESTS_DIR/$CRYPT_TESTFILE" --batch --yes $additionalParameters --passphrase PassPhrase123 --decrypt "$TESTS_DIR/$CRYPT_TESTFILE$CRYPT_EXTENSION" assertEquals "Decrypt file using passphrase" "0" $? echo "Decrypt using passphrase file with cat" - $CRYPT_TOOL --out "$TESTS_DIR/$CRYPT_TESTFILE" --batch --yes --passphrase $(cat "$TESTS_DIR/$PASSFILE") --decrypt "$TESTS_DIR/$CRYPT_TESTFILE$CRYPT_EXTENSION" + $CRYPT_TOOL $options --out "$TESTS_DIR/$CRYPT_TESTFILE" --batch --yes $additionalParameters --passphrase $(cat "$TESTS_DIR/$PASSFILE") --decrypt "$TESTS_DIR/$CRYPT_TESTFILE$CRYPT_EXTENSION" assertEquals "Decrypt file using passphrase" "0" $? echo "Decrypt using passphrase file --no-use-agent" - $CRYPT_TOOL --out "$TESTS_DIR/$CRYPT_TESTFILE" --no-use-agent --batch --yes --passphrase-file="$TESTS_DIR/$PASSFILE" --decrypt "$TESTS_DIR/$CRYPT_TESTFILE$CRYPT_EXTENSION" + $CRYPT_TOOL $options --out "$TESTS_DIR/$CRYPT_TESTFILE" --batch --yes $additionalParameters --passphrase-file="$TESTS_DIR/$PASSFILE" --decrypt "$TESTS_DIR/$CRYPT_TESTFILE$CRYPT_EXTENSION" assertEquals "Decrypt file using passphrase" "0" $? echo "Decrypt using passphrase --no-use-agent" - $CRYPT_TOOL --out "$TESTS_DIR/$CRYPT_TESTFILE" --no-use-agent --batch --yes --passphrase PassPhrase123 --decrypt "$TESTS_DIR/$CRYPT_TESTFILE$CRYPT_EXTENSION" + $CRYPT_TOOL $options --out "$TESTS_DIR/$CRYPT_TESTFILE" --batch --yes $additionalParameters --passphrase PassPhrase123 --decrypt "$TESTS_DIR/$CRYPT_TESTFILE$CRYPT_EXTENSION" assertEquals "Decrypt file using passphrase" "0" $? echo "Decrypt using passphrase file with cat --no-use-agent" - $CRYPT_TOOL --out "$TESTS_DIR/$CRYPT_TESTFILE" --no-use-agent --batch --yes --passphrase $(cat "$TESTS_DIR/$PASSFILE") --decrypt "$TESTS_DIR/$CRYPT_TESTFILE$CRYPT_EXTENSION" + $CRYPT_TOOL $options --out "$TESTS_DIR/$CRYPT_TESTFILE" --batch --yes $additionalParameters --passphrase $(cat "$TESTS_DIR/$PASSFILE") --decrypt "$TESTS_DIR/$CRYPT_TESTFILE$CRYPT_EXTENSION" assertEquals "Decrypt file using passphrase" "0" $? }