porchlight/tests/test_oidc/test_discovery.py

34 lines
1.1 KiB
Python

from httpx import AsyncClient
async def test_discovery_endpoint_returns_metadata(client: AsyncClient) -> None:
res = await client.get("/.well-known/openid-configuration")
assert res.status_code == 200
data = res.json()
assert data["issuer"] == "http://localhost:8000"
assert "authorization_endpoint" in data
assert "token_endpoint" in data
assert "userinfo_endpoint" in data
assert "jwks_uri" in data
async def test_discovery_response_types_supported(client: AsyncClient) -> None:
res = await client.get("/.well-known/openid-configuration")
data = res.json()
assert "code" in data["response_types_supported"]
async def test_discovery_scopes_supported(client: AsyncClient) -> None:
res = await client.get("/.well-known/openid-configuration")
data = res.json()
assert "openid" in data["scopes_supported"]
async def test_jwks_endpoint_returns_keys(client: AsyncClient) -> None:
res = await client.get("/jwks")
assert res.status_code == 200
data = res.json()
assert "keys" in data
assert len(data["keys"]) > 0
for key in data["keys"]:
assert "kty" in key