18 lines
848 B
TypeScript
18 lines
848 B
TypeScript
import 'reflect-metadata';
|
|
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { AssetHistoryController } from '../../src/asset-master/asset-history.controller';
|
|
import { REQUIRED_PERMISSIONS_KEY } from '../../src/authorization/decorators/require-permissions.decorator';
|
|
|
|
function permissionFor(method: string): string[] {
|
|
const controller = AssetHistoryController.prototype;
|
|
const handler = controller[method as keyof typeof controller];
|
|
return Reflect.getMetadata(REQUIRED_PERMISSIONS_KEY, handler) as string[];
|
|
}
|
|
|
|
test('all asset history endpoints require the dedicated permission', () => {
|
|
assert.deepEqual(permissionFor('list'), ['assets.read_history']);
|
|
assert.deepEqual(permissionFor('listForAsset'), ['assets.read_history']);
|
|
assert.deepEqual(permissionFor('getVersion'), ['assets.read_history']);
|
|
});
|