Add two more signature passphrase tests with bytes literals for #82.
parent
e90ae54738
commit
9be01ec6df
|
@ -641,6 +641,36 @@ class GPGTestCase(unittest.TestCase):
|
||||||
self.assertTrue(sig)
|
self.assertTrue(sig)
|
||||||
self.assertTrue(message in str(sig))
|
self.assertTrue(message in str(sig))
|
||||||
|
|
||||||
|
def test_signature_string_passphrase_empty_bytes_literal(self):
|
||||||
|
"""Test that a signing attempt with passphrase=b'' creates a valid
|
||||||
|
signature.
|
||||||
|
|
||||||
|
See Issue #82: https://github.com/isislovecruft/python-gnupg/issues/82
|
||||||
|
"""
|
||||||
|
with open(os.path.join(_files, 'test_key_1.sec')) as fh1:
|
||||||
|
res1 = self.gpg.import_keys(fh1.read())
|
||||||
|
key1 = res1.fingerprints[0]
|
||||||
|
|
||||||
|
message = 'abc\ndef\n'
|
||||||
|
sig = self.gpg.sign(message, default_key=key1, passphrase=b'')
|
||||||
|
self.assertTrue(sig)
|
||||||
|
print("%r" % str(sig))
|
||||||
|
self.assertTrue(message in str(sig))
|
||||||
|
|
||||||
|
def test_signature_string_passphrase_bytes_literal(self):
|
||||||
|
"""Test that a signing attempt with passphrase=b'overalls' creates a
|
||||||
|
valid signature.
|
||||||
|
"""
|
||||||
|
with open(os.path.join(_files, 'kat.sec')) as fh1:
|
||||||
|
res1 = self.gpg.import_keys(fh1.read())
|
||||||
|
key1 = res1.fingerprints[0]
|
||||||
|
|
||||||
|
message = 'abc\ndef\n'
|
||||||
|
sig = self.gpg.sign(message, default_key=key1, passphrase=b'overalls')
|
||||||
|
self.assertTrue(sig)
|
||||||
|
print("%r" % str(sig))
|
||||||
|
self.assertTrue(message in str(sig))
|
||||||
|
|
||||||
def test_signature_string_passphrase_None(self):
|
def test_signature_string_passphrase_None(self):
|
||||||
"""Test that a signing attempt with passphrase=None fails creates a
|
"""Test that a signing attempt with passphrase=None fails creates a
|
||||||
valid signature.
|
valid signature.
|
||||||
|
@ -1370,6 +1400,8 @@ suites = { 'parsers': set(['test_parsers_fix_unsafe',
|
||||||
'test_signature_verification_detached_binary',
|
'test_signature_verification_detached_binary',
|
||||||
'test_signature_file',
|
'test_signature_file',
|
||||||
'test_signature_string_passphrase_empty_string',
|
'test_signature_string_passphrase_empty_string',
|
||||||
|
'test_signature_string_passphrase_empty_bytes_literal',
|
||||||
|
'test_signature_string_passphrase_bytes_literal',
|
||||||
'test_signature_string_passphrase_None',
|
'test_signature_string_passphrase_None',
|
||||||
'test_signature_string_bad_passphrase',
|
'test_signature_string_bad_passphrase',
|
||||||
'test_signature_string_verification',
|
'test_signature_string_verification',
|
||||||
|
|
Loading…
Reference in New Issue