93 lines
3.8 KiB
PHP
93 lines
3.8 KiB
PHP
<?php
|
|
|
|
use App\Services\Intune\PolicyNormalizer;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
beforeEach(function () {
|
|
$this->normalizer = app(PolicyNormalizer::class);
|
|
});
|
|
|
|
it('flattens settings catalog setting instances into a table', function () {
|
|
$snapshot = [
|
|
'@odata.type' => '#microsoft.graph.deviceManagementConfigurationPolicy',
|
|
'settings' => [
|
|
[
|
|
'id' => 's1',
|
|
'settingInstance' => [
|
|
'@odata.type' => '#microsoft.graph.deviceManagementConfigurationSimpleSettingInstance',
|
|
'settingDefinitionId' => 'device_vendor_msft_policy_config_system_minimumpinlength',
|
|
'simpleSettingValue' => [
|
|
'@odata.type' => '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue',
|
|
'value' => 12,
|
|
],
|
|
],
|
|
],
|
|
[
|
|
'id' => 's2',
|
|
'settingInstance' => [
|
|
'@odata.type' => '#microsoft.graph.deviceManagementConfigurationChoiceSettingInstance',
|
|
'settingDefinitionId' => 'device_vendor_msft_policy_config_system_usebiometrics',
|
|
'choiceSettingValue' => [
|
|
'value' => 'device_vendor_msft_policy_config_system_usebiometrics_true',
|
|
],
|
|
],
|
|
],
|
|
[
|
|
'id' => 'group',
|
|
'settingInstance' => [
|
|
'@odata.type' => '#microsoft.graph.deviceManagementConfigurationGroupSettingCollectionInstance',
|
|
'settingDefinitionId' => 'device_vendor_msft_policy_config_system_group',
|
|
'groupSettingCollectionValue' => [
|
|
[
|
|
'children' => [
|
|
[
|
|
'@odata.type' => '#microsoft.graph.deviceManagementConfigurationSimpleSettingInstance',
|
|
'settingDefinitionId' => 'device_vendor_msft_policy_config_system_child',
|
|
'simpleSettingValue' => [
|
|
'value' => true,
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
[
|
|
'id' => 'unknown',
|
|
'settingInstance' => [
|
|
'@odata.type' => '#microsoft.graph.someUnknownSettingInstance',
|
|
'settingDefinitionId' => 'unknown_definition',
|
|
'foo' => 'bar',
|
|
],
|
|
],
|
|
],
|
|
];
|
|
|
|
$result = $this->normalizer->normalize($snapshot, 'settingsCatalogPolicy', 'windows');
|
|
|
|
expect($result['status'])->toBe('success');
|
|
expect($result)->toHaveKey('settings_table');
|
|
|
|
$rows = collect($result['settings_table']['rows']);
|
|
|
|
$minimumPinLength = $rows->firstWhere('definition', 'device_vendor_msft_policy_config_system_minimumpinlength');
|
|
expect($minimumPinLength)->not->toBeNull();
|
|
expect($minimumPinLength['type'])->toBe('SimpleSettingInstance');
|
|
expect($minimumPinLength['value'])->toBe('12');
|
|
|
|
$useBiometrics = $rows->firstWhere('definition', 'device_vendor_msft_policy_config_system_usebiometrics');
|
|
expect($useBiometrics)->not->toBeNull();
|
|
expect($useBiometrics['value'])->toContain('usebiometrics_true');
|
|
|
|
$child = $rows->firstWhere('definition', 'device_vendor_msft_policy_config_system_child');
|
|
expect($child)->not->toBeNull();
|
|
expect($child['value'])->toBe('true');
|
|
expect($child['path'])->toContain('device_vendor_msft_policy_config_system_group');
|
|
|
|
$unknown = $rows->firstWhere('definition', 'unknown_definition');
|
|
expect($unknown)->not->toBeNull();
|
|
expect($unknown['value'])->toContain('foo');
|
|
});
|