- FakeRedis mounted on test_auth_deps and admin_client fixtures - 9 xfail(strict=False) stubs covering all Phase 7.2 behaviors - 73 baseline tests pass, zero regressions
7.1 KiB
phase, plan, subsystem, tags, dependency_graph, tech_stack, key_files, decisions, metrics
| phase | plan | subsystem | tags | dependency_graph | tech_stack | key_files | decisions | metrics | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 07.2-security-jti-claim-redis-access-token-revocation-inserted | 01 | testing |
|
|
|
|
|
|
Phase 07.2 Plan 01: Wave 0 Test Scaffolding Summary
One-liner: FakeRedis mounted on two test fixtures + 9 xfail stubs covering every Phase 7.2 behavior (jti, NBF check × 3, NBF write × 4, negative-guard × 1).
What Was Built
This plan is the Nyquist Wave 0 scaffolding for Phase 7.2. It creates no implementation code — only test stubs that define the expected behaviors before any code in services/auth.py, deps/auth.py, api/auth.py, or api/admin.py is modified.
Task 1: FakeRedis on test_auth_deps + NBF-check stubs
test_auth_deps.py: addedfrom tests.test_auth_api import FakeRedisimportmake_test_app(): now setstest_app.state.redis = FakeRedis()before returning- Added 3 xfail stubs with
@pytest.mark.xfail(strict=False):test_get_current_user_rejects_token_when_iat_before_user_nbftest_get_current_user_allows_token_when_iat_after_user_nbftest_get_current_user_failopen_on_redis_error(uses inline_BrokenRedisclass)
Task 2: JTI presence stub in test_task2_auth_service.py
- Added
test_create_access_token_includes_jti_claimdecorated withxfail(strict=False) - Calls
create_access_token+decode_access_token, asserts"jti"key present and parseable asuuid.UUID
Task 3: NBF-write stubs for change_password/enable_totp/disable_totp
- Added 3 xfail stubs to
test_auth_api.py:test_change_password_writes_user_nbf_to_redistest_enable_totp_writes_user_nbf_to_redistest_disable_totp_writes_user_nbf_to_redis
- Each test exercises the full auth flow then calls
pytest.xfail()as the Wave 0 body
Task 4: FakeRedis on admin_client + deactivation NBF-write stubs
test_admin_api.py: addedfrom tests.test_auth_api import FakeRedisadmin_clientfixture: setsapp.state.redis = FakeRedis()before client yield, resets toNoneafter- Added 2 xfail stubs:
test_deactivate_user_writes_user_nbf_to_redis(positive case)test_activate_user_does_not_write_user_nbf(negative-guard — activation must NOT write user_nbf)
Verification
Baseline container test run: 73 passed (across the 4 modified test files) — zero new failures.
Full project baseline: 373 passed (Phase 7.1 complete state) — confirmed unaffected.
Acceptance criteria checks:
grep -c "FakeRedis" test_auth_deps.py→ 6 (import + assignment + stubs)grep -c "test_app.state.redis" test_auth_deps.py→ 1- 3 new NBF-check test functions in test_auth_deps.py
- 3 xfail markers in test_auth_deps.py
test_create_access_token_includes_jti_claimin test_task2_auth_service.py- 3 NBF-write test functions in test_auth_api.py
from tests.test_auth_api import FakeRedisin test_admin_api.pyapp.state.redis = FakeRedis()in admin_client fixture- 2 deactivation NBF stubs in test_admin_api.py
Commits
| Task | Commit | Description |
|---|---|---|
| 1 | 49c6333 |
test(07.2-01): mount FakeRedis on test_auth_deps app + add NBF-check xfail stubs |
| 2 | c686d90 |
test(07.2-01): add JTI claim xfail stub to test_task2_auth_service.py |
| 3 | 097cdca |
test(07.2-01): add NBF-write xfail stubs for change_password/enable_totp/disable_totp |
| 4 | eb16472 |
test(07.2-01): add FakeRedis to admin_client + NBF-write xfail stubs for deactivation |
Deviations from Plan
None — plan executed exactly as written.
Known Stubs
All 9 new test functions are intentional Wave 0 stubs. They are xfailed with strict=False and carry assert False, "stub" or pytest.xfail() in their bodies. Wave 1 (Plan 02) and Wave 2 (Plan 03) will promote them to passing assertions by replacing the stub bodies with real assertion logic. These are tracked in the plan and are the intended output of this wave.
Patterns Established
- FakeRedis import pattern: always
from tests.test_auth_api import FakeRedis— never redefine in another file - FakeRedis on test_auth_deps:
test_app.state.redis = FakeRedis()insidemake_test_app()— fresh instance per test invocation - FakeRedis teardown:
app.state.redis = Noneafter fixture yield — prevents state leak across test files - Wave 0 body convention:
assert False, "stub — Wave N will fill in: <target assertion>"orpytest.xfail("stub")— no real assertion logic
Patterns to Avoid
- Do NOT redefine
FakeRedisintest_auth_deps.py,test_admin_api.py, or any other file — import fromtests.test_auth_apionly - Do NOT add
app.state.redis = Nonereset inside the fixture loop — only in teardown after yield
Threat Flags
None — this plan only modifies test files and introduces no new network endpoints, auth paths, or schema changes.
Self-Check: PASSED
backend/tests/test_auth_deps.pymodified and committed (49c6333)backend/tests/test_task2_auth_service.pymodified and committed (c686d90)backend/tests/test_auth_api.pymodified and committed (097cdca)backend/tests/test_admin_api.pymodified and committed (eb16472)- All 4 commits exist:
git log --oneline -4confirmseb16472,097cdca,c686d90,49c6333 - 73 baseline tests pass in container (zero regressions)
- All 9 Wave 0 stubs present and correctly decorated with xfail(strict=False)