From 0a95b33a5918d16450b51c2f046313cfd8771a81 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Sat, 5 Sep 2020 15:15:32 +0200 Subject: openpgp: Move listing keys to a separate method 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/test_openpgp.py') diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py index 5ee86aa..edeb0b9 100644 --- a/tests/test_openpgp.py +++ b/tests/test_openpgp.py @@ -642,6 +642,22 @@ def test_recursive_manifest_loader_save_submanifest(tmp_path, privkey_env): assert m2.openpgp_signature is None +@pytest.mark.parametrize( + 'key_var,expected', + [('VALID_PUBLIC_KEY', {KEY_FINGERPRINT: ['gemato@example.com']}), + ('OTHER_VALID_PUBLIC_KEY', + {OTHER_KEY_FINGERPRINT: ['gemato@example.com']}), + ('VALID_KEY_SUBKEY', {KEY_FINGERPRINT: ['gemato@example.com']}), + ('VALID_KEY_NOEMAIL', {KEY_FINGERPRINT: []}), + ]) +def test_list_keys(openpgp_env_with_refresh, key_var, expected): + try: + openpgp_env_with_refresh.import_key(io.BytesIO(globals()[key_var])) + except OpenPGPNoImplementation as e: + pytest.skip(str(e)) + assert openpgp_env_with_refresh.list_keys() == expected + + @pytest.fixture(scope='module') def global_hkp_server(): """A fixture that starts a single HKP server instance for tests""" -- cgit v1.2.3