66 lines
2.1 KiB
PHP
66 lines
2.1 KiB
PHP
<?php
|
|
|
|
use App\Services\Intune\PolicyNormalizer;
|
|
|
|
beforeEach(function () {
|
|
$this->normalizer = app(PolicyNormalizer::class);
|
|
});
|
|
|
|
it('normalizes oma uri settings', function () {
|
|
$snapshot = [
|
|
'@odata.type' => '#microsoft.graph.windows10CustomConfiguration',
|
|
'omaSettings' => [
|
|
[
|
|
'displayName' => 'Setting A',
|
|
'omaUri' => './Vendor/MSFT/SettingA',
|
|
'value' => 'Enabled',
|
|
],
|
|
],
|
|
];
|
|
|
|
$result = $this->normalizer->normalize($snapshot, 'deviceConfiguration', 'windows');
|
|
|
|
expect($result['status'])->toBe('success');
|
|
expect($result['warnings'])->toBe([]);
|
|
expect($result['settings'][0]['type'])->toBe('table');
|
|
expect($result['settings'][0]['rows'][0]['path'])->toBe('./Vendor/MSFT/SettingA');
|
|
expect($result['settings'][0]['rows'][0]['value'])->toBe('Enabled');
|
|
});
|
|
|
|
it('normalizes settings catalog structures', function () {
|
|
$snapshot = [
|
|
'settings' => [
|
|
[
|
|
'displayName' => 'Enable feature',
|
|
'value' => ['value' => 'on'],
|
|
],
|
|
],
|
|
];
|
|
|
|
$result = $this->normalizer->normalize($snapshot, 'deviceConfiguration', 'windows');
|
|
|
|
expect($result['settings'][0]['type'])->toBe('keyValue');
|
|
expect($result['settings'][0]['entries'][0]['key'])->toBe('Enable feature');
|
|
expect($result['settings'][0]['entries'][0]['value'])->toContain('on');
|
|
});
|
|
|
|
it('adds warning for malformed snapshots', function () {
|
|
$snapshot = ['only', 'values'];
|
|
|
|
$result = $this->normalizer->normalize($snapshot, 'deviceConfiguration', 'windows');
|
|
|
|
expect($result['status'])->toBe('warning');
|
|
expect($result['warnings'])->toContain('This snapshot may be incomplete or malformed');
|
|
});
|
|
|
|
it('detects @odata.type mismatch', function () {
|
|
$snapshot = [
|
|
'@odata.type' => '#microsoft.graph.iosGeneralDeviceConfiguration',
|
|
'displayName' => 'Policy',
|
|
];
|
|
|
|
$result = $this->normalizer->normalize($snapshot, 'deviceConfiguration', 'windows');
|
|
|
|
expect(collect($result['warnings'])->join(' '))->toContain('@odata.type mismatch');
|
|
});
|