test: assert Survey execution authorization is retired in F4
This commit is contained in:
@@ -1,18 +1,24 @@
|
|||||||
import 'reflect-metadata';
|
|
||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
import { REQUIRED_PERMISSIONS_KEY } from '../../src/authorization/decorators/require-permissions.decorator';
|
|
||||||
import { SurveyExecutionController } from '../../src/survey-execution/survey-execution.controller';
|
|
||||||
|
|
||||||
function permissionFor(method: string): string[] {
|
const root = process.cwd();
|
||||||
const controller = SurveyExecutionController.prototype;
|
const migration = fs.readFileSync(
|
||||||
const handler = controller[method as keyof typeof controller];
|
path.join(root, 'src/database/migrations/1790000300000-f4-remove-survey-subsystem.ts'),
|
||||||
return Reflect.getMetadata(REQUIRED_PERMISSIONS_KEY, handler) as string[];
|
'utf8',
|
||||||
}
|
);
|
||||||
|
|
||||||
test('survey report endpoints separate reading, capture and review', () => {
|
test('F4 removes the Survey execution controller from the active API', () => {
|
||||||
assert.deepEqual(permissionFor('get'), ['surveys.read_reports']);
|
assert.equal(fs.existsSync(path.join(root, 'src/survey-execution/survey-execution.controller.ts')), false);
|
||||||
assert.deepEqual(permissionFor('save'), ['surveys.capture']);
|
assert.equal(fs.existsSync(path.join(root, 'src/survey-execution/survey-execution.service.ts')), false);
|
||||||
assert.deepEqual(permissionFor('submit'), ['surveys.capture']);
|
});
|
||||||
assert.deepEqual(permissionFor('review'), ['surveys.review']);
|
|
||||||
|
test('F4 removes Survey execution and review permissions from active authorization', () => {
|
||||||
|
assert.match(migration, /'surveys\.execute'/);
|
||||||
|
assert.match(migration, /'surveys\.read_reports'/);
|
||||||
|
assert.match(migration, /'surveys\.capture'/);
|
||||||
|
assert.match(migration, /'surveys\.review'/);
|
||||||
|
assert.match(migration, /DELETE FROM role_permissions/);
|
||||||
|
assert.match(migration, /DELETE FROM permissions/);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user