Files
xenia-pos-local/local_backend/tests/guards
bonaminandClaude Opus 5.5 9f1e12156e feat(backend): DB sessions, login modes, single-session rules
Platform v2 step 1.6 (APPS_PLATFORM D-8, D-9, §6.2, §6.4).
- sessions table (revision 0006); every JWT carries `sid` and is accepted
  only while its session is active (validated per request, 10 s cache that
  is dropped the moment a session ends); the in-memory blacklist is gone, so
  logout and "end session" survive restarts
- one login path, POST /api/auth/login {client, username?, user_id?, pin?,
  password?}: manager mode password|pin (username-only "none" removed, D-8),
  waiter mode pin|password|tap (tap answers auth.mode_needs_device until
  paired devices exist), optional "waiter must type username", and the app's
  access key (core.dashboard.access / waiter_app.access)
- auth.single_session_manager / _waiter: off | refuse_new | end_old
- /login without `client` = the current manager UI with v1 rules (pin or
  password; refuse_new treated as end_old because its lock screen re-logs-in);
  /login-by-id is a deprecated wrapper for the current waiter app;
  /login-no-auth removed
- GET /api/auth/sessions, POST /api/auth/sessions/{id}/end (core.staff.manage);
  blocking a user ends their sessions; refresh keeps the session; logout
  takes the bearer header (or ?token= as before)
- settings API validates enum/bool/int values from the manifests;
  security.login_method migrated to auth.manager_login_mode
- tests: modes, single-session rules, logout, refresh, forged token without
  session, manager session list/end

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 19:13:00 +02:00
..

Guard tests (APPS_PLATFORM D-17)

Tests that protect platform-wide rules rather than one feature. They must stay green; if one fails, fix the code, not the guard. Changing a guard's rule is a design decision: record it in APPS_PLATFORM §2 first.

File Rule Filled in
test_migrations.py Models and Alembic revisions don't drift; AUTOINCREMENT survives batch rebuilds; the schema is built only by Alembic; v1 databases are refused; revision data backfills steps 1.0, 1.1
test_no_naive_time.py No datetime.utcnow/datetime.now, date.today(), argument-less .astimezone(), tz-less fromtimestamp, or Column(DateTime outside core/timeutil.py step 1.1
test_route_access.py Every route declares require(...), require_device(...) or public() step 1.5 (placeholder until then)