python/tests: try to decrypt and verify new test data

* lang/python/tests/t-decrypt.py: test decryption of cipher-3.asc and
cipher-no-sig.asc
* lang/python/tests/t-decrypt-verify.py: test decryption and
verification of cipher-3.asc and cipher-no-sig.asc

--

note that this introduces a failed test -- decrypt-verify.py
misbehaves on cipher-3.asc by throwing a BadSignature even though

GnuPG-bug-id: 4276
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
This commit is contained in:
Daniel Kahn Gillmor 2019-05-02 22:16:51 -04:00
parent c5c3a9d10b
commit bd2d282e57
2 changed files with 21 additions and 0 deletions

View File

@ -75,3 +75,14 @@ with gpg.Context() as c:
assert e.missing[0] == bob assert e.missing[0] == bob
else: else:
assert False, "Expected an error, got none" assert False, "Expected an error, got none"
plaintext, _, verify_result = c.decrypt(open(support.make_filename("cipher-no-sig.asc")))
assert len(plaintext) > 0
assert len(verify_result.signatures) == 0
assert plaintext.find(b'Viscosity Dispersal Thimble Saturday Flaxseed Deflected') >= 0, \
'unsigned Plaintext was not found'
plaintext, _, verify_result = c.decrypt(open(support.make_filename("cipher-3.asc")))
assert len(plaintext) > 0
assert plaintext.find(b'Reenact Studied Thermos Bonehead Unclasp Opposing') >= 0, \
'second Plaintext not found'

View File

@ -42,3 +42,13 @@ with gpg.Context() as c:
assert len(plaintext) > 0 assert len(plaintext) > 0
assert plaintext.find(b'Wenn Sie dies lesen k') >= 0, \ assert plaintext.find(b'Wenn Sie dies lesen k') >= 0, \
'Plaintext not found' 'Plaintext not found'
plaintext, _, _ = c.decrypt(open(support.make_filename("cipher-3.asc")), verify=False)
assert len(plaintext) > 0
assert plaintext.find(b'Reenact Studied Thermos Bonehead Unclasp Opposing') >= 0, \
'second Plaintext not found'
plaintext, _, _ = c.decrypt(open(support.make_filename("cipher-no-sig.asc")), verify=False)
assert len(plaintext) > 0
assert plaintext.find(b'Viscosity Dispersal Thimble Saturday Flaxseed Deflected') >= 0, \
'third Plaintext was not found'