Add @doktorstick's example code for reproducing Issue #93 as a test.

fix/94-encrypt-from-stream
Isis Lovecruft 2015-03-13 03:18:52 +00:00
parent 9d8d6cce5c
commit 38685ae001
No known key found for this signature in database
GPG Key ID: 18C16EC5F9F1D673
1 changed files with 16 additions and 1 deletions

View File

@ -1178,6 +1178,20 @@ know, maybe you shouldn't be doing it in the first place.
encrypted_message = fh.read()
log.debug("Encrypted file contains:\n\n%s\n" % encrypted_message)
def test_encryption_from_filehandle(self):
"""Test that ``encrypt(open('foo'), ...)`` is successful."""
message_filename = os.path.join(_files, 'cypherpunk_manifesto')
with open(message_filename, 'rb') as f:
kwargs = dict(passphrase='speedtest',
symmetric=True,
cipher_algo='AES256',
armor=False,
encrypt=False,
output='/tmp/purernd.enc.gnupg')
encrypted = self.gpg.encrypt(f, None, **kwargs)
self.assertTrue(encrypted.ok)
self.assertGreater(len(encrypted.data), 0)
suites = { 'parsers': set(['test_parsers_fix_unsafe',
'test_parsers_fix_unsafe_semicolon',
@ -1230,7 +1244,8 @@ suites = { 'parsers': set(['test_parsers_fix_unsafe',
'test_symmetric_encryption_and_decryption',
'test_file_encryption_and_decryption',
'test_encryption_to_filename',
'test_encryption_to_filehandle',]),
'test_encryption_to_filehandle',
'test_encryption_from_filehandle',]),
'listkeys': set(['test_list_keys_after_generation']),
'keyrings': set(['test_public_keyring',
'test_secret_keyring',