]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
tests/pytests: remove deprecated calls
authorOto Šťáva <oto.stava@nic.cz>
Mon, 6 May 2024 11:35:02 +0000 (13:35 +0200)
committerOto Šťáva <oto.stava@nic.cz>
Mon, 13 May 2024 13:09:21 +0000 (15:09 +0200)
tests/pytests/conftest.py
tests/pytests/test_tls.py
tests/pytests/utils.py

index 4c711f84795bc410531c5e54dde0043fee220b04..fcf4b05f6a0a9f31fe71bc5cea77216e9f029b7b 100644 (file)
@@ -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():
index 3e1328ab1d3e0507a20bcc8e363d93a79d4477c3..7f5fa42fb7289123e8f0a9d09816cc8bd8e48d72 100644 (file)
@@ -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
 
index 4b995d4bba51aa396a65c46d50547455927d328f..7792c047c1607aaa3af30bb4f940e01d412d2fc4 100644 (file)
@@ -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