40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
"""Read-only OIDC smoke: disposable Docker network only; not a login E2E."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
from urllib.parse import urlparse
|
|
from urllib.request import Request, urlopen
|
|
|
|
PROXY = os.environ.get("ZITPLANE_CI_PROXY", "http://proxy")
|
|
EXPECTED_ISSUER = "http://localhost:8080"
|
|
HOST = "localhost:8080"
|
|
|
|
def fetch(path: str):
|
|
request = Request(PROXY + path, headers={"Host": HOST, "Accept": "application/json"})
|
|
with urlopen(request, timeout=20) as reply:
|
|
if reply.status != 200:
|
|
raise RuntimeError(f"HTTP {reply.status}: {path}")
|
|
return reply.read()
|
|
|
|
def main() -> None:
|
|
fetch("/debug/ready")
|
|
print("ZITPLANE_BACKEND_READY_PASS")
|
|
discovery = json.loads(fetch("/.well-known/openid-configuration"))
|
|
if discovery.get("issuer") != EXPECTED_ISSUER:
|
|
raise RuntimeError("OIDC issuer does not match local dev origin")
|
|
for field in ("authorization_endpoint", "token_endpoint", "jwks_uri"):
|
|
value = discovery.get(field)
|
|
if not isinstance(value, str) or not value.startswith(EXPECTED_ISSUER + "/"):
|
|
raise RuntimeError(f"Missing/unsafe OIDC {field}")
|
|
print("ZITPLANE_OIDC_DISCOVERY_PASS")
|
|
jwks_path = urlparse(discovery["jwks_uri"]).path
|
|
jwks = json.loads(fetch(jwks_path))
|
|
if not isinstance(jwks.get("keys"), list):
|
|
raise RuntimeError("Invalid JWKS shape")
|
|
print("ZITPLANE_OIDC_JWKS_PASS")
|
|
print("ZITPLANE_OIDC_INTERACTIVE_E2E_BLOCKED: no disposable OIDC app/user provisioning in P05")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|