40 lines
1.9 KiB
TypeScript
40 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { makeSheet } from '../../src/importers/sheet-factory';
|
|
import { detectScanTool, purpleKnightDetectionScore } from '../../src/profiles/purple-knight/detector';
|
|
import { matchesPurpleKnightStatus } from '../../src/profiles/purple-knight/filters';
|
|
import { prioritizePurpleKnightSheets } from '../../src/profiles/purple-knight/purple-knight-profile';
|
|
|
|
const assessment = makeSheet('Assessment', [['Metric', 'Value'], ['Score', '72']], '', 'synthetic.xlsx', { workbookIndex: 0 });
|
|
const indicators = makeSheet(
|
|
'Indicator Results',
|
|
[
|
|
['Name', 'Short Name', 'SI Version', 'Severity', 'Weight', 'Category', 'Result'],
|
|
['Synthetic A', 'SYN-001', '1', 'High', '10', 'Synthetic', 'IOEs found'],
|
|
['Synthetic B', 'SYN-002', '1', 'Low', '2', 'Synthetic', 'Passed'],
|
|
['Synthetic C', 'SYN-003', '1', 'Info', '0', 'Synthetic', 'Not selected']
|
|
],
|
|
'',
|
|
'synthetic.xlsx',
|
|
{ workbookIndex: 1 }
|
|
);
|
|
|
|
describe('Purple Knight profile', () => {
|
|
it('detects Purple Knight from synthetic schema signals', () => {
|
|
const context = { fileName: 'synthetic-security-assessment.xlsx', rawText: '', sheets: [assessment, indicators] };
|
|
expect(purpleKnightDetectionScore(context)).toBeGreaterThanOrEqual(60);
|
|
expect(detectScanTool(context)).toBe('PurpleKnight');
|
|
});
|
|
|
|
it('prioritizes Indicator Results', () => {
|
|
expect(prioritizePurpleKnightSheets([assessment, indicators])[0].name).toBe('Indicator Results');
|
|
});
|
|
|
|
it('preserves Purple Knight status filters', () => {
|
|
const [ioe, passed, notSelected] = indicators.analysis.records;
|
|
expect(matchesPurpleKnightStatus(ioe, 'ioes-found')).toBe(true);
|
|
expect(matchesPurpleKnightStatus(passed, 'passed')).toBe(true);
|
|
expect(matchesPurpleKnightStatus(notSelected, 'not-selected')).toBe(true);
|
|
expect(matchesPurpleKnightStatus(passed, 'ioes-found')).toBe(false);
|
|
});
|
|
});
|