summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2023-01-22 20:09:49 +0100
committerMichał Górny <mgorny@gentoo.org>2023-01-22 20:09:49 +0100
commit9c1a7fe51cfec3a80f7783b20d5daec18842bf72 (patch)
tree31199e09e1376271ee0c5c67838c11dfab3052a3
parent5dff168a23b0d70464cabefedb64b82fdf6b1714 (diff)
downloadgemato-9c1a7fe51cfec3a80f7783b20d5daec18842bf72.tar.gz
tests: Extend test_verify_detached() to 1-out-of-2 case
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r--tests/test_openpgp.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py
index 17ef8f2..2fe5b42 100644
--- a/tests/test_openpgp.py
+++ b/tests/test_openpgp.py
@@ -1100,10 +1100,15 @@ def test_verify_require_secure_cli(base_tree, caplog, require_secure):
assert str(ManifestInsecureHashes(["MD5"])) in caplog.text
-def test_verify_detached(tmp_path):
+@pytest.mark.parametrize(
+ "key_var,two_sigs",
+ [("TWO_SIGNATURE_PUBLIC_KEYS", True),
+ ("VALID_PUBLIC_KEY", False),
+ ])
+def test_verify_detached(tmp_path, key_var, two_sigs):
try:
with MockedSystemGPGEnvironment() as openpgp_env:
- with io.BytesIO(TWO_SIGNATURE_PUBLIC_KEYS) as f:
+ with io.BytesIO(globals()[key_var]) as f:
openpgp_env.import_key(f)
with open(tmp_path / "data.bin", "wb") as f:
@@ -1114,8 +1119,9 @@ def test_verify_detached(tmp_path):
sig = openpgp_env.verify_detached(
tmp_path / "sig.bin", tmp_path / "data.bin",
- require_all_good=False)
+ require_all_good=two_sigs)
- assert_signature(sig, "TWO_SIGNATURE_MANIFEST")
+ assert_signature(sig, "TWO_SIGNATURE_MANIFEST",
+ expect_both=two_sigs)
except OpenPGPNoImplementation as e:
pytest.skip(str(e))