56 lines
1.8 KiB
PHP
56 lines
1.8 KiB
PHP
<?php
|
|
|
|
use App\Services\Intune\PolicyNormalizer;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
it('normalizes deviceManagementScript into readable settings', function () {
|
|
$normalizer = app(PolicyNormalizer::class);
|
|
|
|
$snapshot = [
|
|
'@odata.type' => '#microsoft.graph.deviceManagementScript',
|
|
'displayName' => 'My PS script',
|
|
'description' => 'Does a thing',
|
|
'scriptContent' => str_repeat('A', 10),
|
|
'runFrequency' => 'weekly',
|
|
];
|
|
|
|
$result = $normalizer->normalize($snapshot, 'deviceManagementScript', 'windows');
|
|
|
|
expect($result['status'])->toBe('ok');
|
|
expect($result['settings'])->toBeArray()->not->toBeEmpty();
|
|
expect(collect($result['settings'])->pluck('key')->all())->toContain('Display name');
|
|
});
|
|
|
|
it('normalizes deviceShellScript into readable settings', function () {
|
|
$normalizer = app(PolicyNormalizer::class);
|
|
|
|
$snapshot = [
|
|
'@odata.type' => '#microsoft.graph.deviceShellScript',
|
|
'displayName' => 'My macOS shell script',
|
|
'scriptContent' => str_repeat('B', 5),
|
|
];
|
|
|
|
$result = $normalizer->normalize($snapshot, 'deviceShellScript', 'macOS');
|
|
|
|
expect($result['status'])->toBe('ok');
|
|
expect($result['settings'])->toBeArray()->not->toBeEmpty();
|
|
});
|
|
|
|
it('normalizes deviceHealthScript into readable settings', function () {
|
|
$normalizer = app(PolicyNormalizer::class);
|
|
|
|
$snapshot = [
|
|
'@odata.type' => '#microsoft.graph.deviceHealthScript',
|
|
'displayName' => 'My remediation',
|
|
'detectionScriptContent' => str_repeat('C', 3),
|
|
'remediationScriptContent' => str_repeat('D', 4),
|
|
];
|
|
|
|
$result = $normalizer->normalize($snapshot, 'deviceHealthScript', 'windows');
|
|
|
|
expect($result['status'])->toBe('ok');
|
|
expect($result['settings'])->toBeArray()->not->toBeEmpty();
|
|
});
|