phase: 173_docs_push_creds_split
Build and Push Containers / build-and-push-app (push) Successful in 1m41s
Build and Push Containers / build-and-push-db (push) Successful in 11s

All gates green. Final report:

**Phase 173 — final verification pass (all tasks already complete in `complete/`)**

- Verified the full implementation is in the working tree: `docs_user`/`docs_token` settings + catalogue rows (task 01), `docs_repo` PUT 422 guard + `docs_token` write-only pin (task 02), `run_git(env)` + `push_document(user, token)` credential env (task 03), `settings_migrate.py` wired into `create_app()` (task 04), E2E suite (task 05).
- **Completion criteria:**
  1. GET `/api/admin/settings` lists `docs_user` (plain) + `docs_token` (secret, `value=null`), token never in any body — ✅ `test_docs_token_is_write_only_masked_end_to_end` + E2E sentinel-absent-from-DOM
  2. PUT `docs_repo` with `://user:pass@` → 422 naming the fields; clean URL passes — ✅ integration + E2E UI-side
  3. Token set → `GIT_CURL_USERNAME`/`GIT_CURL_PASSWORD`/`GIT_TERMINAL_PROMPT=0` on every git step; empty → `env=None` — ✅ mocked-git unit tests
  4. Legacy env split once at startup, idempotent, one INFO line, `.env` untouched — ✅ `test_settings_migrate.py` (4 shapes) + `test_docs_push_migrate.py`
  5. Full suite green, coverage >90%, lint clean — ✅
  6. E2E isolated: `test_docs_push_creds.py` 4/4; regression set (panel + layout + response_to_docs) 21/21 — ✅
  7. Commit + phase move — harness's job (per instructions, not mine).
  8. README/AGENTS consistent — ✅ (below)
- Tests/lint: `uv run pytest` exit 0 (4112 passed) · `uv run pytest --cov=app --cov-report=term-missing` TOTAL 99% · `uv run ruff check .` clean · `uv run pyright` 0 errors
- Docs: README.md (incl. Docs-push config section, guard/migration paragraph, `.env.example` block) and AGENTS.md verified consistent in full; fixed two stale docstrings in `app/config.py` + `app/core/settings_catalog.py` (`is_set` → the API's actual `has_value` field).
- No live-infrastructure changes (no live step in this phase). No next pending phase — `todo/` held only 173.
This commit is contained in:
2026-10-10 16:47:39 -04:00
parent f27106a638
commit a86caec821
56 changed files with 3177 additions and 39 deletions
+33
View File
@@ -1,6 +1,8 @@
"""Unit tests: app factory edge cases (no live DB needed)."""
from __future__ import annotations
import logging
from fastapi.testclient import TestClient
import app.main as main_mod
@@ -51,3 +53,34 @@ def test_create_app_boots_with_the_switch_on(monkeypatch) -> None:
# settings, and the hook slate is fresh for them too.
settings_overlay.reset_state_for_tests()
get_settings.cache_clear()
def test_create_app_migration_failure_warns_and_boots(
monkeypatch, caplog
) -> None:
"""Phase 173 (task 04, C3): a migration failure logs a WARNING
and never blocks startup — the app still boots (with the
pre-phase behavior: the migration is a convenience, not a
dependency). The seam: the migration is monkeypatched to raise;
the real migration is a no-op in a DB-less unit environment
(the overlay's fail-soft read + the conftest-pinned empty
``BOR_DOCS_REPO``), so the boot path is otherwise unchanged."""
settings_overlay.reset_state_for_tests()
def _boom() -> bool:
raise RuntimeError("migration hiccup")
monkeypatch.setattr(main_mod, "migrate_legacy_docs_creds", _boom)
with caplog.at_level(logging.WARNING, logger="app"):
app2 = main_mod.create_app()
assert app2 is not None
warnings = [
record.getMessage() for record in caplog.records
if record.levelno == logging.WARNING
]
assert "settings migration failed (RuntimeError)" in warnings
# restore: the hook slate is fresh for the later suites, and the
# cache clear keeps a boot-time row set from leaking into their
# settings.
settings_overlay.reset_state_for_tests()
get_settings.cache_clear()