test: cover manage.py, the offline recovery CLI (0% → 59%) - #64
Merged
Conversation
The tool you reach for when the web UI cannot help — forgotten password,
deactivated sole admin, a lost 2FA device — had no tests at all. That is a
bad place for a gap: its whole job is to work on the day nothing else does.
21 checks, four properties, each mutation-verified:
the lock-out guard deactivating or demoting the LAST active superadmin is
refused AND rolled back, an inactive admin does not
count as cover, and a second admin makes it allowed.
Removing the guard fails 5 checks.
session revocation a password reset bumps auth_epoch, or a stolen cookie
outlives the reset meant to kill it. Fails 1.
2fa disable-2fa wipes the SECRET, not just the flag —
otherwise re-enabling silently restores the old
device. Fails 1.
no guessing with no terminal it defaults to the sole superadmin
and otherwise refuses; disable-2fa never defaults at
all. Fails 1.
Plus create-admin (refuses to clobber), weak --password rejected before
anything is written, unknown username refused, and the interactive menu
accepting a number, a name, or a retry.
The harness reports a mid-run crash instead of hiding it. Writing this, three
of my own bugs — a wrong helper name, assigning to the read-only
sys.stdin.isatty, and calling a DB function with no app context — each just
made the suite print fewer checks and still say "all passed". A crash is a
failure and prints its traceback now.
Wired into tools/run-tests.sh (so CI runs it) and into the coverage job.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Coverage variation | ✅ +0.59% coverage variation (-1.00%) |
| Diff coverage | ✅ ∅ diff coverage |
Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (29346ff) 11928 5670 47.54% Head commit (3bafea5) 11928 (+0) 5740 (+70) 48.12% (+0.59%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#64) 0 0 ∅ (not applicable) Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
… corpus repo exists cflite_pr.yml fuzzes what a PR changed, for three minutes, starting from the committed seeds every time. These add the other half: nightly across all five targets for 15 minutes, and a weekly prune plus a coverage report showing which lines the fuzzers actually reach. The reason those modes were left out is that they need somewhere to keep the corpus between runs, which is a separate repo and a token. So every job is guarded by `if: env.CFL_STORAGE_REPO != ''` — with no secret they are skipped and green, and they start working by themselves the moment one is added. Same shape as the Codacy upload: nothing to remember, nothing red in the meantime. Also `if: github.repository == ...` so a fork never burns its own minutes on this, and language: python on run_fuzzers, which defaults to c++ and does not inherit it from the build step. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The tool you reach for when the web UI can't help — forgotten password, deactivated sole admin, lost 2FA device — had no tests at all. Bad place for a gap: its whole job is to work on the day nothing else does.
21 checks across four properties, each mutation-verified:
auth_epoch, or a stolen cookie outlives the reset meant to kill itdisable-2fawipes the secret, not just the flag — otherwise re-enabling silently restores the old devicedisable-2fanever defaults at allPlus
create-adminrefusing to clobber, a weak--passwordrejected before anything is written, unknown usernames refused, and the interactive menu accepting a number, a name, or a retry.The harness now admits when it crashes
Writing this I hit three of my own bugs — a wrong helper name, assigning to the read-only
sys.stdin.isatty, and calling a DB function outside an app context. Each one just made the suite print fewer checks and still say "all passed." That's the same failure mode that let a brokendashboard.jsthrough earlier today. A crash is now a failure, with its traceback.Wired into
tools/run-tests.sh(so CI runs it) and the coverage job.🤖 Generated with Claude Code