## Summary - remove tenant-based Graph options access from runtime service paths and enforce provider-only resolution - add `MicrosoftGraphOptionsResolver` and `ProviderConfigurationRequiredException` for centralized, actionable provider-config errors - turn `Tenant::graphOptions()` into a fail-fast kill switch to prevent legacy runtime usage - add and update tests (including guardrail) to enforce no reintroduction in `app/` - update Spec 088 artifacts (`spec`, `plan`, `research`, `tasks`, checklist) ## Validation - `vendor/bin/sail bin pint --dirty` - `vendor/bin/sail artisan test --compact --filter=NoLegacyTenantGraphOptions` - `vendor/bin/sail artisan test --compact tests/Feature/Filament` - `CI=1 vendor/bin/sail artisan test --compact` ## Notes - Branch includes the guardrail test for legacy callsite detection in `app/`. - Full suite currently green: 1227 passed, 5 skipped. Co-authored-by: Ahmed Darrazi <ahmeddarrazi@MacBookPro.fritz.box> Reviewed-on: #105
68 lines
2.4 KiB
PHP
68 lines
2.4 KiB
PHP
<?php
|
|
|
|
use App\Models\Policy;
|
|
use App\Models\Tenant;
|
|
use App\Services\Graph\AssignmentFetcher;
|
|
use App\Services\Graph\ScopeTagResolver;
|
|
use App\Services\Intune\PolicySnapshotService;
|
|
use App\Services\Intune\VersionService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('persists metadata-only snapshot metadata on captured versions', function () {
|
|
$tenant = Tenant::factory()->create();
|
|
ensureDefaultProviderConnection($tenant, 'microsoft');
|
|
$policy = Policy::factory()->for($tenant)->create([
|
|
'policy_type' => 'mamAppConfiguration',
|
|
'platform' => 'mobile',
|
|
'external_id' => 'A_meta_only',
|
|
'display_name' => 'MAM Config Meta',
|
|
]);
|
|
|
|
$this->mock(PolicySnapshotService::class, function ($mock) {
|
|
$mock->shouldReceive('fetch')
|
|
->once()
|
|
->andReturn([
|
|
'payload' => [
|
|
'id' => 'A_meta_only',
|
|
'displayName' => 'MAM Config Meta',
|
|
'@odata.type' => '#microsoft.graph.targetedManagedAppConfiguration',
|
|
],
|
|
'metadata' => [
|
|
'source' => 'metadata_only',
|
|
'original_status' => 500,
|
|
'original_failure' => 'InternalServerError: upstream',
|
|
],
|
|
'warnings' => [
|
|
'Snapshot captured from local metadata only (Graph API returned 500).',
|
|
],
|
|
]);
|
|
});
|
|
|
|
$this->mock(AssignmentFetcher::class, function ($mock) {
|
|
$mock->shouldReceive('fetch')->never();
|
|
});
|
|
|
|
$this->mock(ScopeTagResolver::class, function ($mock) {
|
|
$mock->shouldReceive('resolve')->never();
|
|
});
|
|
|
|
$service = app(VersionService::class);
|
|
|
|
$version = $service->captureFromGraph(
|
|
tenant: $tenant,
|
|
policy: $policy,
|
|
createdBy: 'tester@example.test',
|
|
includeAssignments: false,
|
|
includeScopeTags: false,
|
|
);
|
|
|
|
expect($version->metadata['source'])->toBe('metadata_only');
|
|
expect($version->metadata['original_status'])->toBe(500);
|
|
expect($version->metadata['original_failure'])->toContain('InternalServerError');
|
|
expect($version->metadata['capture_source'])->toBe('version_capture');
|
|
expect($version->metadata['warnings'])->toBeArray();
|
|
expect($version->metadata['warnings'][0])->toContain('metadata only');
|
|
});
|