## Summary - Capture and restore foundation types (assignment filters, scope tags, notification templates) with deterministic mapping. - Apply foundation mappings during restore (scope tags on policy payloads, assignment filter mapping with skip reasons). - Improve restore run UX (item selection, rerun action, preview-only badges). - Enforce preview-only policy types (e.g. Conditional Access) during execution. ## Testing - ./vendor/bin/sail artisan test tests/Feature/Filament/ConditionalAccessPreviewOnlyTest.php ## Notes - Specs/plan/tasks updated under specs/006-sot-foundations-assignments. - No migrations. Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local> Reviewed-on: #7
96 lines
3.1 KiB
PHP
96 lines
3.1 KiB
PHP
<?php
|
|
|
|
use App\Models\BackupItem;
|
|
use App\Models\Policy;
|
|
use App\Models\Tenant;
|
|
use App\Services\Intune\BackupService;
|
|
use App\Services\Intune\FoundationSnapshotService;
|
|
use App\Services\Intune\PolicySnapshotService;
|
|
use Mockery\MockInterface;
|
|
|
|
beforeEach(function () {
|
|
$this->tenant = Tenant::factory()->create(['status' => 'active']);
|
|
|
|
$this->policy = Policy::factory()->create([
|
|
'tenant_id' => $this->tenant->id,
|
|
'policy_type' => 'deviceConfiguration',
|
|
'platform' => 'windows',
|
|
'display_name' => 'Test Policy',
|
|
]);
|
|
|
|
config()->set('tenantpilot.foundation_types', [
|
|
[
|
|
'type' => 'assignmentFilter',
|
|
'label' => 'Assignment Filter',
|
|
'category' => 'Foundations',
|
|
'platform' => 'all',
|
|
'endpoint' => 'deviceManagement/assignmentFilters',
|
|
'backup' => 'full',
|
|
'restore' => 'enabled',
|
|
'risk' => 'low',
|
|
],
|
|
]);
|
|
|
|
$this->mock(PolicySnapshotService::class, function (MockInterface $mock) {
|
|
$mock->shouldReceive('fetch')
|
|
->andReturn([
|
|
'payload' => [
|
|
'@odata.type' => '#microsoft.graph.deviceConfiguration',
|
|
'id' => 'policy-1',
|
|
'displayName' => 'Test Policy',
|
|
],
|
|
'metadata' => [],
|
|
'warnings' => [],
|
|
]);
|
|
});
|
|
|
|
$this->mock(FoundationSnapshotService::class, function (MockInterface $mock) {
|
|
$mock->shouldReceive('fetchAll')
|
|
->once()
|
|
->andReturn([
|
|
'items' => [
|
|
[
|
|
'source_id' => 'filter-1',
|
|
'display_name' => 'Filter One',
|
|
'payload' => [
|
|
'id' => 'filter-1',
|
|
'displayName' => 'Filter One',
|
|
],
|
|
'metadata' => [
|
|
'displayName' => 'Filter One',
|
|
'kind' => 'assignmentFilter',
|
|
'graph' => [
|
|
'resource' => 'deviceManagement/assignmentFilters',
|
|
'apiVersion' => 'beta',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
'failures' => [],
|
|
]);
|
|
});
|
|
});
|
|
|
|
it('creates foundation backup items when requested', function () {
|
|
$service = app(BackupService::class);
|
|
|
|
$backupSet = $service->createBackupSet(
|
|
tenant: $this->tenant,
|
|
policyIds: [$this->policy->id],
|
|
name: 'Foundation Backup',
|
|
includeFoundations: true,
|
|
);
|
|
|
|
expect($backupSet->items)->toHaveCount(2);
|
|
|
|
$foundationItem = BackupItem::query()
|
|
->where('backup_set_id', $backupSet->id)
|
|
->where('policy_type', 'assignmentFilter')
|
|
->first();
|
|
|
|
expect($foundationItem)->not->toBeNull();
|
|
expect($foundationItem->policy_id)->toBeNull();
|
|
expect($foundationItem->policy_identifier)->toBe('filter-1');
|
|
expect($foundationItem->metadata['displayName'])->toBe('Filter One');
|
|
});
|