## Summary - replace the legacy Tenant and TenantMembership core models with ManagedEnvironment and ManagedEnvironmentMembership - propagate the managed environment naming and key changes across Filament resources, pages, controllers, jobs, models, and supporting runtime paths - add feature 279 spec artifacts and focused managed-environment test coverage for model behavior, route binding, panel context, authorization, and legacy guardrails ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/ManagedEnvironment/LegacyTenantCoreGuardTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentAuthorizationTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentPanelContextTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentRouteBindingTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentContextResolverTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentModelTest.php` - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` ## Notes - branch pushed from commit `1123b122` - browser smoke test file was added but not run in this pass Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #335
64 lines
2.1 KiB
PHP
64 lines
2.1 KiB
PHP
<?php
|
|
|
|
use App\Services\Graph\GraphContractRegistry;
|
|
use App\Services\Graph\GraphLogger;
|
|
use App\Services\Graph\MicrosoftGraphClient;
|
|
use Illuminate\Http\Client\Request;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
beforeEach(function () {
|
|
config()->set('graph_contracts.types.deviceConfiguration', [
|
|
'resource' => 'deviceManagement/deviceConfigurations',
|
|
'allowed_select' => ['id', 'displayName'],
|
|
'allowed_expand' => [],
|
|
'type_family' => ['#microsoft.graph.deviceConfiguration'],
|
|
]);
|
|
|
|
config()->set('graph.base_url', 'https://graph.microsoft.com');
|
|
config()->set('graph.version', 'beta');
|
|
config()->set('graph.managed_environment_id', 'tenant');
|
|
config()->set('graph.client_id', 'client');
|
|
config()->set('graph.client_secret', 'secret');
|
|
config()->set('graph.scope', 'https://graph.microsoft.com/.default');
|
|
});
|
|
|
|
it('falls back when capability errors occur on select', function () {
|
|
$callCount = 0;
|
|
|
|
Http::fake([
|
|
'https://login.microsoftonline.com/*' => Http::response([
|
|
'access_token' => 'fake-token',
|
|
'expires_in' => 3600,
|
|
], 200),
|
|
'https://graph.microsoft.com/*' => function (Request $request) use (&$callCount) {
|
|
$callCount++;
|
|
|
|
if ($callCount === 1) {
|
|
return Http::response([
|
|
'error' => [
|
|
'code' => 'Request_BadRequest',
|
|
'message' => 'Request is invalid due to $select',
|
|
],
|
|
], 400);
|
|
}
|
|
|
|
return Http::response(['id' => 'policy-1', 'displayName' => 'Policy'], 200);
|
|
},
|
|
]);
|
|
|
|
$client = new MicrosoftGraphClient(
|
|
logger: app(GraphLogger::class),
|
|
contracts: app(GraphContractRegistry::class),
|
|
);
|
|
|
|
$response = $client->getPolicy('deviceConfiguration', 'policy-1', [
|
|
'select' => ['id', 'displayName', 'unsupported'],
|
|
'tenant' => 'tenant',
|
|
'access_token' => 'token',
|
|
]);
|
|
|
|
expect($response->successful())->toBeTrue();
|
|
expect($callCount)->toBe(2);
|
|
expect($response->warnings)->not->toBeEmpty();
|
|
});
|