CI / test (push) Canceled after 0s
Introduce git.GitRunner as the sole git-op seam: the only place git is invoked. It owns subprocess execution, per-op timeout, error redaction, and auth delivery. Forge tokens move off the remote URL entirely onto a non-persisted per-op http.<host>.extraHeader, so they never reach the command line, a remote URL, or .git/config. Rewrite the mirror procedure to drive GitRunner and retire the URL-token helpers (_authed/_bare/_redact/_scrub_remote_tokens) plus the try/finally scrub -- their reason to exist vanishes. mirror_repo's signature and report stay unchanged; cli/migrate import the re-exported GitError/timeout unchanged. The procedure's ordering invariants are now locked by a recording-fake test, and an AST guard fails the suite if any git op bypasses the seam. Closes the 2026-08-11 audit's HIGH (token in GitError) and MEDIUM (token in .git/config) at one structural root cause. Closes #1
32 lines
1.3 KiB
Markdown
32 lines
1.3 KiB
Markdown
# tests
|
|
|
|
## Purpose
|
|
|
|
Pytest suite for `codeberg_to_gitea_migrator`.
|
|
|
|
## Ownership
|
|
|
|
Project maintainer (Alexander Kucera).
|
|
|
|
## Local Contracts
|
|
|
|
- pytest `testpaths = ["tests"]` (root `pyproject.toml`).
|
|
- Test files named `test_*.py`; test functions `test_*`.
|
|
|
|
## Work Guidance
|
|
|
|
- `test_smoke.py` — package imports + version.
|
|
- `test_refs.py` — `#NNN`/URL cross-reference rewrite + `NumberMap`.
|
|
- `test_clients.py` — `ApiClient` pagination, param cleaning, 4xx handling, JSON POST, all via `httpx.MockTransport` (no network).
|
|
- `test_git.py` — the `GitRunner` seam (auth delivery via non-persisted `extraHeader`, known-secret redaction, timeout/error contract, `ok` never raises) + an AST guard that git is invoked only through `GitRunner`. Driven by a recording exec fake; no git binary, no network.
|
|
- `test_mirror.py` — the mirror procedure's ordering invariants (capture → prune → mirror push → PR-head push; LFS gated on the probe) and per-op auth wiring (fetch=source, push=target, local ref ops=none), via a recording exec fake that captures command intent only — never the token.
|
|
- Keep tests network-free: never hit live Codeberg/Gitea from the suite. The end-to-end run is a manual CLI invocation, not a test.
|
|
|
|
## Verification
|
|
|
|
- `pytest` from the repo root.
|
|
|
|
## Child DOX Index
|
|
|
|
- No children.
|