diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-10-25 14:03:19 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-10-25 14:03:19 +0200 |
commit | 5c5289c8810fd66867d890cf170d80997496203a (patch) | |
tree | 8171502872f07f47508c826620c571f9cc66459f /tests | |
parent | 307f382033631dc9668c4d5a331acc16b6e66d7a (diff) | |
download | gemato-5c5289c8810fd66867d890cf170d80997496203a.tar.gz |
openpgp: Fix and test the context manager API
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_openpgp.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py index dc2eafc..88b105b 100644 --- a/tests/test_openpgp.py +++ b/tests/test_openpgp.py @@ -202,3 +202,23 @@ class OpenPGPNoKeyTest(unittest.TestCase): self.env.verify_file, f) except gemato.exceptions.OpenPGPNoImplementation as e: raise unittest.SkipTest(str(e)) + + +class OpenPGPContextManagerTest(unittest.TestCase): + """ + Test the context manager API for OpenPGPEnvironment. + """ + + def test_verify_manifest(self): + with io.BytesIO(SIGNED_MANIFEST.encode('utf8')) as f: + with gemato.openpgp.OpenPGPEnvironment() as env: + try: + try: + env.import_key( + io.BytesIO(PUBLIC_KEY.encode('utf8'))) + except RuntimeError: + raise unittest.SkipTest('Unable to import OpenPGP key') + + env.verify_file(f) + except gemato.exceptions.OpenPGPNoImplementation as e: + raise unittest.SkipTest(str(e)) |