DC-006: Add integration test for TOTP auth flow
Covers the full BACKLOG DC-006 acceptance criteria: - GET /api/totp/config — read current config - POST /api/totp/setup — generate / import Base32 secret - POST /api/totp/verify-setup — activate TOTP after setup - POST /api/totp/verify — login with TOTP code → session + CSRF - GET /api/totp/check-session — auth gate (200 / 401) - POST /api/totp/disable — disable TOTP (requires valid code) - POST /api/totp/config — update session duration 25 tests, all passing. Uses real otplib for code generation (so we exercise actual TOTP math) but mocks credentialManager, session, totpConfig, saveTotpConfig — those own their own state machines (disk, cookies, file) that don't belong in a routes test. Also fixed a latent DC-005 bug: routes/auth/totp.js had wrong require-path depth after the refactor (../../../src/... went 3 levels up instead of 2, breaking route load). Changed to ../../src/... for the 2-level depth. NOTE: the same depth bug exists in many other depth-2 route files (auth/keys.js, auth/sso-gate.js, auth/session-handlers.js, recipes/*, apps/*, arr/*, config/*) — see BACKLOG.md DC-005 follow-up note. Tests didn't catch this because no test previously imported the auth routes; this new test exercises that import path. Result: 904/904 Jest tests pass (879 baseline + 25 new). ESLint: this file clean. Pre-existing 134 src/ warnings are unrelated (DC-005 refactor moved files without re-applying DC-004 lint cleanup — separate follow-up).
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const express = require('express');
|
||||
const { ValidationError, AuthenticationError } = require('../../../src/utilities/errors');
|
||||
const { ok, successMessage } = require('../src/utils/responses');
|
||||
const { ValidationError, AuthenticationError } = require('../../src/utilities/errors');
|
||||
const { ok, successMessage } = require('../../src/utils/responses');
|
||||
|
||||
/**
|
||||
* Auth TOTP routes factory
|
||||
|
||||
Reference in New Issue
Block a user