29 lines
1.8 KiB
TypeScript
29 lines
1.8 KiB
TypeScript
import 'reflect-metadata';
|
|
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { REQUIRED_PERMISSIONS_KEY } from '../../src/authorization/decorators/require-permissions.decorator';
|
|
import { FindingCatalogController } from '../../src/inspection-findings/finding-catalog.controller';
|
|
import {
|
|
InspectionActFindingsController,
|
|
InspectionFindingsController,
|
|
} from '../../src/inspection-findings/inspection-findings.controller';
|
|
|
|
function permissionFor(controller: object, method: string): string[] {
|
|
const handler = controller[method as keyof typeof controller];
|
|
return Reflect.getMetadata(REQUIRED_PERMISSIONS_KEY, handler) as string[];
|
|
}
|
|
|
|
test('F4 finding endpoints separate catalog, content and closure while mutable follow-up is retired', () => {
|
|
assert.deepEqual(permissionFor(FindingCatalogController.prototype, 'list'), ['finding_catalog.read']);
|
|
for (const method of ['adminList', 'createCategory', 'updateCategory', 'createItem', 'updateItem']) {
|
|
assert.deepEqual(permissionFor(FindingCatalogController.prototype, method), ['finding_catalog.manage']);
|
|
}
|
|
assert.deepEqual(permissionFor(InspectionActFindingsController.prototype, 'list'), ['inspection_findings.read']);
|
|
assert.deepEqual(permissionFor(InspectionActFindingsController.prototype, 'create'), ['inspection_findings.create']);
|
|
assert.deepEqual(permissionFor(InspectionFindingsController.prototype, 'list'), ['inspection_findings.read']);
|
|
assert.deepEqual(permissionFor(InspectionFindingsController.prototype, 'get'), ['inspection_findings.read']);
|
|
assert.deepEqual(permissionFor(InspectionFindingsController.prototype, 'update'), ['inspection_findings.update']);
|
|
assert.equal('updateFollowUp' in InspectionFindingsController.prototype, false);
|
|
assert.deepEqual(permissionFor(InspectionFindingsController.prototype, 'close'), ['inspection_findings.close']);
|
|
});
|