mirror of
https://github.com/siop-spelev/siop2.git
synced 2026-08-08 12:41:54 +00:00
- packages/shared : rôles/catégories, schémas Zod, contrat d'API ; pnpm contract → docs/openapi.json committée (règle d'or ADR-001) - apps/api : NestJS 11 + Prisma 6, migration r0_identity (Role/Permission/User) ; guard JWT global + @Public() ; PermissionsGuard (@RequirePermission, matrice relue en base, cache 60 s) ; FileStorage (seul import MinIO) ; /health - démo-login ADR-002 : module conditionnel DEMO_MODE (404 sinon, testé e2e), double verrou production, refus des comptes isDemo=false - seed idempotent : 7 rôles, matrice complète (70 lignes), 7 comptes démo - 19 tests Jest (unit + e2e) ; smoke test sur build de prod Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
/**
|
|
* ADR-002, test dédié : quand DEMO_MODE n'est pas actif, les routes démo
|
|
* N'EXISTENT PAS (404) — le module n'est pas enregistré.
|
|
*/
|
|
// « false » plutôt que delete : dotenv (importé par config/env.ts) repeuplerait
|
|
// une variable supprimée depuis .env, mais n'écrase jamais une valeur existante.
|
|
process.env.DEMO_MODE = 'false';
|
|
|
|
import { INestApplication } from '@nestjs/common';
|
|
import { Test } from '@nestjs/testing';
|
|
import request from 'supertest';
|
|
import { AppModule } from '../src/app.module';
|
|
|
|
describe('Auth démo (e2e, DEMO_MODE absent)', () => {
|
|
let app: INestApplication;
|
|
|
|
beforeAll(async () => {
|
|
const moduleRef = await Test.createTestingModule({
|
|
imports: [AppModule.forRoot()],
|
|
}).compile();
|
|
app = moduleRef.createNestApplication();
|
|
await app.init();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await app?.close();
|
|
});
|
|
|
|
it('GET /auth/demo-accounts → 404', async () => {
|
|
await request(app.getHttpServer()).get('/auth/demo-accounts').expect(404);
|
|
});
|
|
|
|
it('POST /auth/demo-login → 404', async () => {
|
|
await request(app.getHttpServer())
|
|
.post('/auth/demo-login')
|
|
.send({ userId: '00000000-0000-4000-8000-000000000000' })
|
|
.expect(404);
|
|
});
|
|
|
|
it('la connexion classique, elle, reste disponible', async () => {
|
|
// 401 (identifiants) et non 404 : la route existe bien
|
|
await request(app.getHttpServer())
|
|
.post('/auth/login')
|
|
.send({ email: 'nobody@spelev.ma', password: 'x' })
|
|
.expect(401);
|
|
});
|
|
});
|