ci: introduce ZitPlane P05 verification foundation
This commit is contained in:
1 parent
7ecf531697
commit
42b79362c1
32 files changed
+1731
-471
No files matched your search
@@ -0,0 +1,8 @@
|
||||
# tests/ci manifest
|
||||
|
||||
| File | Responsibility | Phase |
|
||||
| --- | --- | --- |
|
||||
| [README.md](README.md) | CI-only test boundaries and safety constraints | P05-CI-01 |
|
||||
| [MINIFEST.md](MINIFEST.md) | Exact tests/ci direct-file register | P05-CI-01 |
|
||||
| [source_contract.py](source_contract.py) | Source and lockfile structural checks, no network/secrets | P05-CI-01 |
|
||||
| [oidc_discovery.py](oidc_discovery.py) | Disposable ZITADEL ready/discovery/JWKS smoke only | P05-CI-01 |
|
||||
@@ -0,0 +1,10 @@
|
||||
# tests/ci — Isolated Gitea verification tools
|
||||
|
||||
This folder contains **CI-only** source/lockfile checks and OIDC discovery smoke support. Run these through the approved `.gitea/workflows/p05-ci.yml` on a disposable Linux runner.
|
||||
|
||||
- `source_contract.py` checks the narrow P05 source/package constraints and paths. It is not a typecheck or application test.
|
||||
- `oidc_discovery.py` checks ZITADEL readiness, OIDC discovery, and the public JWKS endpoint on the **disposable** Docker network. It does NOT log in a user, check a real callback, prove protected routes or administer accounts.
|
||||
|
||||
No real credentials or production domains are used. Never print bootstrap PATs, admin secrets, session cookies or `.env` contents. Cleanup of disposable volumes is mandatory; never apply `docker compose down -v` to a user's non-CI stack.
|
||||
|
||||
Add new CI checks and update `MINIFEST.md`, `project/`, `docs/`, and `notes/` in the same approved phase.
|
||||
@@ -0,0 +1,39 @@
|
||||
"""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()
|
||||
@@ -0,0 +1,75 @@
|
||||
"""P05 structural contract checks — CI only, not a build or live auth test."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
ACCOUNT = ROOT / "users/ui"
|
||||
LOGIN = ROOT / "auth/ui/v2"
|
||||
|
||||
def fail(message: str) -> None:
|
||||
raise AssertionError(message)
|
||||
|
||||
def check_account_lock() -> None:
|
||||
manifest = json.loads((ACCOUNT / "package.json").read_text(encoding="utf-8"))
|
||||
lock = json.loads((ACCOUNT / "package-lock.json").read_text(encoding="utf-8"))
|
||||
root = lock["packages"][""]
|
||||
for group in ("dependencies", "devDependencies"):
|
||||
if root.get(group) != manifest.get(group):
|
||||
fail(f"Account {group} diverge from lockfile")
|
||||
if lock.get("lockfileVersion") != 3:
|
||||
fail("Expected npm lockfile v3")
|
||||
if manifest["name"] != lock["name"]:
|
||||
fail("Account lock name mismatch")
|
||||
print("ZITPLANE_ACCOUNT_LOCK_CONTRACT_PASS")
|
||||
|
||||
def check_login_importers() -> None:
|
||||
work = (LOGIN / "pnpm-workspace.yaml").read_text(encoding="utf-8")
|
||||
lock = (LOGIN / "pnpm-lock.yaml").read_text(encoding="utf-8")
|
||||
expected = {".", "apps/login", "packages/zitadel-client", "packages/zitadel-proto"}
|
||||
m = re.search(r"(?m)^importers:\s*$", lock)
|
||||
if not m:
|
||||
fail("Missing pnpm importers")
|
||||
n = re.search(r"(?m)^packages:\s*$", lock[m.end():])
|
||||
if not n:
|
||||
fail("Missing pnpm package snapshots")
|
||||
section = lock[m.end():m.end()+n.start()]
|
||||
importers = set(re.findall(r"(?m)^ ([^\s].*?):\s*$", section))
|
||||
if importers != expected:
|
||||
fail(f"Unexpected lock importers: {sorted(importers)}")
|
||||
for name in sorted(expected - {"."}):
|
||||
if not (LOGIN / name / "package.json").is_file():
|
||||
fail(f"Missing actual workspace package {name}")
|
||||
if f" - {name}\n" not in work:
|
||||
fail(f"Missing workspace member {name}")
|
||||
if " - apps/*" in work or " - console" in work:
|
||||
fail("Unused upstream workspace globs retained")
|
||||
print("ZITPLANE_LOGIN_WORKSPACE_CONTRACT_PASS")
|
||||
|
||||
def check_security_boundaries() -> None:
|
||||
src = (ACCOUNT / "src/auth.ts").read_text(encoding="utf-8")
|
||||
endpoint = (ACCOUNT / "src/app/api/account/me/route.ts").read_text(encoding="utf-8")
|
||||
identity = (ACCOUNT / "src/lib/identity.ts").read_text(encoding="utf-8")
|
||||
for flag in ('checks: ["pkce", "state", "nonce"]', 'zitadelTokenExpiresAt', 'token.zitadelSubject'):
|
||||
if flag not in src:
|
||||
fail(f"Missing reviewed OIDC source contract: {flag}")
|
||||
if "session?.user?.id" not in endpoint or "session?.user?.id" not in identity:
|
||||
fail("Protected source must gate on valid user id")
|
||||
print("ZITPLANE_SOURCE_GUARD_CONTRACT_PASS")
|
||||
|
||||
def main() -> int:
|
||||
check_account_lock()
|
||||
check_login_importers()
|
||||
check_security_boundaries()
|
||||
print("ZITPLANE_SOURCE_CONTRACTS_PASS")
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main())
|
||||
except (AssertionError, ValueError, KeyError, FileNotFoundError) as exc:
|
||||
print(f"ZITPLANE_SOURCE_CONTRACTS_FAIL: {exc}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
Reference in new issue
Block a user