From 9fab773090bae6c16598d737e427fdc2e0d70d8f Mon Sep 17 00:00:00 2001 From: enlineawork Date: Tue, 8 Sep 2026 09:17:30 -0300 Subject: [PATCH] test: assert Survey execution authorization is retired in F4 --- .../survey-execution-authorization.test.ts | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/api-v3/test/unit/survey-execution-authorization.test.ts b/api-v3/test/unit/survey-execution-authorization.test.ts index 9a7f7c4..59be86c 100644 --- a/api-v3/test/unit/survey-execution-authorization.test.ts +++ b/api-v3/test/unit/survey-execution-authorization.test.ts @@ -1,18 +1,24 @@ -import 'reflect-metadata'; import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import path from 'node:path'; 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 controller = SurveyExecutionController.prototype; - const handler = controller[method as keyof typeof controller]; - return Reflect.getMetadata(REQUIRED_PERMISSIONS_KEY, handler) as string[]; -} +const root = process.cwd(); +const migration = fs.readFileSync( + path.join(root, 'src/database/migrations/1790000300000-f4-remove-survey-subsystem.ts'), + 'utf8', +); -test('survey report endpoints separate reading, capture and review', () => { - assert.deepEqual(permissionFor('get'), ['surveys.read_reports']); - assert.deepEqual(permissionFor('save'), ['surveys.capture']); - assert.deepEqual(permissionFor('submit'), ['surveys.capture']); - assert.deepEqual(permissionFor('review'), ['surveys.review']); +test('F4 removes the Survey execution controller from the active API', () => { + assert.equal(fs.existsSync(path.join(root, 'src/survey-execution/survey-execution.controller.ts')), false); + assert.equal(fs.existsSync(path.join(root, 'src/survey-execution/survey-execution.service.ts')), false); +}); + +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/); });