FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.8] gh-108310: Fix TestPreHandshakeClose tests in test_ssl by frenzymadness · Pull Request #110718 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 9 additions & 6 deletions Lib/test/test_ssl.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def data_file(*name):
OP_ENABLE_MIDDLEBOX_COMPAT = getattr(ssl, "OP_ENABLE_MIDDLEBOX_COMPAT", 0)
OP_IGNORE_UNEXPECTED_EOF = getattr(ssl, "OP_IGNORE_UNEXPECTED_EOF", 0)

# *_TIMEOUT constants are available in test.support in 3.9+
SHORT_TIMEOUT = 30.0

# Ubuntu has patched OpenSSL and changed behavior of security level 2
# see https://bugs.python.org/issue41561#msg389003
def is_ubuntu():
Expand Down Expand Up @@ -4835,7 +4838,7 @@ def __init__(self, *, name, call_after_accept, timeout=None):
self.listener = None # set by .start()
self.port = None # set by .start()
if timeout is None:
self.timeout = support.SHORT_TIMEOUT
self.timeout = SHORT_TIMEOUT
else:
self.timeout = timeout
super().__init__(name=name)
Expand Down Expand Up @@ -4917,7 +4920,7 @@ def test_preauth_data_to_tls_server(self):

def call_after_accept(unused):
server_accept_called.set()
if not ready_for_server_wrap_socket.wait(support.SHORT_TIMEOUT):
if not ready_for_server_wrap_socket.wait(SHORT_TIMEOUT):
raise RuntimeError("wrap_socket event never set, test may fail.")
return False # Tell the server thread to continue.

Expand Down Expand Up @@ -4961,7 +4964,7 @@ def test_preauth_data_to_tls_client(self):
client_can_continue_with_wrap_socket = threading.Event()

def call_after_accept(conn_to_client):
if not server_can_continue_with_wrap_socket.wait(support.SHORT_TIMEOUT):
if not server_can_continue_with_wrap_socket.wait(SHORT_TIMEOUT):
print("ERROR: test client took too long")

# This forces an immediate connection close via RST on .close().
Expand All @@ -4987,7 +4990,7 @@ def call_after_accept(conn_to_client):
client.connect(server.listener.getsockname())
server_can_continue_with_wrap_socket.set()

if not client_can_continue_with_wrap_socket.wait(support.SHORT_TIMEOUT):
if not client_can_continue_with_wrap_socket.wait(SHORT_TIMEOUT):
self.fail("test server took too long")
ssl_ctx = ssl.create_default_context()
try:
Expand Down Expand Up @@ -5026,7 +5029,7 @@ def connect(self):
http.client.HTTPConnection.connect(self)

# Wait for our fault injection server to have done its thing.
if not server_responding.wait(support.SHORT_TIMEOUT) and support.verbose:
if not server_responding.wait(SHORT_TIMEOUT) and support.verbose:
sys.stdout.write("server_responding event never set.")
self.sock = self._context.wrap_socket(
self.sock, server_hostname=self.host)
Expand Down Expand Up @@ -5104,7 +5107,7 @@ def test_main(verbose=False):
tests = [
ContextTests, BasicSocketTests, SSLErrorTests, MemoryBIOTests,
SSLObjectTests, SimpleBackgroundTests, ThreadedTests,
TestPostHandshakeAuth, TestSSLDebug
TestPostHandshakeAuth, TestSSLDebug, TestPreHandshakeClose
]

if support.is_resource_enabled('network'):
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SSL tests for pre-handshake close were previously not enabled on Python 3.8
due to an incorrect backport. This is now fixed. Patch by Lumír Balhar.

Back | FazBrowse Home | New Git URL