auth-core-fdi.phase2.test.ts57 lines · main
1/**
2 * Phase 2 FDI surface — mount check.
3 * Sets dummy control-plane URL so env/auth side-effects don't crash unit tests.
4 */
5import { beforeAll, describe, expect, test } from 'bun:test';
6import { Hono } from 'hono';
7
8process.env.BRIVEN_DATABASE_URL =
9 process.env.BRIVEN_DATABASE_URL ??
10 'postgres://postgres:devpass@127.0.0.1:5434/postgres?sslmode=disable';
11process.env.BRIVEN_AUTH_CORE_ENABLED = process.env.BRIVEN_AUTH_CORE_ENABLED ?? 'true';
12process.env.BRIVEN_ENGINE_DATABASE_URL =
13 process.env.BRIVEN_ENGINE_DATABASE_URL ??
14 'postgres://postgres:devpass@127.0.0.1:5434/briven_engine?sslmode=disable';
15process.env.BRIVEN_DATA_PLANE_URL =
16 process.env.BRIVEN_DATA_PLANE_URL ??
17 'postgres://postgres:devpass@127.0.0.1:5434/postgres?sslmode=disable';
18
19describe('Phase 2 FDI routes mounted', () => {
20 let app: Hono;
21
22 beforeAll(async () => {
23 const { authCoreFdiRouter } = await import('./auth-core-fdi.js');
24 const { authCoreSessionRouter } = await import('./auth-core-session.js');
25 const { authCoreStatusRouter } = await import('./auth-core-status.js');
26 app = new Hono();
27 app.route('/', authCoreStatusRouter);
28 app.route('/', authCoreFdiRouter);
29 app.route('/', authCoreSessionRouter);
30 });
31
32 test('signup returns not-ready or field error (not 404)', async () => {
33 const res = await app.request('http://localhost/v1/auth-core/fdi/signup', {
34 method: 'POST',
35 headers: { 'content-type': 'application/json' },
36 body: JSON.stringify({}),
37 });
38 expect([400, 503]).toContain(res.status);
39 expect(res.status).not.toBe(404);
40 });
41
42 test('signin returns not-ready or field error (not 404)', async () => {
43 const res = await app.request('http://localhost/v1/auth-core/fdi/signin', {
44 method: 'POST',
45 headers: { 'content-type': 'application/json' },
46 body: JSON.stringify({}),
47 });
48 expect([400, 503]).toContain(res.status);
49 expect(res.status).not.toBe(404);
50 });
51
52 test('session/me returns not-ready or unauthenticated (not 404)', async () => {
53 const res = await app.request('http://localhost/v1/auth-core/session/me');
54 expect([401, 503]).toContain(res.status);
55 expect(res.status).not.toBe(404);
56 });
57});