29 lines
1.7 KiB
TypeScript
29 lines
1.7 KiB
TypeScript
import { expect, it } from 'vitest';
|
|
import { publishContextReport } from '../../src/assessment-context/context-report-publication';
|
|
import { reassignedHeatmapContext } from './context-heatmap-fixture';
|
|
|
|
it('publishes identical cluster membership without stale Other GPO counts and never changes Context', () => {
|
|
const context = reassignedHeatmapContext();
|
|
for (const item of context.settings) item.clusterConfidence = { 'lateral-movement-exposure': 'recognized' };
|
|
const before = JSON.stringify(context);
|
|
const published = publishContextReport(context);
|
|
expect(published.clusters).toHaveLength(22);
|
|
expect(published.clusters.find(item => item.id === 'other-deviations')).toMatchObject({ scanner: 2, gpo: 0 });
|
|
expect(published.clusters.find(item => item.id === 'lateral-movement-exposure')).toMatchObject({ scanner: 0, gpo: 29 });
|
|
expect(published.clusters.find(item => item.id === 'lateral-movement-exposure')!.confidence.recognized).toBe(29);
|
|
expect(published.clusters.find(item => item.id === 'lateral-movement-exposure')!.findingKeys).toHaveLength(29);
|
|
expect(JSON.stringify(context)).toBe(before);
|
|
published.assessmentIds.push('mutated-copy');
|
|
expect(context.assessmentIds).not.toContain('mutated-copy');
|
|
});
|
|
|
|
it('publishes one counting key per GPO setting while retaining every technical result ID', () => {
|
|
const context = reassignedHeatmapContext();
|
|
context.evaluations[0].resultProjectionIds.push('second-backup-result', 'third-baseline-result');
|
|
const before = JSON.stringify(context);
|
|
const cluster = publishContextReport(context).clusters.find(item => item.id === 'lateral-movement-exposure')!;
|
|
expect(cluster.resultIds).toHaveLength(31);
|
|
expect(cluster.findingKeys).toHaveLength(29);
|
|
expect(JSON.stringify(context)).toBe(before);
|
|
});
|