From 28b120c5797d6f73c18e1a63f0e9b89b2c2347e4 Mon Sep 17 00:00:00 2001 From: Ahmed Darrazi Date: Wed, 7 Jan 2026 02:28:39 +0100 Subject: [PATCH] fix(graph): accept derived odata types --- config/graph_contracts.php | 7 +++++ specs/011-restore-run-wizard/tasks.md | 1 + tests/Pest.php | 3 ++ tests/Unit/ODataTypeValidationTest.php | 38 ++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 tests/Unit/ODataTypeValidationTest.php diff --git a/config/graph_contracts.php b/config/graph_contracts.php index 6c6ac67..856eb14 100644 --- a/config/graph_contracts.php +++ b/config/graph_contracts.php @@ -19,6 +19,8 @@ 'type_family' => [ '#microsoft.graph.deviceConfiguration', '#microsoft.graph.windows10CustomConfiguration', + '#microsoft.graph.windows10GeneralConfiguration', + '#microsoft.graph.windowsHealthMonitoringConfiguration', '#microsoft.graph.iosGeneralDeviceConfiguration', '#microsoft.graph.androidGeneralDeviceConfiguration', '#microsoft.graph.macOSGeneralDeviceConfiguration', @@ -165,6 +167,8 @@ '#microsoft.graph.windows10CompliancePolicy', '#microsoft.graph.iosCompliancePolicy', '#microsoft.graph.androidCompliancePolicy', + '#microsoft.graph.androidDeviceOwnerCompliancePolicy', + '#microsoft.graph.androidWorkProfileCompliancePolicy', '#microsoft.graph.macOSCompliancePolicy', ], 'create_method' => 'POST', @@ -190,6 +194,7 @@ '#microsoft.graph.targetedManagedAppProtection', '#microsoft.graph.iosManagedAppProtection', '#microsoft.graph.androidManagedAppProtection', + '#microsoft.graph.windowsManagedAppProtection', '#microsoft.graph.windowsInformationProtectionPolicy', '#microsoft.graph.mdmWindowsInformationProtectionPolicy', ], @@ -289,6 +294,8 @@ 'type_family' => [ '#microsoft.graph.deviceEnrollmentConfiguration', '#microsoft.graph.windows10EnrollmentCompletionPageConfiguration', + '#microsoft.graph.deviceEnrollmentWindowsHelloForBusinessConfiguration', + '#microsoft.graph.windowsRestoreDeviceEnrollmentConfiguration', ], 'create_method' => 'POST', 'update_method' => 'PATCH', diff --git a/specs/011-restore-run-wizard/tasks.md b/specs/011-restore-run-wizard/tasks.md index e6c7b48..f20fb48 100644 --- a/specs/011-restore-run-wizard/tasks.md +++ b/specs/011-restore-run-wizard/tasks.md @@ -38,6 +38,7 @@ ## Phase 7 — Tests + Formatting - [x] T018 Add Pest tests for wizard gating rules and status transitions. - [x] T019 Add Pest tests for safety checks persistence and blocking behavior. - [x] T020 Add Pest tests for preview summary generation. +- [x] T024 Fix Graph contract type families to accept valid derived @odata.type values during restore. - [x] T021 Run `./vendor/bin/pint --dirty`. - [x] T022 Run targeted tests (e.g. `./vendor/bin/sail artisan test --filter=RestoreRunWizard` once tests exist). diff --git a/tests/Pest.php b/tests/Pest.php index 4baf965..2e65b3a 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -17,6 +17,9 @@ ->use(RefreshDatabase::class) ->in('Feature'); +pest()->extend(Tests\TestCase::class) + ->in('Unit'); + beforeEach(function () { putenv('INTUNE_TENANT_ID'); unset($_ENV['INTUNE_TENANT_ID'], $_SERVER['INTUNE_TENANT_ID']); diff --git a/tests/Unit/ODataTypeValidationTest.php b/tests/Unit/ODataTypeValidationTest.php new file mode 100644 index 0000000..b4cd370 --- /dev/null +++ b/tests/Unit/ODataTypeValidationTest.php @@ -0,0 +1,38 @@ + $odataType], 'deviceConfiguration', 'all'); + + expect($result['matches'])->toBeTrue(); +})->with([ + '#microsoft.graph.windows10GeneralConfiguration', + '#microsoft.graph.windowsHealthMonitoringConfiguration', +]); + +it('accepts derived deviceCompliancePolicy odata types', function (string $odataType) { + $result = BackupItem::validateODataType(['@odata.type' => $odataType], 'deviceCompliancePolicy', 'all'); + + expect($result['matches'])->toBeTrue(); +})->with([ + '#microsoft.graph.androidDeviceOwnerCompliancePolicy', + '#microsoft.graph.androidWorkProfileCompliancePolicy', +]); + +it('accepts derived appProtectionPolicy odata types', function (string $odataType) { + $result = BackupItem::validateODataType(['@odata.type' => $odataType], 'appProtectionPolicy', 'mobile'); + + expect($result['matches'])->toBeTrue(); +})->with([ + '#microsoft.graph.windowsManagedAppProtection', +]); + +it('accepts derived enrollmentRestriction odata types', function (string $odataType) { + $result = BackupItem::validateODataType(['@odata.type' => $odataType], 'enrollmentRestriction', 'all'); + + expect($result['matches'])->toBeTrue(); +})->with([ + '#microsoft.graph.deviceEnrollmentWindowsHelloForBusinessConfiguration', + '#microsoft.graph.windowsRestoreDeviceEnrollmentConfiguration', +]);