45 lines
2.7 KiB
TypeScript
45 lines
2.7 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { buildReportProjection } from '../../src/reporting/report-projection';
|
|
import type { UnifiedResultProjection } from '../../src/domain/unified-result';
|
|
import { buildTechnicalReportHtml } from '../../src/reporting/technical-report';
|
|
|
|
describe('Technical Report', () => {
|
|
it('renders source-backed actual/expected values, exact GPO instructions and all policy states without scripts', () => {
|
|
const result = {
|
|
resultProjectionId: 'dummy-result', sourceKind: 'policy-evaluation', sourceResultId: 'dummy-source',
|
|
projectId: 'dummy-project', collectionRunId: 'dummy-run', sourceTool: 'GPOs',
|
|
title: '<Dummy Registry Rule>', sourceRuleId: 'registry:dummy', isDeviation: true,
|
|
severityNormalized: 'unknown', outcomeNormalized: 'fail', policyActualValue: 0, policyBaselineValue: 1,
|
|
policyComparisonRelation: 'different', policyDiagnosticCodes: ['dummy-conflict'],
|
|
frameworkReferences: [{ namespace: 'GPOs', value: 'MITRE T1110' }]
|
|
} as unknown as UnifiedResultProjection;
|
|
const projection = buildReportProjection({
|
|
generatedAt: '2026-09-23T10:00:00Z', project: { id: 'dummy-project', name: 'Dummy Customer' },
|
|
results: [result], domains: [{ id: 'gpo', label: 'GPO & Baseline' }], domainOf: () => 'gpo',
|
|
policyEntries: [{ id: 'dummy-setting', verdict: 'Fail', conflict: true, duplicate: false,
|
|
title: 'Dummy Registry Rule', scope: 'machine', identity: 'dummy-key', backupInstanceIds: ['dummy-backup'] }],
|
|
technicalPolicySources: [{ settingId: 'dummy-setting', sources: [{
|
|
id: 'dummy-source', backupInstanceId: 'dummy-backup', gpoId: '{DUMMY-GUID}',
|
|
nativeBackupId: '{DUMMY-BACKUP}', sourceReference: 'dummy/source', sequence: 2,
|
|
values: [{ kind: 'registry-policy', operation: 'set-value', data: 0, typeCode: 'REG_DWORD' }],
|
|
deviationFields: [['data']]
|
|
}] }]
|
|
});
|
|
const html = buildTechnicalReportHtml(projection);
|
|
expect(html).toContain('<html lang="de">');
|
|
expect(html).toContain('<Dummy Registry Rule>');
|
|
expect(html).not.toContain('<Dummy Registry Rule>');
|
|
expect(html).toContain('Konfiguriert');
|
|
expect(html).toContain('Erwartet');
|
|
expect(html).toContain('dummy/source');
|
|
expect(html).toContain('dummy-backup');
|
|
expect(html).toContain('MITRE T1110');
|
|
expect(html).toContain('<dd class="different">0</dd>');
|
|
for (const verdict of ['Deviation', 'Passed', 'Not configured', 'No baseline rule', 'Not comparable', 'Conflicts', 'Duplicates']) {
|
|
expect(html).toContain(verdict);
|
|
}
|
|
expect(html).toContain('effektive Endpunktzustand ist nicht verifiziert');
|
|
expect(html).not.toMatch(/<script\b|<link\b|https?:\/\//i);
|
|
});
|
|
});
|