Skip to content

Commit

Permalink
test: regression coverage for defect freedomofpress#4294
Browse files Browse the repository at this point in the history
Mock internal python-gnupg method to generate ValueError from
the _handle_status method on DeleteResult
  • Loading branch information
redshiftzero committed Apr 23, 2019
1 parent 745ca50 commit 16ec570
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions securedrop/tests/test_crypto_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,24 @@ def test_delete_reply_keypair(source_app, test_source):
assert source_app.crypto_util.getkey(fid) is None


def test_delete_reply_keypair_pinentry_status_is_handled(source_app, test_source,
mocker, capsys):
"""
Regression test for https://github.com/freedomofpress/securedrop/issues/4294
"""
fid = test_source['filesystem_id']

# Patch private python-gnupg method to reproduce the issue in #4294
mocker.patch('pretty_bad_protocol._util._separate_keyword',
return_value=('PINENTRY_LAUNCHED', 'does not matter'))

source_app.crypto_util.delete_reply_keypair(fid)

captured = capsys.readouterr()
assert "ValueError: Unknown status message: 'PINENTRY_LAUNCHED'" not in captured.err
assert source_app.crypto_util.getkey(fid) is None


def test_delete_reply_keypair_no_key(source_app):
"""No exceptions should be raised when provided a filesystem id that
does not exist.
Expand Down

0 comments on commit 16ec570

Please sign in to comment.