diff options
author | Michał Górny <mgorny@gentoo.org> | 2020-10-01 13:34:55 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2020-10-01 13:34:55 +0200 |
commit | ce683786ce6ad9d0f5723b4438bb9054f4a49d77 (patch) | |
tree | 5f9498a834549d1680750761f6eb64e5c85a23b0 /tests/test_openpgp.py | |
parent | 9840187c10dcac5953daa0b2b419a86e633d7a22 (diff) | |
download | gemato-ce683786ce6ad9d0f5723b4438bb9054f4a49d77.tar.gz |
openpgp: Fix handling connection errors in WKD refresh
Bug: https://bugs.gentoo.org/745771
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'tests/test_openpgp.py')
-rw-r--r-- | tests/test_openpgp.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py index 6bce97d..c57a612 100644 --- a/tests/test_openpgp.py +++ b/tests/test_openpgp.py @@ -5,6 +5,7 @@ import datetime import io +import logging import os import shlex import signal @@ -875,22 +876,26 @@ def test_refresh_wkd(openpgp_env_with_refresh, pytest.skip(str(e)) +@pytest.mark.parametrize('status', [401, 404, 500, ConnectionError]) def test_refresh_wkd_fallback_to_hkp(openpgp_env_with_refresh, - hkp_server): + hkp_server, caplog, status): """Test whether WKD refresh failure falls back to HKP""" with pytest.importorskip('responses').RequestsMock() as responses: try: with io.BytesIO(VALID_PUBLIC_KEY) as f: openpgp_env_with_refresh.import_key(f) hkp_server.keys[KEY_FINGERPRINT] = REVOKED_PUBLIC_KEY - responses.add( - responses.GET, - 'https://example.com/.well-known/openpgpkey/hu/' - '5x66h616iaskmnadrm86ndo6xnxbxjxb?l=gemato', - status=404) + if status is not ConnectionError: + responses.add( + responses.GET, + 'https://example.com/.well-known/openpgpkey/hu/' + '5x66h616iaskmnadrm86ndo6xnxbxjxb?l=gemato', + status=status) + caplog.set_level(logging.DEBUG) openpgp_env_with_refresh.refresh_keys( allow_wkd=True, keyserver=hkp_server.addr) + assert 'failing due to failed request' in caplog.text with pytest.raises(OpenPGPRevokedKeyFailure): with io.StringIO(SIGNED_MANIFEST) as f: |