From c8acf77e04e10437d3eb22ed7fc90f4a0ae07e00 Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Sat, 8 Jul 2023 15:52:41 -0500 Subject: [PATCH] Adjust pinentry mock The new test Docker image has a newer gnupg which does not behave the same way, handling invalid passwords. This type of error is simulated using an ICP error in the pinentry protocol. --- test/pinentry-mock | 18 +++++++++++++----- test/test_encryption.py | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/test/pinentry-mock b/test/pinentry-mock index d40033b..39da043 100755 --- a/test/pinentry-mock +++ b/test/pinentry-mock @@ -1,12 +1,20 @@ #!/bin/bash # This program is a custom mock pinentry program -# It always uses whatever password is found in the /tmp directory -password="$(cat /tmp/mock-password 2>/dev/null)" +# It uses whatever password is found in the /tmp directory +# If the password is empty, replies CANCEL causing an error to similate invalid +# credentials echo "OK Pleased to meet you" while read -r line; do if [[ $line =~ GETPIN ]]; then - echo -n "D " - echo "$password" + password="$(cat /tmp/mock-password 2>/dev/null)" + if [ -n "$password" ]; then + echo -n "D " + echo "$password" + echo "OK"; + else + echo "CANCEL"; + fi + else + echo "OK"; fi - echo "OK"; done diff --git a/test/test_encryption.py b/test/test_encryption.py index 4868eb3..829ca1b 100644 --- a/test/test_encryption.py +++ b/test/test_encryption.py @@ -214,7 +214,7 @@ def test_symmetric_encrypt( if missing_encrypt: assert 'does not exist' in run.err elif bad_phrase: - assert 'Invalid passphrase' in run.err + assert 'Invalid IPC' in run.err else: assert encrypted_data_valid( runner, gnupg, paths.archive, encrypt_targets)