feat: Sprachnotizen-API (T7 L2 Task 7)
Upload (Audio nur per Magic Bytes, versiegelt, 2 MiB), Text-Weg, Liste, Abruf, Wiederholen, Verwerfen, alle verwerfen, Konfiguration und Zähler unter /voice-captures. Rechte voice-captures:use plus inspections:create (eigener Guard, API-Schlüssel ausgeschlossen), Zähler nur mit system:manage; jede Abfrage auf den Besitzer begrenzt. Grenzen je Benutzer unter Advisory-Lock (10 offen, 30 je Tag, 10 je 60 s), Wiederholen ebenfalls begrenzt und gedrosselt, Audio für QUEUED nur unter 24 h. Verwerfen löscht Inhalt und Claim sofort. Keine Inhalte in Log oder Audit. Wächter gegen Sprachinhalte in Suche, Export und Berichten erweitert. Refs #27 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
19550d1394
commit
0b0bc3c6dc
21 files changed
+2843
-12
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import type { ExecutionContext } from '@nestjs/common';
|
||||
import { InspectionCreateGuard } from './inspection-create.guard';
|
||||
|
||||
function contextOf(user: { id: string } | undefined): ExecutionContext {
|
||||
return {
|
||||
switchToHttp: () => ({ getRequest: () => ({ user }) }),
|
||||
} as unknown as ExecutionContext;
|
||||
}
|
||||
|
||||
describe('InspectionCreateGuard', () => {
|
||||
it('asks for inspections:create for the signed-in person', async () => {
|
||||
const hasAny = jest.fn().mockResolvedValue(true);
|
||||
const guard = new InspectionCreateGuard({ hasAny } as never);
|
||||
await expect(guard.canActivate(contextOf({ id: 'u1' }))).resolves.toBe(
|
||||
true,
|
||||
);
|
||||
expect(hasAny).toHaveBeenCalledWith('u1', ['inspections:create']);
|
||||
});
|
||||
|
||||
it('denies a person without the right and a request without a person', async () => {
|
||||
const hasAny = jest.fn().mockResolvedValue(false);
|
||||
const guard = new InspectionCreateGuard({ hasAny } as never);
|
||||
await expect(guard.canActivate(contextOf({ id: 'u1' }))).resolves.toBe(
|
||||
false,
|
||||
);
|
||||
await expect(guard.canActivate(contextOf(undefined))).resolves.toBe(false);
|
||||
expect(hasAny).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user