Skip to content

Commit

Permalink
Test that TLSListener.handle_handshake_error logs the exception
Browse files Browse the repository at this point in the history
  • Loading branch information
gschaffner committed Aug 29, 2023
1 parent 5f208ee commit 40fd355
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/streams/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ async def test_default_context_ignore_unexpected_eof_flag_off(

class TestTLSListener:
@skip_on_broken_openssl
async def test_handshake_fail(self, server_context: ssl.SSLContext) -> None:
async def test_handshake_fail(
self, server_context: ssl.SSLContext, caplog: pytest.LogCaptureFixture
) -> None:
def handler(stream: object) -> NoReturn:
pytest.fail("This function should never be called in this scenario")

Expand All @@ -411,6 +413,13 @@ async def handle_handshake_error(
) -> None:
nonlocal exception
await TLSListener.handle_handshake_error(exc, stream)

# Regression test for #608.
assert len(caplog.records) == 1
logged_exc_info = caplog.records[0].exc_info
logged_exc = logged_exc_info[1] if logged_exc_info is not None else None
assert logged_exc is exc

assert isinstance(stream, SocketStream)
exception = exc
event.set()
Expand Down

0 comments on commit 40fd355

Please sign in to comment.