From: Oto Šťáva Date: Mon, 6 May 2024 11:35:02 +0000 (+0200) Subject: tests/pytests: remove deprecated calls X-Git-Tag: v5.7.3~5^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c5949d8e0e767569ad4e4572db19bd117c9eb28;p=thirdparty%2Fknot-resolver.git tests/pytests: remove deprecated calls --- diff --git a/tests/pytests/conftest.py b/tests/pytests/conftest.py index 4c711f847..fcf4b05f6 100644 --- a/tests/pytests/conftest.py +++ b/tests/pytests/conftest.py @@ -86,7 +86,7 @@ def query_before(request): # whether to send an initial query return request.param -@pytest.mark.optionalhook +@pytest.hookimpl(optionalhook=True) def pytest_metadata(metadata): # filter potentially sensitive data from GitLab CI keys_to_delete = [] for key in metadata.keys(): diff --git a/tests/pytests/test_tls.py b/tests/pytests/test_tls.py index 3e1328ab1..7f5fa42fb 100644 --- a/tests/pytests/test_tls.py +++ b/tests/pytests/test_tls.py @@ -73,7 +73,7 @@ def test_tls_session_resumption(tmpdir, sf1, sf2, sf3): with make_kresd(workdir, 'tt') as kresd: ctx = utils.make_ssl_context( - verify_location=kresd.tls_cert_path, extra_options=[ssl.OP_NO_TLSv1_3]) + verify_location=kresd.tls_cert_path, maximum_tls=ssl.TLSVersion.TLSv1_2) session = connect(kresd, ctx, sf1) # initial conn connect(kresd, ctx, sf2, session) # resume session on the same instance diff --git a/tests/pytests/utils.py b/tests/pytests/utils.py index 4b995d4bb..7792c047c 100644 --- a/tests/pytests/utils.py +++ b/tests/pytests/utils.py @@ -110,17 +110,12 @@ def expect_kresd_close(rst_ok=False): pytest.fail("kresd didn't close the connection") -def make_ssl_context(insecure=False, verify_location=None, extra_options=None): - # set TLS v1.2+ - context = ssl.SSLContext(ssl.PROTOCOL_TLS) - context.options |= ssl.OP_NO_SSLv2 - context.options |= ssl.OP_NO_SSLv3 - context.options |= ssl.OP_NO_TLSv1 - context.options |= ssl.OP_NO_TLSv1_1 - - if extra_options is not None: - for option in extra_options: - context.options |= option +def make_ssl_context(insecure=False, verify_location=None, + minimum_tls=ssl.TLSVersion.TLSv1_2, + maximum_tls=ssl.TLSVersion.MAXIMUM_SUPPORTED): + context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) + context.minimum_version = minimum_tls + context.maximum_version = maximum_tls if insecure: # turn off certificate verification