import { describe, expect, it } from 'vitest'; import { annotateWindowsCodes, wellKnownSidName } from '../../src/shared/windows-codes'; const meanings = (text: string) => annotateWindowsCodes(text).filter(segment => segment.meaning).map(segment => [segment.text, segment.meaning]); describe('standard Windows code meanings', () => { it('names well-known SIDs, standardized domain RIDs, user rights and registry types', () => { expect(meanings('Expected: Values:\n *S-1-5-32-544\n *S-1-5-32-555'.split('\n')[1] + ' ' + '*S-1-5-32-555')).toEqual([ ['*S-1-5-32-544', 'Administrators'], ['*S-1-5-32-555', 'Remote Desktop Users']]); expect(wellKnownSidName('*S-1-5-21-111-222-333-500')).toBe('Administrator (built-in account)'); expect(meanings('Computer policy: Privilege Rights · SeNetworkLogonRight')).toEqual([['SeNetworkLogonRight', 'Access this computer from the network']]); expect(meanings('Type code: 4')).toEqual([['Type code: 4', 'REG_DWORD']]); expect(meanings('0 (registry type 4)')).toEqual([['registry type 4', 'REG_DWORD']]); }); it('keeps unknown or customer-specific codes and longer tokens plain and never repeats a stated meaning', () => { expect(meanings('*S-1-5-21-111-222-333-1105 · *S-1-5-32-5440 · SeSyntheticUnknownRight · Type code: 99')).toEqual([]); expect(meanings('*S-1-5-32-544 (Administrators)')).toEqual([]); expect(annotateWindowsCodes('No codes here.')).toEqual([{ text: 'No codes here.' }]); }); });