auth-reliability.test.ts26 lines · main
| 1 | import { describe, expect, test } from 'bun:test'; |
| 2 | |
| 3 | import { |
| 4 | getAuthReliabilitySnapshot, |
| 5 | recordAuthMailerFailure, |
| 6 | recordAuthRateLimitDenied, |
| 7 | recordAuthRoute5xx, |
| 8 | resetAuthReliabilityCountersForTests, |
| 9 | } from './auth-reliability.js'; |
| 10 | |
| 11 | describe('auth-reliability snapshot (S6.3)', () => { |
| 12 | test('records counters and returns operator watch list', async () => { |
| 13 | resetAuthReliabilityCountersForTests(); |
| 14 | recordAuthRateLimitDenied('memory'); |
| 15 | recordAuthMailerFailure('briven_auth_magic_link'); |
| 16 | recordAuthRoute5xx(); |
| 17 | |
| 18 | const snap = await getAuthReliabilitySnapshot(); |
| 19 | expect(snap.counters.rateLimitDenied).toBeGreaterThanOrEqual(1); |
| 20 | expect(snap.counters.mailerFailures).toBeGreaterThanOrEqual(1); |
| 21 | expect(snap.counters.authRoute5xx).toBeGreaterThanOrEqual(1); |
| 22 | expect(snap.watch.length).toBeGreaterThan(0); |
| 23 | expect(snap.isolation.claim.toLowerCase()).toContain('project'); |
| 24 | expect(typeof snap.redisConfigured).toBe('boolean'); |
| 25 | }); |
| 26 | }); |