diff --git a/app/Services/Intune/PolicySnapshotService.php b/app/Services/Intune/PolicySnapshotService.php index aeec01f..c173b1b 100644 --- a/app/Services/Intune/PolicySnapshotService.php +++ b/app/Services/Intune/PolicySnapshotService.php @@ -296,7 +296,13 @@ private function hydrateGroupPolicyConfiguration(string $tenantIdentifier, Tenan } $definitionValues = array_merge($definitionValues, $response->data['value'] ?? []); - $nextPath = $response->data['@odata.nextLink'] ?? null; + $nextLink = $response->data['@odata.nextLink'] ?? null; + + if (! $nextLink) { + break; + } + + $nextPath = $this->stripGraphBaseUrl((string) $nextLink); } if ($hydrationStatus === 'failed') { @@ -368,7 +374,13 @@ private function hydrateGroupPolicyConfiguration(string $tenantIdentifier, Tenan } $presentationValues = array_merge($presentationValues, $pvResponse->data['value'] ?? []); - $presentationNext = $pvResponse->data['@odata.nextLink'] ?? null; + $presentationNextLink = $pvResponse->data['@odata.nextLink'] ?? null; + + if (! $presentationNextLink) { + break; + } + + $presentationNext = $this->stripGraphBaseUrl((string) $presentationNextLink); } if ($presentationValues !== []) { diff --git a/app/Services/Intune/RestoreService.php b/app/Services/Intune/RestoreService.php index 66b0731..4ee0cac 100644 --- a/app/Services/Intune/RestoreService.php +++ b/app/Services/Intune/RestoreService.php @@ -627,7 +627,7 @@ public function execute( 'restore_run_id' => $restoreRun->id, 'backup_item_id' => $item->id, ], - assignments: $restoredAssignments, + assignments: $item->assignments, scopeTags: $scopeTagsForVersion, ); } diff --git a/resources/views/livewire/policy-version-assignments-widget.blade.php b/resources/views/livewire/policy-version-assignments-widget.blade.php index 2f7e0b7..5a593c4 100644 --- a/resources/views/livewire/policy-version-assignments-widget.blade.php +++ b/resources/views/livewire/policy-version-assignments-widget.blade.php @@ -1,4 +1,19 @@
+ @php + $scopeTags = $version->scope_tags['names'] ?? []; + @endphp + @if(!empty($scopeTags)) + +
+ @foreach($scopeTags as $tag) + + {{ $tag }} + + @endforeach +
+
+ @endif + @if($version->assignments && count($version->assignments) > 0)
- @php - $scopeTags = $version->scope_tags['names'] ?? []; - @endphp - @if(!empty($scopeTags)) -
-

Scope Tags

-
- @foreach($scopeTags as $tag) - - {{ $tag }} - - @endforeach -
-
- @endif -

Assignment Details

diff --git a/tests/Feature/Filament/PolicyVersionScopeTagsDisplayTest.php b/tests/Feature/Filament/PolicyVersionScopeTagsDisplayTest.php new file mode 100644 index 0000000..6a9d3e3 --- /dev/null +++ b/tests/Feature/Filament/PolicyVersionScopeTagsDisplayTest.php @@ -0,0 +1,59 @@ + env('INTUNE_TENANT_ID', 'local-tenant'), + 'name' => 'Tenant One', + 'metadata' => [], + 'is_current' => true, + ]); + + putenv('INTUNE_TENANT_ID='.$tenant->tenant_id); + $tenant->makeCurrent(); + + $policy = Policy::create([ + 'tenant_id' => $tenant->id, + 'external_id' => 'policy-1', + 'policy_type' => 'deviceConfiguration', + 'display_name' => 'Policy A', + 'platform' => 'windows', + ]); + + $version = PolicyVersion::create([ + 'tenant_id' => $tenant->id, + 'policy_id' => $policy->id, + 'version_number' => 1, + 'policy_type' => $policy->policy_type, + 'platform' => $policy->platform, + 'created_by' => 'tester@example.com', + 'captured_at' => CarbonImmutable::now(), + 'snapshot' => [ + 'displayName' => 'Policy A', + ], + 'assignments' => null, + 'scope_tags' => [ + 'ids' => ['0', 'scope-1'], + 'names' => ['Default', 'Verbund-1'], + ], + ]); + + $user = User::factory()->create(); + + $response = $this->actingAs($user) + ->get(PolicyVersionResource::getUrl('view', ['record' => $version])); + + $response->assertOk(); + $response->assertSee('Scope Tags'); + $response->assertSee('Default'); + $response->assertSee('Verbund-1'); +}); diff --git a/tests/Feature/Filament/RestoreExecutionTest.php b/tests/Feature/Filament/RestoreExecutionTest.php index 60a4cba..2fd856c 100644 --- a/tests/Feature/Filament/RestoreExecutionTest.php +++ b/tests/Feature/Filament/RestoreExecutionTest.php @@ -49,6 +49,8 @@ public function getServicePrincipalPermissions(array $options = []): GraphRespon } }); + config()->set('graph_contracts.types.deviceConfiguration.assignments_payload_key', 'assignments'); + $tenant = Tenant::create([ 'tenant_id' => 'tenant-1', 'name' => 'Tenant One', @@ -85,6 +87,16 @@ public function getServicePrincipalPermissions(array $options = []): GraphRespon 'scope_tag_ids' => ['0', 'scope-1'], 'scope_tag_names' => ['Default', 'Verbund-1'], ], + 'assignments' => [ + [ + 'target' => [ + '@odata.type' => '#microsoft.graph.groupAssignmentTarget', + 'groupId' => 'group-1', + 'group_display_name' => 'Group One', + ], + 'intent' => 'apply', + ], + ], ]); $user = User::factory()->create(['email' => 'tester@example.com']); @@ -116,6 +128,7 @@ public function getServicePrincipalPermissions(array $options = []): GraphRespon 'ids' => ['0', 'scope-1'], 'names' => ['Default', 'Verbund-1'], ]); + expect($version->assignments)->toBe($backupItem->assignments); }); test('restore execution records foundation mappings', function () {