Replace httpx and httpx-sse with httpx2 (#2972)
Some checks failed
CI / checks (push) Has been cancelled
CI / all-green (push) Has been cancelled

Co-authored-by: Max Isbey <224885523+maxisbey@users.noreply.github.com>
This commit is contained in:
Marcelo Trylesinski 2026-07-14 18:05:08 +02:00 • committed by GitHub
commit 2713b53b12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,7 +6,7 @@ in the WWW-Authenticate header, the actual scope is used (not the resource_metad
from unittest import mock
import httpx
import httpx2
import pytest
from pydantic import AnyUrl
@ -79,7 +79,7 @@ async def test_401_uses_www_auth_scope_not_resource_metadata_url():
redirect_uris=[AnyUrl("http://localhost:3030/callback")],
)
test_request = httpx.Request("GET", "https://api.example.com/mcp")
test_request = httpx2.Request("GET", "https://api.example.com/mcp")
auth_flow = provider.async_auth_flow(test_request)
# First request (no auth header yet)
@ -90,7 +90,7 @@ async def test_401_uses_www_auth_scope_not_resource_metadata_url():
resource_metadata_url = "https://api.example.com/.well-known/oauth-protected-resource"
expected_scope = "read write"
response_401 = httpx.Response(
response_401 = httpx2.Response(
401,
headers={"WWW-Authenticate": (f'Bearer resource_metadata="{resource_metadata_url}", scope="{expected_scope}"')},
request=test_request,
@ -101,7 +101,7 @@ async def test_401_uses_www_auth_scope_not_resource_metadata_url():
assert ".well-known/oauth-protected-resource" in str(prm_request.url)
# PRM response with scopes_supported (these should be overridden by WWW-Auth scope)
prm_response = httpx.Response(
prm_response = httpx2.Response(
200,
content=(
b'{"resource": "https://api.example.com/mcp", '
@ -116,7 +116,7 @@ async def test_401_uses_www_auth_scope_not_resource_metadata_url():
assert ".well-known/oauth-authorization-server" in str(oauth_metadata_request.url)
# OAuth metadata response
oauth_metadata_response = httpx.Response(
oauth_metadata_response = httpx2.Response(
200,
content=(
b'{"issuer": "https://auth.example.com", '
@ -152,7 +152,7 @@ async def test_401_uses_www_auth_scope_not_resource_metadata_url():
)
# Complete the flow to properly release the lock
token_response = httpx.Response(
token_response = httpx2.Response(
200,
content=b'{"access_token": "test_token", "token_type": "Bearer", "expires_in": 3600}',
request=token_request,
@ -162,7 +162,7 @@ async def test_401_uses_www_auth_scope_not_resource_metadata_url():
assert final_request.headers["Authorization"] == "Bearer test_token"
# Finish the flow
final_response = httpx.Response(200, request=final_request)
final_response = httpx2.Response(200, request=final_request)
try:
await auth_flow.asend(final_response)
except StopAsyncIteration: