Skip to content

Commit cc32393

Browse files
redshiftzerokushaldas
authored andcommitted
test: regression coverage for defect #4294
Mock internal python-gnupg method to generate ValueError from the _handle_status method on DeleteResult
1 parent 3d6e6f7 commit cc32393

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

securedrop/tests/test_crypto_util.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,24 @@ def test_delete_reply_keypair(source_app, test_source):
268268
assert source_app.crypto_util.getkey(fid) is None
269269

270270

271+
def test_delete_reply_keypair_pinentry_status_is_handled(source_app, test_source,
272+
mocker, capsys):
273+
"""
274+
Regression test for https://github.com/freedomofpress/securedrop/issues/4294
275+
"""
276+
fid = test_source['filesystem_id']
277+
278+
# Patch private python-gnupg method to reproduce the issue in #4294
279+
mocker.patch('pretty_bad_protocol._util._separate_keyword',
280+
return_value=('PINENTRY_LAUNCHED', 'does not matter'))
281+
282+
source_app.crypto_util.delete_reply_keypair(fid)
283+
284+
captured = capsys.readouterr()
285+
assert "ValueError: Unknown status message: 'PINENTRY_LAUNCHED'" not in captured.err
286+
assert source_app.crypto_util.getkey(fid) is None
287+
288+
271289
def test_delete_reply_keypair_no_key(source_app):
272290
"""No exceptions should be raised when provided a filesystem id that
273291
does not exist.

0 commit comments

Comments
 (0)