test_q1_app_integrity.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
9 hours ago
| 1 | """Data-integrity tests for Track Q / Q1 overseer app (§Q0.12).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | from tests.fixtures.app import seed_app_repo, start_test_app |
| 8 | from tests.support import FIXTURES, make_runner, ok |
| 9 | |
| 10 | |
| 11 | def _governance_runner(tmp_path: Path): |
| 12 | return make_runner( |
| 13 | { |
| 14 | "git rev-parse --abbrev-ref HEAD": ok("main"), |
| 15 | "git status --porcelain": ok(""), |
| 16 | "git rev-parse origin/main": ok("cafebabe"), |
| 17 | "gh pr list --state merged --limit 5 --json number,title,mergeCommit,mergedAt": ok("[]"), |
| 18 | "git remote get-url origin": ok("[email protected]:owner/repo.git"), |
| 19 | "git merge-base --is-ancestor": ok(""), |
| 20 | } |
| 21 | ) |
| 22 | |
| 23 | |
| 24 | def test_governance_sync_dry_run_idempotent(tmp_path: Path) -> None: |
| 25 | seed_app_repo(tmp_path) |
| 26 | docs = tmp_path / "docs" |
| 27 | (docs / "OVERSEER-HANDOVER.md").write_text( |
| 28 | (FIXTURES / "governance-handover-drift.md").read_text(encoding="utf-8"), |
| 29 | encoding="utf-8", |
| 30 | ) |
| 31 | (docs / "ROADMAP.md").write_text( |
| 32 | (FIXTURES / "governance-roadmap-drift.md").read_text(encoding="utf-8"), |
| 33 | encoding="utf-8", |
| 34 | ) |
| 35 | handle, client = start_test_app(tmp_path, runner=_governance_runner(tmp_path)) |
| 36 | try: |
| 37 | _s1, first = client.post("/api/governance-sync", {"write": False}) |
| 38 | _s2, second = client.post("/api/governance-sync", {"write": False}) |
| 39 | assert first["result"] == second["result"] |
| 40 | assert (docs / "ROADMAP.md").read_text(encoding="utf-8") == ( |
| 41 | FIXTURES / "governance-roadmap-drift.md" |
| 42 | ).read_text(encoding="utf-8") |
| 43 | finally: |
| 44 | handle.shutdown() |
| 45 | |
| 46 | |
| 47 | def test_session_credential_not_written_to_repo(tmp_path: Path) -> None: |
| 48 | seed_app_repo(tmp_path) |
| 49 | handle, client = start_test_app(tmp_path) |
| 50 | try: |
| 51 | client.get("/api/status") |
| 52 | client.get("/api/docs/roadmap") |
| 53 | for path in tmp_path.rglob("*"): |
| 54 | if path.is_file(): |
| 55 | text = path.read_text(encoding="utf-8", errors="ignore") |
| 56 | assert handle.config.session_credential not in text |
| 57 | assert handle.config.csrf_token not in text |
| 58 | lock = tmp_path / ".overseer" / "version.lock" |
| 59 | if lock.is_file(): |
| 60 | assert handle.config.session_credential not in lock.read_text(encoding="utf-8") |
| 61 | finally: |
| 62 | handle.shutdown() |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
9 hours ago