From 75d3b7abba57ed5099b302ccbba506d8f175bc9d Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Sun, 22 Jan 2023 11:26:26 +0100 Subject: openpgp: Allow verifying a subset of signatures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- tests/test_openpgp.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/test_openpgp.py') diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py index 6702471..22ef6cf 100644 --- a/tests/test_openpgp.py +++ b/tests/test_openpgp.py @@ -484,6 +484,38 @@ def test_verify_manifest(openpgp_env, manifest_var, key_var, expected): pytest.skip(str(e)) +def test_verify_one_out_of_two(): + try: + with MockedSystemGPGEnvironment() as openpgp_env: + with io.BytesIO(VALID_PUBLIC_KEY) as f: + openpgp_env.import_key(f) + + with io.StringIO(TWO_SIGNATURE_MANIFEST) as f: + sig = openpgp_env.verify_file(f, require_all_good=False) + + assert sig == [ + OpenPGPSignatureData( + fingerprint="81E12C16BD8DCD60BE180845136880E72A7B1384", + timestamp=datetime.datetime(2023, 1, 21, 17, 14, 44), + expire_timestamp=None, + primary_key_fingerprint="81E12C16BD8DCD60BE18" + "0845136880E72A7B1384", + sig_status=OpenPGPSignatureStatus.GOOD, + valid_sig=True, + trusted_sig=True), + OpenPGPSignatureData( + fingerprint="", + timestamp=None, + expire_timestamp=None, + primary_key_fingerprint="", + sig_status=OpenPGPSignatureStatus.NO_PUBLIC_KEY, + valid_sig=False, + trusted_sig=False), + ] + except OpenPGPNoImplementation as e: + pytest.skip(str(e)) + + def test_verify_untrusted_key(): try: with MockedSystemGPGEnvironment() as openpgp_env: -- cgit v1.2.3