Files
compras/tests/Unit/ReplenishmentTaskDefinitionTest.php
T
nala 96b30368bc
tests / ci (push) Canceled after 0s
commit compras5 2911
2026-11-29 19:49:19 +02:00

14 lines
1.3 KiB
PHP

<?php
use App\Services\ReplenishmentTaskDefinition;
test('native omitted limited run level remains equivalent but elevation and frequency changes are refused', function () {
$xml = '<Task xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"><Triggers><TimeTrigger><Repetition><Interval>PT1M</Interval></Repetition></TimeTrigger><LogonTrigger><UserId>S-1-5-21-1</UserId></LogonTrigger></Triggers><Principals><Principal><UserId>S-1-5-21-1</UserId><LogonType>InteractiveToken</LogonType><RunLevel>LeastPrivilege</RunLevel></Principal></Principals><Actions><Exec><Command>C:/synthetic/php-win.exe</Command></Exec></Actions></Task>';
$xml = str_replace('<Actions>', '<Settings><AllowHardTerminate>true</AllowHardTerminate></Settings><Actions>', $xml);
ReplenishmentTaskDefinition::assertMatches($xml, str_replace(['<RunLevel>LeastPrivilege</RunLevel>', '<AllowHardTerminate>true</AllowHardTerminate>'], '', $xml));
expect(true)->toBeTrue();
foreach ([str_replace('LeastPrivilege', 'HighestAvailable', $xml), str_replace('PT1M', 'PT5M', $xml), str_replace('S-1-5-21-1', 'S-1-5-18', $xml), str_replace('<AllowHardTerminate>true', '<AllowHardTerminate>false', $xml)] as $changed) {
expect(fn () => ReplenishmentTaskDefinition::assertMatches($xml, $changed))->toThrow(LogicException::class);
}
});