Skip to content

Commit 606db60

Browse files
Cover the session group auth test helpers
The coverage gate counts tests. The auth handler repr was never called, and the in-process ASGI helpers had branches no HTTP request reaches. Co-authored-by: Michael <265398295+lafalce-assistant@users.noreply.github.com>
1 parent ff78bb6 commit 606db60

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎tests/client/test_session_group.py‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,6 @@ def _by_host(apps: dict[str, ASGIApp]) -> ASGIApp:
439439
"""
440440

441441
async def app(scope: Scope, receive: Receive, send: Send) -> None:
442-
if scope["type"] != "http":
443-
return
444442
host = next(value.decode("latin-1") for name, value in scope["headers"] if name == b"host")
445443
await apps[host.split(":", 1)[0]](scope, receive, send)
446444

@@ -449,10 +447,9 @@ async def app(scope: Scope, receive: Receive, send: Send) -> None:
449447

450448
def _recording_app(app: ASGIApp, authorizations: list[str | None], traces: list[str | None]) -> ASGIApp:
451449
async def wrapped(scope: Scope, receive: Receive, send: Send) -> None:
452-
if scope["type"] == "http":
453-
headers = {name.decode("latin-1").lower(): value.decode("latin-1") for name, value in scope["headers"]}
454-
authorizations.append(headers.get("authorization"))
455-
traces.append(headers.get("x-trace-id"))
450+
headers = {name.decode("latin-1").lower(): value.decode("latin-1") for name, value in scope["headers"]}
451+
authorizations.append(headers.get("authorization"))
452+
traces.append(headers.get("x-trace-id"))
456453
await app(scope, receive, send)
457454

458455
return wrapped
@@ -498,6 +495,8 @@ def test_http_parameters_omit_auth_from_serialization() -> None:
498495

499496
assert SseServerParameters(url="http://example.test/sse").auth is None
500497
assert StreamableHttpParameters(url="http://example.test/mcp").auth is None
498+
# The token is visible on the handler itself, so a leak into the parameters repr would fail below.
499+
assert repr(auth) == "_BearerAuth(secret-token)"
501500
for params in (sse, stream):
502501
assert params.auth is auth
503502
assert params.model_copy().auth is auth

0 commit comments

Comments
 (0)