Files
dh-inspeccion-v2/api-v3/test/unit/phase-f4-smtp-delivery.test.ts
T

30 lines
1.5 KiB
TypeScript

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/);
});