(self)
| 456 | self.loop.run_until_complete(client(srv.addr)) |
| 457 | |
| 458 | def test_ssl_handshake_timeout(self): |
| 459 | # bpo-29970: Check that a connection is aborted if handshake is not |
| 460 | # completed in timeout period, instead of remaining open indefinitely |
| 461 | client_sslctx = test_utils.simple_client_sslcontext() |
| 462 | |
| 463 | # silence error logger |
| 464 | messages = [] |
| 465 | self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx)) |
| 466 | |
| 467 | server_side_aborted = False |
| 468 | |
| 469 | def server(sock): |
| 470 | nonlocal server_side_aborted |
| 471 | try: |
| 472 | sock.recv_all(1024 * 1024) |
| 473 | except ConnectionAbortedError: |
| 474 | server_side_aborted = True |
| 475 | finally: |
| 476 | sock.close() |
| 477 | |
| 478 | async def client(addr): |
| 479 | await asyncio.wait_for( |
| 480 | self.loop.create_connection( |
| 481 | asyncio.Protocol, |
| 482 | *addr, |
| 483 | ssl=client_sslctx, |
| 484 | server_hostname='', |
| 485 | ssl_handshake_timeout=10.0), |
| 486 | 0.5) |
| 487 | |
| 488 | with self.tcp_server(server, |
| 489 | max_clients=1, |
| 490 | backlog=1) as srv: |
| 491 | |
| 492 | with self.assertRaises(asyncio.TimeoutError): |
| 493 | self.loop.run_until_complete(client(srv.addr)) |
| 494 | |
| 495 | self.assertTrue(server_side_aborted) |
| 496 | |
| 497 | # Python issue #23197: cancelling a handshake must not raise an |
| 498 | # exception or log an error, even if the handshake failed |
| 499 | self.assertEqual(messages, []) |
| 500 | |
| 501 | def test_ssl_handshake_connection_lost(self): |
| 502 | # #246: make sure that no connection_lost() is called before |
nothing calls this directly
no test coverage detected