feat(security): harden the API, trust Hiboutik for deletions, lock syncs (#3)

This commit is contained in:
2026-11-08 09:36:50 +00:00
parent 6121b9c9bf
commit 04960379e8
31 changed files with 923 additions and 499 deletions

View File

@@ -27,12 +27,12 @@ describe('AppController (e2e)', () => {
});
it('POST /sync starts a synchronization (202)', () => {
hiboutikService.startSync.mockReturnValue(true);
hiboutikService.startSync.mockResolvedValue(true);
return request(app.getHttpServer()).post('/sync').expect(202).expect({ message: 'Hiboutik synchronization started' });
});
it('POST /sync answers 409 when a synchronization is already running', () => {
hiboutikService.startSync.mockReturnValue(false);
hiboutikService.startSync.mockResolvedValue(false);
return request(app.getHttpServer()).post('/sync').expect(409);
});

View File

@@ -3,6 +3,7 @@
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"setupFiles": ["<rootDir>/setup-env.ts"],
"transform": {
"^.+.ts$": "ts-jest",
"^.+.js$": [
@@ -18,6 +19,6 @@
},
"transformIgnorePatterns": ["/node_modules/(?!@nestjs/config/)"],
"moduleNameMapper": {
"^(.{1,2}/.*).js$": "$1"
"^(\\.{1,2}/.*)\\.js$": "$1"
}
}

5
test/setup-env.ts Normal file
View File

@@ -0,0 +1,5 @@
// The e2e test needs neither a database nor Hiboutik, but the app validates its environment at startup: provide dummy values.
process.env.DATABASE_URL ??= 'postgresql://test:test@localhost:5432/test';
process.env.HIBOUTIK_BASE_URL ??= 'https://example.hiboutik.test/api';
process.env.HIBOUTIK_USERNAME ??= 'test';
process.env.HIBOUTIK_PASSWORD ??= 'test';