test_lac_integration.py python
81 lines 2.9 KB
Raw
sha256:106ef9e12cca7f3be3ffb2a6bd3abfa76f032dce453c9e5010d732a8d86f2e14 Reconcile reviewed credential compatibility 32254cd939885d9… Human patch 8 days ago
1 """Integration tests — Landing + access clarity (§LAC.12)."""
2
3 from __future__ import annotations
4
5 import urllib.request
6 from pathlib import Path
7
8 from tests.fixtures.app import seed_app_repo, start_test_app
9 from tools.landing.validate import validate_landing
10
11 KIT_ROOT = Path(__file__).resolve().parents[2]
12
13
14 def test_validate_landing_on_kit_root_passes() -> None:
15 result = validate_landing(KIT_ROOT)
16 assert result.ok, result.errors
17
18
19 def test_relative_doc_links_exist() -> None:
20 index = (KIT_ROOT / "docs" / "landing" / "index.html").read_text(encoding="utf-8")
21 assert "https://github.com/aaronrene/overseer-kit/blob/main/docs/GIT-ONLY-QUICKSTART.md" in index
22 assert "https://github.com/aaronrene/overseer-kit/blob/main/docs/CONSUMER-ADAPTER-PATTERN.md" in index
23 assert "https://github.com/aaronrene/overseer-kit/blob/main/docs/TRACK-Q-DESKTOP-OPERATOR-RUNBOOK.md" in index
24 assert "K7-DOGFOOD-OPERATOR-RUNBOOK" not in index
25 assert (KIT_ROOT / "docs" / "TRACK-Q-DESKTOP-OPERATOR-RUNBOOK.md").is_file()
26 assert "../GIT-ONLY-QUICKSTART.md" not in index
27 assert "musehub.ai" not in index
28 assert "Knowtation" not in index
29 assert "Scooling" not in index
30 assert "VideoFactory" not in index
31
32
33 def test_api_health_returns_repo_root_with_bearer(tmp_path: Path) -> None:
34 seed_app_repo(tmp_path)
35 handle, client = start_test_app(tmp_path)
36 try:
37 status, health = client.get("/api/health")
38 assert status == 200
39 assert health["ok"] is True
40 assert health["result"]["repo_root"] == str(tmp_path.resolve())
41 assert health["result"]["bind"] == "127.0.0.1"
42 assert isinstance(health["result"]["port"], int)
43 finally:
44 handle.shutdown()
45
46
47 def test_path_b_static_still_serves(tmp_path: Path) -> None:
48 seed_app_repo(tmp_path)
49 handle, client = start_test_app(tmp_path)
50 try:
51 request = urllib.request.Request(
52 f"{client.base_url}/",
53 headers={"Authorization": f"Bearer {client.session}"},
54 )
55 with urllib.request.urlopen(request, timeout=5) as response:
56 assert response.status == 200
57 html = response.read().decode("utf-8")
58 assert "Open the local console" in html
59 assert 'id="auth-panel"' in html
60 assert 'id="bound-repo"' in html
61 assert "collapseAuthPanel" in (
62 Path(__file__).resolve().parents[2]
63 / "tools"
64 / "app"
65 / "static"
66 / "assets"
67 / "app.js"
68 ).read_text(encoding="utf-8")
69 finally:
70 handle.shutdown()
71
72
73 def test_unknown_api_still_rejected(tmp_path: Path) -> None:
74 seed_app_repo(tmp_path)
75 handle, client = start_test_app(tmp_path)
76 try:
77 status, payload = client.get("/api/not-a-real-route")
78 assert status == 404
79 assert payload["ok"] is False
80 finally:
81 handle.shutdown()
File History 2 commits
sha256:106ef9e12cca7f3be3ffb2a6bd3abfa76f032dce453c9e5010d732a8d86f2e14 Reconcile reviewed credential compatibility 32254cd939885d9… Human patch 8 days ago
sha256:c87cf2c2f03da507f66f93922cb339a2cbebb33ad6372a6039032fb09a20da12 Reconcile reviewed Overseer recovery d47291d5d9030de5ebef71… Human minor ⚠ 9 days ago