regstack 0.2.4__tar.gz → 0.2.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {regstack-0.2.4 → regstack-0.2.6}/CHANGELOG.md +30 -0
- {regstack-0.2.4 → regstack-0.2.6}/PKG-INFO +1 -1
- {regstack-0.2.4 → regstack-0.2.6}/docs/changelog.md +61 -0
- {regstack-0.2.4 → regstack-0.2.6}/pyproject.toml +23 -1
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/mongo/repositories/pending_repo.py +4 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/protocols.py +16 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/migrations/__init__.py +18 -12
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/repositories/pending_repo.py +9 -1
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/cli/doctor.py +2 -2
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/routers/admin.py +1 -7
- regstack-0.2.6/src/regstack/version.py +1 -0
- {regstack-0.2.4 → regstack-0.2.6}/tasks.py +42 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/integration/test_admin_router.py +56 -0
- regstack-0.2.6/tests/unit/test_cli_doctor.py +164 -0
- regstack-0.2.6/tests/unit/test_cli_init.py +150 -0
- {regstack-0.2.4 → regstack-0.2.6}/uv.lock +1 -1
- regstack-0.2.4/src/regstack/version.py +0 -1
- {regstack-0.2.4 → regstack-0.2.6}/.github/workflows/publish.yml +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/.github/workflows/test.yml +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/.gitignore +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/.python-version +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/.readthedocs.yaml +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/CLAUDE.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/LICENSE +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/NOTICE +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/README.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/SECURITY.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/docs/_static/.gitkeep +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/docs/_templates/.gitkeep +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/docs/api.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/docs/architecture.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/docs/cli.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/docs/conf.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/docs/configuration.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/docs/embedding.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/docs/index.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/docs/quickstart.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/docs/security.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/docs/theming.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/examples/_common/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/examples/_common/app.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/examples/mongo/README.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/examples/mongo/branding/theme.css +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/examples/mongo/main.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/examples/mongo/regstack.toml +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/examples/postgres/README.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/examples/postgres/main.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/examples/postgres/regstack.toml +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/examples/sqlite/README.md +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/examples/sqlite/main.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/examples/sqlite/regstack.toml +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/regstack.toml.example +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/app.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/auth/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/auth/clock.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/auth/dependencies.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/auth/jwt.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/auth/lockout.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/auth/mfa.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/auth/password.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/auth/tokens.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/base.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/factory.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/mongo/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/mongo/backend.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/mongo/client.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/mongo/indexes.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/mongo/repositories/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/mongo/repositories/blacklist_repo.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/mongo/repositories/login_attempt_repo.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/mongo/repositories/mfa_code_repo.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/mongo/repositories/user_repo.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/backend.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/migrations/env.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/migrations/script.py.mako +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/migrations/versions/0001_initial_schema.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/repositories/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/repositories/blacklist_repo.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/repositories/login_attempt_repo.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/repositories/mfa_code_repo.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/repositories/user_repo.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/schema.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/backends/sql/types.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/cli/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/cli/__main__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/cli/_runtime.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/cli/admin.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/cli/init.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/cli/migrate.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/config/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/config/loader.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/config/schema.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/config/secrets.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/base.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/composer.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/console.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/factory.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/ses.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/smtp.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/templates/email_change.html +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/templates/email_change.subject.txt +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/templates/email_change.txt +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/templates/password_reset.html +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/templates/password_reset.subject.txt +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/templates/password_reset.txt +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/templates/sms_login_mfa.txt +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/templates/sms_phone_setup.txt +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/templates/verification.html +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/templates/verification.subject.txt +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/email/templates/verification.txt +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/hooks/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/hooks/events.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/models/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/models/_objectid.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/models/login_attempt.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/models/mfa_code.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/models/pending_registration.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/models/user.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/routers/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/routers/_schemas.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/routers/account.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/routers/login.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/routers/logout.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/routers/password.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/routers/phone.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/routers/register.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/routers/verify.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/sms/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/sms/base.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/sms/factory.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/sms/null.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/sms/sns.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/sms/twilio.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/pages.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/static/css/core.css +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/static/css/theme.css +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/static/js/regstack.js +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/templates/auth/email_change_confirm.html +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/templates/auth/forgot.html +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/templates/auth/login.html +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/templates/auth/me.html +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/templates/auth/mfa_confirm.html +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/templates/auth/register.html +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/templates/auth/reset.html +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/templates/auth/verify.html +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/src/regstack/ui/templates/base.html +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/conftest.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/integration/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/integration/test_account_management.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/integration/test_happy_path.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/integration/test_indexes.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/integration/test_login_lockout.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/integration/test_mfa.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/integration/test_password_reset.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/integration/test_sql_migrations.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/integration/test_ui_router.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/integration/test_verification.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/__init__.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/test_base_install_imports.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/test_cli.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/test_config_loader.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/test_jwt.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/test_lockout.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/test_mail_composer.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/test_mfa_code_repo.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/test_password.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/test_ses_backend.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/test_sms.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/test_smtp_backend.py +0 -0
- {regstack-0.2.4 → regstack-0.2.6}/tests/unit/test_ui_env.py +0 -0
|
@@ -5,6 +5,36 @@ authoritative copy lives at
|
|
|
5
5
|
[`docs/changelog.md`](docs/changelog.md) and is rendered into the
|
|
6
6
|
Sphinx docs.
|
|
7
7
|
|
|
8
|
+
## 0.2.6 — 2026-04-28
|
|
9
|
+
|
|
10
|
+
Bug fix.
|
|
11
|
+
|
|
12
|
+
- **Fix:** `/admin/stats` reported `pending_registrations: 0` on
|
|
13
|
+
every SQL backend. The route reached into the Mongo repo's private
|
|
14
|
+
`_collection` attribute and silently fell back to `0` when the
|
|
15
|
+
attribute was absent. Added `count_unexpired(now=None)` to
|
|
16
|
+
`PendingRepoProtocol` with Mongo + SQL implementations and routed
|
|
17
|
+
through `rs.clock.now()` so the count respects the injected clock.
|
|
18
|
+
New parametrized integration test exercises the count on every
|
|
19
|
+
backend.
|
|
20
|
+
|
|
21
|
+
## 0.2.5 — 2026-04-28
|
|
22
|
+
|
|
23
|
+
Bug fix + tooling.
|
|
24
|
+
|
|
25
|
+
- **Fix:** `regstack doctor` against a SQL backend crashed with
|
|
26
|
+
`asyncio.run() cannot be called from a running event loop`. The
|
|
27
|
+
schema check called `regstack.backends.sql.migrations.current()`,
|
|
28
|
+
which used `asyncio.run()` internally — invalid inside doctor's own
|
|
29
|
+
`asyncio.run`. Added `current_async()` and switched the doctor
|
|
30
|
+
command to use it. Sync `current()` is preserved for the migrate
|
|
31
|
+
CLI.
|
|
32
|
+
- **New:** `inv coverage [--no-html] [--fail-under=N]` runs the full
|
|
33
|
+
three-backend matrix under coverage and writes term + HTML reports.
|
|
34
|
+
Branch coverage is on by default.
|
|
35
|
+
- Test coverage uplift on the CLI: `cli/init.py` 14% → 88%,
|
|
36
|
+
`cli/doctor.py` 61% → 87%. Total: **85% → 87.1%**.
|
|
37
|
+
|
|
8
38
|
## 0.2.4 — 2026-04-28
|
|
9
39
|
|
|
10
40
|
**Breaking** — back-compat shims removed:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: regstack
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
4
4
|
Summary: Embeddable user registration, login, and account management for FastAPI apps. SQLite / Postgres / MongoDB.
|
|
5
5
|
Project-URL: Homepage, https://github.com/jdrumgoole/regstack
|
|
6
6
|
Project-URL: Repository, https://github.com/jdrumgoole/regstack
|
|
@@ -3,6 +3,67 @@
|
|
|
3
3
|
All notable changes to this project are documented here. Versions follow
|
|
4
4
|
[Semantic Versioning](https://semver.org/) once `1.0.0` ships.
|
|
5
5
|
|
|
6
|
+
## 0.2.6 — 2026-04-28
|
|
7
|
+
|
|
8
|
+
**Bug fix.**
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- ``/admin/stats`` reported ``pending_registrations: 0`` on every SQL
|
|
13
|
+
backend. The route reached into the Mongo repo's private
|
|
14
|
+
``_collection`` attribute and silently fell back to ``0`` when the
|
|
15
|
+
attribute was absent — the kind of failure that survives a
|
|
16
|
+
multi-backend refactor when the integration tests don't pin the
|
|
17
|
+
number.
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- ``PendingRepoProtocol.count_unexpired(now=None) -> int``, with Mongo
|
|
22
|
+
and SQL implementations. "Unexpired" rather than a raw row count
|
|
23
|
+
because SQL backends accumulate dead rows until ``purge_expired``
|
|
24
|
+
runs; an admin looking at "pending: 47" wants 47 *live* rows.
|
|
25
|
+
- The admin stats route now routes the count through
|
|
26
|
+
``rs.clock.now()``. Without this, ``FrozenClock``-driven tests
|
|
27
|
+
would see every row as "expired" because the route would be reading
|
|
28
|
+
wall-clock time while the rest of the system runs on the injected
|
|
29
|
+
clock. Same shape of clock-injection drift the bulk-revoke fix
|
|
30
|
+
closed earlier.
|
|
31
|
+
- New parametrized integration test
|
|
32
|
+
``test_stats_pending_registrations_count_unexpired`` runs against
|
|
33
|
+
SQLite + Mongo + Postgres and confirms the count excludes expired
|
|
34
|
+
rows on every backend.
|
|
35
|
+
|
|
36
|
+
## 0.2.5 — 2026-04-28
|
|
37
|
+
|
|
38
|
+
**Bug fix + tooling.**
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- ``regstack doctor`` against a SQL backend crashed with
|
|
43
|
+
``asyncio.run() cannot be called from a running event loop``. The
|
|
44
|
+
schema check called
|
|
45
|
+
``regstack.backends.sql.migrations.current()``, which used
|
|
46
|
+
``asyncio.run()`` internally — invalid inside doctor's own
|
|
47
|
+
``asyncio.run``. Added ``current_async()`` and switched the doctor
|
|
48
|
+
command to use it. Sync ``current()`` is preserved for the migrate
|
|
49
|
+
CLI (which runs outside an event loop).
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
|
|
53
|
+
- ``inv coverage [--no-html] [--fail-under=N]`` — runs the full
|
|
54
|
+
three-backend matrix under coverage, combines per-pytest-xdist-worker
|
|
55
|
+
``.coverage`` files, prints the term-with-missing report, and writes
|
|
56
|
+
``htmlcov/``. Branch coverage is on by default.
|
|
57
|
+
- ``[tool.coverage.*]`` config in ``pyproject.toml``.
|
|
58
|
+
- ``tests/unit/test_cli_init.py`` — six tests driving the
|
|
59
|
+
``regstack init`` wizard via ``CliRunner(input=...)``. Lifts
|
|
60
|
+
``cli/init.py`` from 14% → 88%.
|
|
61
|
+
- ``tests/unit/test_cli_doctor.py`` — four tests for the SQLite
|
|
62
|
+
``regstack doctor`` paths. Lifts ``cli/doctor.py`` from 61% → 87%.
|
|
63
|
+
|
|
64
|
+
Total line coverage on the full backend matrix: **85% → 87.1%**
|
|
65
|
+
(branch coverage is also newly enabled).
|
|
66
|
+
|
|
6
67
|
## 0.2.4 — 2026-04-28
|
|
7
68
|
|
|
8
69
|
**Breaking** — every back-compat shim left over from the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "regstack"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.6"
|
|
4
4
|
description = "Embeddable user registration, login, and account management for FastAPI apps. SQLite / Postgres / MongoDB."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
@@ -119,3 +119,25 @@ python_version = "3.11"
|
|
|
119
119
|
strict = true
|
|
120
120
|
warn_unreachable = true
|
|
121
121
|
plugins = ["pydantic.mypy"]
|
|
122
|
+
|
|
123
|
+
[tool.coverage.run]
|
|
124
|
+
source = ["src/regstack"]
|
|
125
|
+
branch = true
|
|
126
|
+
parallel = true
|
|
127
|
+
# `concurrency = ["thread"]` is implicit; pytest-xdist workers each write
|
|
128
|
+
# their own .coverage.<host>.<pid>.<token> file and `coverage combine`
|
|
129
|
+
# folds them together — see the `coverage` invoke task.
|
|
130
|
+
|
|
131
|
+
[tool.coverage.report]
|
|
132
|
+
show_missing = true
|
|
133
|
+
skip_covered = false
|
|
134
|
+
precision = 1
|
|
135
|
+
exclude_lines = [
|
|
136
|
+
"pragma: no cover",
|
|
137
|
+
"if TYPE_CHECKING:",
|
|
138
|
+
"raise NotImplementedError",
|
|
139
|
+
"\\.\\.\\.$", # body-less Protocol methods
|
|
140
|
+
]
|
|
141
|
+
|
|
142
|
+
[tool.coverage.html]
|
|
143
|
+
directory = "htmlcov"
|
|
@@ -64,6 +64,10 @@ class PendingRepo:
|
|
|
64
64
|
result = await self._collection.delete_many({"expires_at": {"$lt": cutoff}})
|
|
65
65
|
return int(result.deleted_count)
|
|
66
66
|
|
|
67
|
+
async def count_unexpired(self, now: datetime | None = None) -> int:
|
|
68
|
+
cutoff = now or datetime.now(UTC)
|
|
69
|
+
return await self._collection.count_documents({"expires_at": {"$gt": cutoff}})
|
|
70
|
+
|
|
67
71
|
@staticmethod
|
|
68
72
|
def _hydrate(doc: dict[str, Any] | None) -> PendingRegistration | None:
|
|
69
73
|
if doc is None:
|
|
@@ -154,6 +154,22 @@ class PendingRepoProtocol(Protocol):
|
|
|
154
154
|
"""
|
|
155
155
|
...
|
|
156
156
|
|
|
157
|
+
async def count_unexpired(self, now: datetime | None = None) -> int:
|
|
158
|
+
"""Count pending-registration rows whose ``expires_at`` is in the future.
|
|
159
|
+
|
|
160
|
+
"Unexpired" rather than a raw row-count because SQL backends
|
|
161
|
+
accumulate dead rows until ``purge_expired`` runs — a raw
|
|
162
|
+
count would double-report a verification email that's been
|
|
163
|
+
unanswered for a month and a fresh one sent today.
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
now: Reference instant. Defaults to ``datetime.now(UTC)``.
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
Number of pending rows with ``expires_at > now``.
|
|
170
|
+
"""
|
|
171
|
+
...
|
|
172
|
+
|
|
157
173
|
|
|
158
174
|
@runtime_checkable
|
|
159
175
|
class BlacklistRepoProtocol(Protocol):
|
|
@@ -71,23 +71,29 @@ async def upgrade_async(database_url: str, revision: str = "head") -> None:
|
|
|
71
71
|
|
|
72
72
|
def current(database_url: str) -> str | None:
|
|
73
73
|
"""Return the current revision recorded in alembic_version, or None
|
|
74
|
-
if the table doesn't exist (i.e. fresh DB).
|
|
75
|
-
engine = create_async_engine(database_url)
|
|
76
|
-
|
|
77
|
-
async def _read() -> str | None:
|
|
78
|
-
async with engine.connect() as conn:
|
|
79
|
-
return await conn.run_sync(_current_sync)
|
|
74
|
+
if the table doesn't exist (i.e. fresh DB).
|
|
80
75
|
|
|
76
|
+
Synchronous; do NOT call from inside a running event loop —
|
|
77
|
+
use :func:`current_async` instead.
|
|
78
|
+
"""
|
|
81
79
|
import asyncio
|
|
82
80
|
|
|
81
|
+
return asyncio.run(_current_async_impl(database_url))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
async def current_async(database_url: str) -> str | None:
|
|
85
|
+
"""Async variant of :func:`current` — safe to call from inside an
|
|
86
|
+
already-running event loop (e.g. ``regstack doctor``)."""
|
|
87
|
+
return await _current_async_impl(database_url)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
async def _current_async_impl(database_url: str) -> str | None:
|
|
91
|
+
engine = create_async_engine(database_url)
|
|
83
92
|
try:
|
|
84
|
-
|
|
93
|
+
async with engine.connect() as conn:
|
|
94
|
+
return await conn.run_sync(_current_sync)
|
|
85
95
|
finally:
|
|
86
|
-
|
|
87
|
-
async def _close() -> None:
|
|
88
|
-
await engine.dispose()
|
|
89
|
-
|
|
90
|
-
asyncio.run(_close())
|
|
96
|
+
await engine.dispose()
|
|
91
97
|
|
|
92
98
|
|
|
93
99
|
def _current_sync(connection) -> str | None:
|
|
@@ -4,7 +4,7 @@ import uuid
|
|
|
4
4
|
from datetime import UTC, datetime
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
|
-
from sqlalchemy import delete, select
|
|
7
|
+
from sqlalchemy import delete, func, select
|
|
8
8
|
|
|
9
9
|
from regstack.backends.sql.schema import pending_table
|
|
10
10
|
from regstack.models.pending_registration import PendingRegistration
|
|
@@ -56,6 +56,14 @@ class SqlPendingRepo:
|
|
|
56
56
|
result = await conn.execute(delete(self._t).where(self._t.c.expires_at < cutoff))
|
|
57
57
|
return int(result.rowcount or 0)
|
|
58
58
|
|
|
59
|
+
async def count_unexpired(self, now: datetime | None = None) -> int:
|
|
60
|
+
cutoff = now or datetime.now(UTC)
|
|
61
|
+
async with self._engine.connect() as conn:
|
|
62
|
+
result = await conn.execute(
|
|
63
|
+
select(func.count()).select_from(self._t).where(self._t.c.expires_at > cutoff)
|
|
64
|
+
)
|
|
65
|
+
return int(result.scalar_one())
|
|
66
|
+
|
|
59
67
|
|
|
60
68
|
def _pending_values(p: PendingRegistration) -> dict:
|
|
61
69
|
return {
|
|
@@ -127,10 +127,10 @@ async def _check_schema(config) -> CheckResult:
|
|
|
127
127
|
)
|
|
128
128
|
return CheckResult("schema", True, "core indexes present")
|
|
129
129
|
# SQL backends: compare alembic_version to the bundled head.
|
|
130
|
-
from regstack.backends.sql.migrations import
|
|
130
|
+
from regstack.backends.sql.migrations import current_async, head_revision
|
|
131
131
|
|
|
132
132
|
url = config.database_url.get_secret_value()
|
|
133
|
-
live =
|
|
133
|
+
live = await current_async(url)
|
|
134
134
|
head = head_revision()
|
|
135
135
|
if live is None:
|
|
136
136
|
return CheckResult(
|
|
@@ -50,13 +50,7 @@ def build_admin_router(rs: RegStack) -> APIRouter:
|
|
|
50
50
|
active = await rs.users.count(is_active=True)
|
|
51
51
|
verified = await rs.users.count(is_verified=True)
|
|
52
52
|
supers = await rs.users.count(is_superuser=True)
|
|
53
|
-
|
|
54
|
-
# mongo backend; SQL backends will add a typed count too.
|
|
55
|
-
pending_count_doc = getattr(rs.pending, "_collection", None)
|
|
56
|
-
if pending_count_doc is not None:
|
|
57
|
-
pending = await pending_count_doc.count_documents({})
|
|
58
|
-
else: # pragma: no cover — used by SQL backends in Phase 2
|
|
59
|
-
pending = 0
|
|
53
|
+
pending = await rs.pending.count_unexpired(rs.clock.now())
|
|
60
54
|
return AdminStats(
|
|
61
55
|
total_users=total,
|
|
62
56
|
active_users=active,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.6"
|
|
@@ -95,6 +95,48 @@ def test_serial(c: Context, k: str = "") -> None:
|
|
|
95
95
|
c.run(cmd, pty=True)
|
|
96
96
|
|
|
97
97
|
|
|
98
|
+
@task
|
|
99
|
+
def coverage(
|
|
100
|
+
c: Context,
|
|
101
|
+
pg_url: str = _DEFAULT_PG_URL,
|
|
102
|
+
html: bool = True,
|
|
103
|
+
fail_under: int = 0,
|
|
104
|
+
) -> None:
|
|
105
|
+
"""Run the full backend matrix under coverage.
|
|
106
|
+
|
|
107
|
+
Combines per-worker .coverage.* files (pytest-xdist runs one
|
|
108
|
+
coverage instance per worker; settings.parallel = true plus
|
|
109
|
+
`coverage combine` glues them back together) and prints the
|
|
110
|
+
line-coverage report. With --html (default), also writes an
|
|
111
|
+
HTML report under ``htmlcov/``.
|
|
112
|
+
|
|
113
|
+
Set ``--fail-under=N`` to make the task exit non-zero when total
|
|
114
|
+
line coverage drops below N percent — useful in CI.
|
|
115
|
+
"""
|
|
116
|
+
# Wipe stale coverage state so partial reruns don't leave double-counted
|
|
117
|
+
# data files behind.
|
|
118
|
+
c.run("uv run coverage erase", pty=True, warn=True)
|
|
119
|
+
env = {
|
|
120
|
+
"REGSTACK_TEST_BACKENDS": "sqlite,mongo,postgres",
|
|
121
|
+
"REGSTACK_TEST_POSTGRES_URL": pg_url,
|
|
122
|
+
# pytest-cov picks settings up from [tool.coverage.*] in pyproject.toml.
|
|
123
|
+
"COVERAGE_PROCESS_START": "pyproject.toml",
|
|
124
|
+
}
|
|
125
|
+
c.run(
|
|
126
|
+
"uv run python -m pytest -n auto --cov=src/regstack --cov-report=",
|
|
127
|
+
pty=True,
|
|
128
|
+
env=env,
|
|
129
|
+
)
|
|
130
|
+
c.run("uv run coverage combine", pty=True, warn=True)
|
|
131
|
+
report_cmd = "uv run coverage report"
|
|
132
|
+
if fail_under > 0:
|
|
133
|
+
report_cmd += f" --fail-under={fail_under}"
|
|
134
|
+
c.run(report_cmd, pty=True)
|
|
135
|
+
if html:
|
|
136
|
+
c.run("uv run coverage html", pty=True)
|
|
137
|
+
print("\nHTML report: htmlcov/index.html")
|
|
138
|
+
|
|
139
|
+
|
|
98
140
|
@task
|
|
99
141
|
def e2e(c: Context) -> None:
|
|
100
142
|
"""Run Playwright end-to-end suite."""
|
|
@@ -161,6 +161,62 @@ async def test_admin_resend_verification(make_client) -> None:
|
|
|
161
161
|
assert r.status_code == 400
|
|
162
162
|
|
|
163
163
|
|
|
164
|
+
@pytest.mark.asyncio
|
|
165
|
+
async def test_stats_pending_registrations_count_unexpired(make_client) -> None:
|
|
166
|
+
"""Admin stats must report pending-registration count correctly on every backend.
|
|
167
|
+
|
|
168
|
+
Before this test landed, the stats route reached into Mongo's private
|
|
169
|
+
``_collection`` attribute and silently returned 0 on SQL backends. The
|
|
170
|
+
parametrized ``backend_kind`` fixture means this asserts the count
|
|
171
|
+
against SQLite, MongoDB, and PostgreSQL in turn — a gap that survived
|
|
172
|
+
the multi-backend refactor because the existing admin tests didn't
|
|
173
|
+
pin this number.
|
|
174
|
+
|
|
175
|
+
Also seeds an already-expired pending row directly via the repo to
|
|
176
|
+
confirm the count excludes it (the SQL backend has no TTL reaper, so
|
|
177
|
+
this distinction matters).
|
|
178
|
+
"""
|
|
179
|
+
from datetime import timedelta
|
|
180
|
+
|
|
181
|
+
from regstack.models.pending_registration import PendingRegistration
|
|
182
|
+
|
|
183
|
+
async with make_client(
|
|
184
|
+
require_verification=True,
|
|
185
|
+
enable_admin_router=True,
|
|
186
|
+
) as (rs, client):
|
|
187
|
+
await rs.bootstrap_admin("admin@example.com", "adminadminadmin")
|
|
188
|
+
admin_token = await _login(client, "admin@example.com", "adminadminadmin")
|
|
189
|
+
headers = {"authorization": f"Bearer {admin_token}"}
|
|
190
|
+
|
|
191
|
+
# Two fresh registrations → two unexpired pending rows.
|
|
192
|
+
await client.post(REGISTER, json=ALICE)
|
|
193
|
+
await client.post(REGISTER, json=BOB)
|
|
194
|
+
|
|
195
|
+
r = await client.get(ADMIN_STATS, headers=headers)
|
|
196
|
+
assert r.status_code == 200
|
|
197
|
+
assert r.json()["pending_registrations"] == 2
|
|
198
|
+
|
|
199
|
+
# Insert a stale pending row directly, anchored to ``rs.clock`` so
|
|
200
|
+
# it's "in the past" from the route's POV (which also reads the
|
|
201
|
+
# injected clock). Mongo would reap it via TTL eventually; SQL
|
|
202
|
+
# leaves it in place until purge_expired runs. Either way,
|
|
203
|
+
# count_unexpired must exclude it.
|
|
204
|
+
stale = PendingRegistration(
|
|
205
|
+
email="stale@example.com",
|
|
206
|
+
hashed_password="x",
|
|
207
|
+
full_name="Stale",
|
|
208
|
+
token_hash="stale-token-hash",
|
|
209
|
+
expires_at=rs.clock.now() - timedelta(hours=1),
|
|
210
|
+
)
|
|
211
|
+
await rs.pending.upsert(stale)
|
|
212
|
+
|
|
213
|
+
r = await client.get(ADMIN_STATS, headers=headers)
|
|
214
|
+
assert r.status_code == 200
|
|
215
|
+
assert r.json()["pending_registrations"] == 2, (
|
|
216
|
+
f"stale row should not be counted: {r.json()}"
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
|
|
164
220
|
@pytest.mark.asyncio
|
|
165
221
|
async def test_admin_404_for_unknown_user(make_client) -> None:
|
|
166
222
|
async with make_client(enable_admin_router=True) as (rs, client):
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"""Tests for the ``regstack doctor`` CLI command.
|
|
2
|
+
|
|
3
|
+
Targets the SQLite branch (no infrastructure required) and exercises:
|
|
4
|
+
|
|
5
|
+
- the JWT-secret quality check (missing / too short / present)
|
|
6
|
+
- the backend ``ping`` path
|
|
7
|
+
- the schema check before and after ``install_schema``
|
|
8
|
+
- the email-factory check
|
|
9
|
+
- the ``--send-test-email`` path against the console backend
|
|
10
|
+
- the ``--check-dns`` path with a domain we expect to fail
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import asyncio
|
|
16
|
+
import os
|
|
17
|
+
import secrets
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
import pytest
|
|
21
|
+
from click.testing import CliRunner
|
|
22
|
+
|
|
23
|
+
from regstack.cli.__main__ import cli
|
|
24
|
+
from regstack.cli._runtime import open_regstack
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _write_sqlite_config(
|
|
28
|
+
tmp_path: Path,
|
|
29
|
+
*,
|
|
30
|
+
from_address: str = "noreply@example.com",
|
|
31
|
+
) -> tuple[Path, Path]:
|
|
32
|
+
sqlite_path = tmp_path / "doctor.db"
|
|
33
|
+
cfg = tmp_path / "regstack.toml"
|
|
34
|
+
cfg.write_text(
|
|
35
|
+
f"""\
|
|
36
|
+
app_name = "doctor-test"
|
|
37
|
+
base_url = "http://localhost:8000"
|
|
38
|
+
database_url = "sqlite+aiosqlite:///{sqlite_path}"
|
|
39
|
+
|
|
40
|
+
jwt_ttl_seconds = 7200
|
|
41
|
+
require_verification = false
|
|
42
|
+
allow_registration = true
|
|
43
|
+
|
|
44
|
+
[email]
|
|
45
|
+
backend = "console"
|
|
46
|
+
from_address = "{from_address}"
|
|
47
|
+
from_name = "doctor-test"
|
|
48
|
+
|
|
49
|
+
[sms]
|
|
50
|
+
backend = "null"
|
|
51
|
+
"""
|
|
52
|
+
)
|
|
53
|
+
return cfg, sqlite_path
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@pytest.fixture
|
|
57
|
+
def doctor_env(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> tuple[Path, str]:
|
|
58
|
+
"""Strip ambient REGSTACK_* vars, then set a known JWT secret + DB URL.
|
|
59
|
+
|
|
60
|
+
Returns ``(config_path, jwt_secret)``.
|
|
61
|
+
"""
|
|
62
|
+
for var in list(os.environ):
|
|
63
|
+
if var.startswith("REGSTACK_"):
|
|
64
|
+
monkeypatch.delenv(var, raising=False)
|
|
65
|
+
secret = secrets.token_urlsafe(64)
|
|
66
|
+
cfg_path, sqlite_path = _write_sqlite_config(tmp_path)
|
|
67
|
+
monkeypatch.setenv("REGSTACK_JWT_SECRET", secret)
|
|
68
|
+
monkeypatch.setenv("REGSTACK_DATABASE_URL", f"sqlite+aiosqlite:///{sqlite_path}")
|
|
69
|
+
return cfg_path, secret
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_doctor_reports_schema_missing_then_present(
|
|
73
|
+
doctor_env: tuple[Path, str],
|
|
74
|
+
) -> None:
|
|
75
|
+
"""Pre-install: doctor reports schema missing. Post-install: green."""
|
|
76
|
+
cfg_path, _ = doctor_env
|
|
77
|
+
runner = CliRunner()
|
|
78
|
+
|
|
79
|
+
# Pre-install: schema check fails (alembic_version table missing).
|
|
80
|
+
result = runner.invoke(cli, ["doctor", "--config", str(cfg_path)])
|
|
81
|
+
assert result.exit_code >= 1
|
|
82
|
+
assert "schema" in result.output
|
|
83
|
+
assert "alembic_version table missing" in result.output
|
|
84
|
+
assert "jwt secret" in result.output
|
|
85
|
+
assert "email backend" in result.output
|
|
86
|
+
|
|
87
|
+
# Install schema, then re-run.
|
|
88
|
+
async def _install() -> None:
|
|
89
|
+
async with open_regstack(cfg_path) as rs:
|
|
90
|
+
await rs.install_schema()
|
|
91
|
+
|
|
92
|
+
asyncio.run(_install())
|
|
93
|
+
|
|
94
|
+
result = runner.invoke(cli, ["doctor", "--config", str(cfg_path)])
|
|
95
|
+
assert result.exit_code == 0, result.output
|
|
96
|
+
assert "at head" in result.output
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_doctor_flags_short_jwt_secret(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
|
100
|
+
for var in list(os.environ):
|
|
101
|
+
if var.startswith("REGSTACK_"):
|
|
102
|
+
monkeypatch.delenv(var, raising=False)
|
|
103
|
+
cfg_path, sqlite_path = _write_sqlite_config(tmp_path)
|
|
104
|
+
monkeypatch.setenv("REGSTACK_JWT_SECRET", "too-short")
|
|
105
|
+
monkeypatch.setenv("REGSTACK_DATABASE_URL", f"sqlite+aiosqlite:///{sqlite_path}")
|
|
106
|
+
|
|
107
|
+
runner = CliRunner()
|
|
108
|
+
result = runner.invoke(cli, ["doctor", "--config", str(cfg_path)])
|
|
109
|
+
assert result.exit_code >= 1
|
|
110
|
+
assert "jwt secret" in result.output
|
|
111
|
+
assert "too short" in result.output
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def test_doctor_send_test_email_via_console(doctor_env: tuple[Path, str]) -> None:
|
|
115
|
+
"""--send-test-email succeeds against the console backend (it just prints)."""
|
|
116
|
+
cfg_path, _ = doctor_env
|
|
117
|
+
|
|
118
|
+
# Bring schema up so the schema check passes — otherwise the failed
|
|
119
|
+
# schema check makes doctor exit non-zero and we can't observe the
|
|
120
|
+
# send-test-email check independently.
|
|
121
|
+
async def _install() -> None:
|
|
122
|
+
async with open_regstack(cfg_path) as rs:
|
|
123
|
+
await rs.install_schema()
|
|
124
|
+
|
|
125
|
+
asyncio.run(_install())
|
|
126
|
+
|
|
127
|
+
runner = CliRunner()
|
|
128
|
+
result = runner.invoke(
|
|
129
|
+
cli,
|
|
130
|
+
[
|
|
131
|
+
"doctor",
|
|
132
|
+
"--config",
|
|
133
|
+
str(cfg_path),
|
|
134
|
+
"--send-test-email",
|
|
135
|
+
"probe@example.com",
|
|
136
|
+
],
|
|
137
|
+
)
|
|
138
|
+
assert result.exit_code == 0, result.output
|
|
139
|
+
assert "email send" in result.output
|
|
140
|
+
assert "probe@example.com" in result.output
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def test_doctor_check_dns_runs_lookups(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
|
144
|
+
"""--check-dns runs SPF/DKIM/MX lookups for the sender domain.
|
|
145
|
+
|
|
146
|
+
We use ``example.com`` as the sender — it's RFC 2606 reserved so it
|
|
147
|
+
accepts no traffic, which is fine here: we only care that doctor
|
|
148
|
+
actually invokes the dig probes (the labels appear in output) and
|
|
149
|
+
handles whatever response comes back without crashing.
|
|
150
|
+
"""
|
|
151
|
+
for var in list(os.environ):
|
|
152
|
+
if var.startswith("REGSTACK_"):
|
|
153
|
+
monkeypatch.delenv(var, raising=False)
|
|
154
|
+
cfg_path, sqlite_path = _write_sqlite_config(tmp_path, from_address="probe@example.com")
|
|
155
|
+
monkeypatch.setenv("REGSTACK_JWT_SECRET", secrets.token_urlsafe(64))
|
|
156
|
+
monkeypatch.setenv("REGSTACK_DATABASE_URL", f"sqlite+aiosqlite:///{sqlite_path}")
|
|
157
|
+
|
|
158
|
+
runner = CliRunner()
|
|
159
|
+
result = runner.invoke(cli, ["doctor", "--config", str(cfg_path), "--check-dns"])
|
|
160
|
+
# The schema check fails (we didn't install it), so exit code ≥ 1 —
|
|
161
|
+
# we just care that the DNS check labels are present in output.
|
|
162
|
+
assert "dns mx" in result.output
|
|
163
|
+
assert "dns spf" in result.output
|
|
164
|
+
assert "dns dmarc" in result.output
|