diff --git a/tests/helpers/build-test-app.ts b/tests/helpers/build-test-app.ts index d2e6849..02b1a21 100644 --- a/tests/helpers/build-test-app.ts +++ b/tests/helpers/build-test-app.ts @@ -4,9 +4,29 @@ import { authRoutes } from '../../src/routes/auth.js'; import type { MockDb } from '../test-utils.js'; import { createMockDb } from '../test-utils.js'; +/** Mock Redis for login lockout in auth tests. Implements ttl, setex, del, eval. */ +const mockRedis = { + async ttl(_key: string): Promise { + return -2; // key does not exist -> not blocked + }, + async setex(_key: string, _ttl: number, _value: string): Promise<'OK'> { + return 'OK'; + }, + async del(..._keys: string[]): Promise { + return 0; + }, + async eval( + _script: string, + _keysCount: number, + ..._keysAndArgs: string[] + ): Promise { + return [0, 0, 0]; // counters below threshold + }, +}; + /** * Build a minimal Fastify app for auth route integration tests. - * Uses mock db and rate limit options (no actual rate limiting). + * Uses mock db, mock Redis for login lockout, and rate limit options (no actual rate limiting). */ export async function buildAuthTestApp(mockDb?: MockDb): Promise { const db = mockDb ?? createMockDb(); @@ -31,8 +51,8 @@ export async function buildAuthTestApp(mockDb?: MockDb): Promise