diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-10-26 23:31:39 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-10-26 23:35:57 +0200 |
commit | 6ed742617a81ac4cbe9f21d3a246480f2b7fa277 (patch) | |
tree | a7df4789390d1ee7b40387ffeca8d21eba7fcc82 /tests/test_openpgp.py | |
parent | 9b7f95fe5a159aee6602fc37e34bba4581175f7b (diff) | |
download | gemato-6ed742617a81ac4cbe9f21d3a246480f2b7fa277.tar.gz |
recursiveloader: Support verifying Manifest signatures explicitly
Diffstat (limited to 'tests/test_openpgp.py')
-rw-r--r-- | tests/test_openpgp.py | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py index 9d37716..5d55565 100644 --- a/tests/test_openpgp.py +++ b/tests/test_openpgp.py @@ -4,10 +4,15 @@ # Licensed under the terms of 2-clause BSD license import io +import os.path +import shutil +import tempfile import unittest +import gemato.compression import gemato.manifest import gemato.openpgp +import gemato.recursiveloader PUBLIC_KEY = u''' @@ -192,6 +197,19 @@ class SignedManifestTest(unittest.TestCase): self.assertRaises(gemato.exceptions.ManifestSyntaxError, m.load, f, verify_openpgp=False) + def test_recursive_manifest_loader(self): + d = tempfile.mkdtemp() + try: + with io.open(os.path.join(d, 'Manifest'), 'w') as f: + f.write(MODIFIED_SIGNED_MANIFEST) + + m = gemato.recursiveloader.ManifestRecursiveLoader( + os.path.join(d, 'Manifest'), + verify_openpgp=False) + self.assertFalse(m.openpgp_signed) + finally: + shutil.rmtree(d) + class OpenPGPCorrectKeyTest(unittest.TestCase): """ @@ -246,6 +264,35 @@ class OpenPGPCorrectKeyTest(unittest.TestCase): self.assertRaises(gemato.exceptions.OpenPGPVerificationFailure, m.load, f, openpgp_env=self.env) + def test_recursive_manifest_loader(self): + d = tempfile.mkdtemp() + try: + with io.open(os.path.join(d, 'Manifest'), 'w') as f: + f.write(SIGNED_MANIFEST) + + m = gemato.recursiveloader.ManifestRecursiveLoader( + os.path.join(d, 'Manifest'), + verify_openpgp=True, + openpgp_env=self.env) + self.assertTrue(m.openpgp_signed) + finally: + shutil.rmtree(d) + + def test_recursive_manifest_loader_compressed(self): + d = tempfile.mkdtemp() + try: + with gemato.compression.open_potentially_compressed_path( + os.path.join(d, 'Manifest.gz'), 'w') as cf: + cf.write(SIGNED_MANIFEST) + + m = gemato.recursiveloader.ManifestRecursiveLoader( + os.path.join(d, 'Manifest.gz'), + verify_openpgp=True, + openpgp_env=self.env) + self.assertTrue(m.openpgp_signed) + finally: + shutil.rmtree(d) + class OpenPGPNoKeyTest(unittest.TestCase): """ @@ -291,6 +338,35 @@ class OpenPGPNoKeyTest(unittest.TestCase): self.assertIsNotNone(m.find_path_entry('myebuild-0.ebuild')) self.assertFalse(m.openpgp_signed) + def test_recursive_manifest_loader(self): + d = tempfile.mkdtemp() + try: + with io.open(os.path.join(d, 'Manifest'), 'w') as f: + f.write(SIGNED_MANIFEST) + + self.assertRaises(gemato.exceptions.OpenPGPVerificationFailure, + gemato.recursiveloader.ManifestRecursiveLoader, + os.path.join(d, 'Manifest'), + verify_openpgp=True, + openpgp_env=self.env) + finally: + shutil.rmtree(d) + + def test_recursive_manifest_loader_compressed(self): + d = tempfile.mkdtemp() + try: + with gemato.compression.open_potentially_compressed_path( + os.path.join(d, 'Manifest.gz'), 'w') as cf: + cf.write(SIGNED_MANIFEST) + + self.assertRaises(gemato.exceptions.OpenPGPVerificationFailure, + gemato.recursiveloader.ManifestRecursiveLoader, + os.path.join(d, 'Manifest.gz'), + verify_openpgp=True, + openpgp_env=self.env) + finally: + shutil.rmtree(d) + class OpenPGPContextManagerTest(unittest.TestCase): """ |