F4.5 · SMTP Superadmin y Report Word al Inspector
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
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 { SmtpSettingsController } from '../../src/inspection-reports/smtp-settings.controller';
|
||||
|
||||
function permissions(method: string): string[] {
|
||||
const handler = SmtpSettingsController.prototype[
|
||||
method as keyof SmtpSettingsController
|
||||
];
|
||||
return Reflect.getMetadata(REQUIRED_PERMISSIONS_KEY, handler) as string[];
|
||||
}
|
||||
|
||||
test('F4 SMTP configuration is restricted to the programmer Superadmin permission', () => {
|
||||
assert.deepEqual(permissions('get'), ['system_mail.manage']);
|
||||
assert.deepEqual(permissions('update'), ['system_mail.manage']);
|
||||
assert.deepEqual(permissions('test'), ['system_mail.manage']);
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
|
||||
const root = process.cwd();
|
||||
const read = (relative: string) => fs.readFileSync(path.join(root, relative), 'utf8');
|
||||
|
||||
test('F4 stores SMTP password encrypted and never exposes it through public settings', () => {
|
||||
const crypto = read('src/inspection-reports/smtp-settings-crypto.ts');
|
||||
const settings = read('src/inspection-reports/smtp-settings.service.ts');
|
||||
assert.match(crypto, /aes-256-gcm/);
|
||||
assert.match(settings, /passwordConfigured/);
|
||||
assert.doesNotMatch(settings, /passwordEncrypted:\s*row\.passwordEncrypted/);
|
||||
});
|
||||
|
||||
test('F4 sends the editable Report Word to the responsible Inspector instead of creating new Director deliveries', () => {
|
||||
const delivery = read('src/inspection-reports/inspection-document-delivery.service.ts');
|
||||
assert.match(delivery, /documentKind: 'REPORT_WORD',[\s\S]*recipientKind: 'INSPECTOR'/);
|
||||
assert.doesNotMatch(delivery, /documentKind: 'REPORT_WORD',[\s\S]{0,180}recipientKind: 'DIRECTOR'/);
|
||||
assert.match(delivery, /revisión y edición del inspector responsable antes de su carga en GEDO/);
|
||||
});
|
||||
|
||||
test('F4 keeps ENV SMTP only as migration fallback and prioritizes enabled Superadmin DB settings', () => {
|
||||
const smtp = read('src/inspection-reports/smtp-delivery.service.ts');
|
||||
assert.match(smtp, /source: 'DATABASE'/);
|
||||
assert.match(smtp, /source: 'ENV'/);
|
||||
assert.match(smtp, /FROM smtp_settings/);
|
||||
});
|
||||
Reference in New Issue
Block a user