mirror of
https://github.com/python/cpython.git
synced 2025-09-20 07:31:10 +00:00
bpo-31870: Fix test_get_server_certificate_timeout on Windows (GH-25570)
Some OS do not support millisecond granularity in select(). Use 100ms timeout and a server callback with sleep to emulate a slow server.
This commit is contained in:
parent
b2fac1afaa
commit
f05c2aed7e
1 changed files with 5 additions and 1 deletions
|
@ -2137,9 +2137,13 @@ class SimpleBackgroundTests(unittest.TestCase):
|
||||||
_test_get_server_certificate_fail(self, *self.server_addr)
|
_test_get_server_certificate_fail(self, *self.server_addr)
|
||||||
|
|
||||||
def test_get_server_certificate_timeout(self):
|
def test_get_server_certificate_timeout(self):
|
||||||
|
def servername_cb(ssl_sock, server_name, initial_context):
|
||||||
|
time.sleep(0.2)
|
||||||
|
self.server_context.set_servername_callback(servername_cb)
|
||||||
|
|
||||||
with self.assertRaises(socket.timeout):
|
with self.assertRaises(socket.timeout):
|
||||||
ssl.get_server_certificate(self.server_addr, ca_certs=SIGNING_CA,
|
ssl.get_server_certificate(self.server_addr, ca_certs=SIGNING_CA,
|
||||||
timeout=0.0001)
|
timeout=0.1)
|
||||||
|
|
||||||
def test_ciphers(self):
|
def test_ciphers(self):
|
||||||
with test_wrap_socket(socket.socket(socket.AF_INET),
|
with test_wrap_socket(socket.socket(socket.AF_INET),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue