## 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
65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
|
|
use App\Services\Graph\AssignmentFilterResolver;
|
|
use App\Services\Graph\GraphResponse;
|
|
use App\Services\Graph\MicrosoftGraphClient;
|
|
use App\Services\Providers\MicrosoftGraphOptionsResolver;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
uses(RefreshDatabase::class);
|
|
beforeEach(function () {
|
|
Cache::flush();
|
|
$this->graphClient = Mockery::mock(MicrosoftGraphClient::class);
|
|
$this->resolver = new AssignmentFilterResolver($this->graphClient, app(MicrosoftGraphOptionsResolver::class));
|
|
});
|
|
|
|
test('resolves assignment filters by id', function () {
|
|
$filters = [
|
|
['id' => 'filter-1', 'displayName' => 'Targeted Devices'],
|
|
['id' => 'filter-2', 'displayName' => 'Excluded Devices'],
|
|
];
|
|
|
|
$response = new GraphResponse(
|
|
success: true,
|
|
data: ['value' => $filters]
|
|
);
|
|
|
|
$this->graphClient
|
|
->shouldReceive('request')
|
|
->once()
|
|
->with('GET', '/deviceManagement/assignmentFilters', [
|
|
'query' => [
|
|
'$select' => 'id,displayName',
|
|
],
|
|
])
|
|
->andReturn($response);
|
|
|
|
$result = $this->resolver->resolve(['filter-1']);
|
|
|
|
expect($result)->toHaveCount(1)
|
|
->and($result[0]['id'])->toBe('filter-1')
|
|
->and($result[0]['displayName'])->toBe('Targeted Devices');
|
|
});
|
|
|
|
test('uses cache for repeated lookups', function () {
|
|
$filters = [
|
|
['id' => 'filter-1', 'displayName' => 'Targeted Devices'],
|
|
];
|
|
|
|
$response = new GraphResponse(
|
|
success: true,
|
|
data: ['value' => $filters]
|
|
);
|
|
|
|
$this->graphClient
|
|
->shouldReceive('request')
|
|
->once()
|
|
->andReturn($response);
|
|
|
|
$result1 = $this->resolver->resolve(['filter-1']);
|
|
$result2 = $this->resolver->resolve(['filter-1']);
|
|
|
|
expect($result1)->toBe($result2);
|
|
});
|