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.
This commit is contained in:
Tim Byrne 2023-07-08 15:52:41 -05:00
parent 9752d801ae
commit c8acf77e04
No known key found for this signature in database
GPG Key ID: 14DB4FC2465A4B12
2 changed files with 14 additions and 6 deletions

View File

@ -1,12 +1,20 @@
#!/bin/bash #!/bin/bash
# This program is a custom mock pinentry program # This program is a custom mock pinentry program
# It always uses whatever password is found in the /tmp directory # It uses whatever password is found in the /tmp directory
password="$(cat /tmp/mock-password 2>/dev/null)" # If the password is empty, replies CANCEL causing an error to similate invalid
# credentials
echo "OK Pleased to meet you" echo "OK Pleased to meet you"
while read -r line; do while read -r line; do
if [[ $line =~ GETPIN ]]; then if [[ $line =~ GETPIN ]]; then
echo -n "D " password="$(cat /tmp/mock-password 2>/dev/null)"
echo "$password" if [ -n "$password" ]; then
echo -n "D "
echo "$password"
echo "OK";
else
echo "CANCEL";
fi
else
echo "OK";
fi fi
echo "OK";
done done

View File

@ -214,7 +214,7 @@ def test_symmetric_encrypt(
if missing_encrypt: if missing_encrypt:
assert 'does not exist' in run.err assert 'does not exist' in run.err
elif bad_phrase: elif bad_phrase:
assert 'Invalid passphrase' in run.err assert 'Invalid IPC' in run.err
else: else:
assert encrypted_data_valid( assert encrypted_data_valid(
runner, gnupg, paths.archive, encrypt_targets) runner, gnupg, paths.archive, encrypt_targets)