Assessor_2.0/tests/features/report-security-domains.tes...

32 lines
2.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import type { FindingRecord } from '../../src/domain/finding';
import type { UnifiedResultProjection } from '../../src/domain/unified-result';
import { securityDomainCatalog, securityDomainIdForRecord, securityDomainIdForUnifiedResult } from '../../src/features/dashboard/security-domains';
const titles: Record<string, string> = {
identity: 'Inactive user accounts', privilege: 'Privileged admin delegation',
authentication: 'Legacy Kerberos authentication', infrastructure: 'Domain controller replication',
hardening: 'Print Spooler hardening', gpo: 'Group Policy baseline setting',
cloud: 'Entra application access', recovery: 'Audit logging and backup'
};
describe('shared report security-domain assignment', () => {
it('agrees with Work for all eight catalog entries, explicit GPO and honest Unclassified', () => {
for (const domain of securityDomainCatalog) {
const title = titles[domain.id];
const record = { title, fields: [] } as unknown as FindingRecord;
const result = { title, description: '', sourceKind: 'scanner-finding', categories: [] } as unknown as UnifiedResultProjection;
expect(securityDomainIdForRecord(record)).toBe(domain.id);
expect(securityDomainIdForUnifiedResult(result)).toBe(domain.id);
}
const gpoRecord = { title: 'Synthetic setting', fields: [{ label: 'Category', value: 'GPOs', index: 0 }] } as FindingRecord;
const gpoResult = { title: 'Synthetic setting', sourceKind: 'policy-evaluation', categories: [] } as unknown as UnifiedResultProjection;
expect(securityDomainIdForRecord(gpoRecord)).toBe('gpo');
expect(securityDomainIdForUnifiedResult(gpoResult)).toBe('gpo');
const unknownRecord = { title: 'Unmapped synthetic control', fields: [] } as unknown as FindingRecord;
const unknownResult = { title: unknownRecord.title, sourceKind: 'scanner-finding', categories: [] } as unknown as UnifiedResultProjection;
expect(securityDomainIdForRecord(unknownRecord)).toBe('unclassified');
expect(securityDomainIdForUnifiedResult(unknownResult)).toBe('unclassified');
});
});