Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions jwks_client/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def issue_token(

def create_jwks_client(self) -> JWKSClient:
transport: typing.Final = httpx2.MockTransport(lambda _: httpx2.Response(200, json=self.jwks))
return JWKSClient(
self.jwks_uri, http_client=httpware.AsyncClient(httpx2_client=httpx2.AsyncClient(transport=transport))
)
return JWKSClient(self.jwks_uri, http_client=httpware.AsyncClient(transport=transport))


class StaticTokenVerifier:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ version = "0"
dependencies = [
# 2.15.1 carries the fixes for the 2026 advisories and binds a PyJWK's algorithm at verify time.
"pyjwt[crypto]>=2.15.1",
# 0.15.0 introduced max_response_body_bytes.
"httpware>=0.15.0,<1",
# 0.18.0 forwards transport= to the owned httpx2 client, which jwks_client.testing relies on.
"httpware>=0.18.0,<1",
"httpx2>=2.0.0,<3",
]

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def signing_key() -> SigningKey:

@pytest.fixture
def http_client(server: JWKSServer) -> httpware.AsyncClient:
return httpware.AsyncClient(httpx2_client=httpx2.AsyncClient(transport=httpx2.MockTransport(server.handle)))
return httpware.AsyncClient(transport=httpx2.MockTransport(server.handle))


@pytest.fixture
Expand Down
4 changes: 1 addition & 3 deletions tests/test_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ async def test_missing_or_invalid_token_is_unauthorized(verifier: JWTVerifier, t

async def test_unreachable_identity_provider_is_service_unavailable(idp: FakeIdentityProvider) -> None:
transport = httpx2.MockTransport(lambda _: httpx2.Response(HTTPStatus.BAD_GATEWAY))
jwks = JWKSClient(
idp.jwks_uri, http_client=httpware.AsyncClient(httpx2_client=httpx2.AsyncClient(transport=transport))
)
jwks = JWKSClient(idp.jwks_uri, http_client=httpware.AsyncClient(transport=transport))

response = await call(build_app(JWKSBearer(JWTVerifier(jwks, algorithms=["RS256"]))), idp.issue_token())

Expand Down
4 changes: 1 addition & 3 deletions tests/test_litestar.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ async def test_token_outside_policy_is_unauthorized(idp: FakeIdentityProvider, v

async def test_unreachable_identity_provider_is_service_unavailable(idp: FakeIdentityProvider) -> None:
transport = httpx2.MockTransport(lambda _: httpx2.Response(HTTPStatus.BAD_GATEWAY))
jwks = JWKSClient(
idp.jwks_uri, http_client=httpware.AsyncClient(httpx2_client=httpx2.AsyncClient(transport=transport))
)
jwks = JWKSClient(idp.jwks_uri, http_client=httpware.AsyncClient(transport=transport))
async with AsyncTestClient(build_app(JWTVerifier(jwks, algorithms=["RS256"]))) as client:
response = await client.get("/claims", headers={"Authorization": f"Bearer {idp.issue_token()}"})

Expand Down
Loading