Skip to content

Commit 29e499d

Browse files
author
Jianke LIN
committed
test(auth): use httpx2 in streamable HTTP auth test
1 parent e3088cc commit 29e499d

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

tests/server/auth/test_get_access_token_streamable_http.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time
22

3-
import httpx
3+
import httpx2
44
import pytest
55
from mcp_types import (
66
CallToolRequestParams,
@@ -41,11 +41,11 @@ async def _handle_list_tools(ctx: ServerRequestContext, params: PaginatedRequest
4141
return ListToolsResult(tools=[Tool(name="whoami", input_schema={"type": "object", "properties": {}})])
4242

4343

44-
class _MutableBearerAuth(httpx.Auth):
44+
class _MutableBearerAuth(httpx2.Auth):
4545
def __init__(self, token: str | None) -> None:
4646
self.token = token
4747

48-
def auth_flow(self, request: httpx.Request):
48+
def auth_flow(self, request: httpx2.Request):
4949
if self.token is not None:
5050
request.headers["Authorization"] = f"Bearer {self.token}"
5151
yield request
@@ -54,12 +54,12 @@ def auth_flow(self, request: httpx.Request):
5454
async def _call_whoami(asgi_app: Starlette, host: str, token: str | None) -> str:
5555
auth = _MutableBearerAuth(token)
5656
async with (
57-
httpx.ASGITransport(asgi_app) as transport,
58-
httpx.AsyncClient(
57+
httpx2.ASGITransport(asgi_app) as transport,
58+
httpx2.AsyncClient(
5959
transport=transport,
6060
base_url=f"http://{host}",
6161
auth=auth,
62-
timeout=httpx.Timeout(30, read=30),
62+
timeout=httpx2.Timeout(30, read=30),
6363
follow_redirects=True,
6464
) as http_client,
6565
):

0 commit comments

Comments
 (0)