TenantAtlas/tests/Unit/Providers/PlatformProviderIdentityResolverTest.php
ahmido bab01f07a9 feat: standardize platform provider identity (#166)
## Summary
- standardize Microsoft provider connections around explicit platform vs dedicated identity modes
- centralize admin-consent URL and runtime identity resolution so platform flows no longer fall back to tenant-local credentials
- add migration classification, richer consent and verification state handling, dedicated override management, and focused regression coverage

## Validation
- focused repo test coverage was added across provider identity, onboarding, audit, policy, guard, and migration flows
- latest explicit passing run in the workspace: `vendor/bin/sail artisan test --compact tests/Feature/AdminConsentCallbackTest.php tests/Feature/Audit/ProviderConnectionConsentAuditTest.php`

## Notes
- branch includes the full Spec 137 artifact set under `specs/137-platform-provider-identity/`
- target base branch: `dev`

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #166
2026-03-13 16:29:08 +00:00

43 lines
2.0 KiB
PHP

<?php
use App\Services\Providers\PlatformProviderIdentityResolver;
use App\Support\Providers\ProviderConnectionType;
use App\Support\Providers\ProviderReasonCodes;
it('resolves the central platform identity from config', function (): void {
config()->set('graph.client_id', 'platform-client-id');
config()->set('graph.client_secret', 'platform-client-secret');
config()->set('graph.tenant_id', 'platform-home-tenant-id');
$resolution = app(PlatformProviderIdentityResolver::class)->resolve('customer-tenant-id');
expect($resolution->resolved)->toBeTrue()
->and($resolution->connectionType)->toBe(ProviderConnectionType::Platform)
->and($resolution->tenantContext)->toBe('customer-tenant-id')
->and($resolution->effectiveClientId)->toBe('platform-client-id')
->and($resolution->credentialSource)->toBe('platform_config')
->and($resolution->clientSecret)->toBe('platform-client-secret')
->and($resolution->authorityTenant)->toBe('platform-home-tenant-id')
->and($resolution->redirectUri)->toBe(route('admin.consent.callback'));
});
it('blocks platform identity resolution when the platform client id is missing', function (): void {
config()->set('graph.client_id', '');
config()->set('graph.client_secret', 'platform-client-secret');
$resolution = app(PlatformProviderIdentityResolver::class)->resolve('customer-tenant-id');
expect($resolution->resolved)->toBeFalse()
->and($resolution->effectiveReasonCode())->toBe(ProviderReasonCodes::PlatformIdentityMissing);
});
it('blocks platform identity resolution when the platform secret is missing', function (): void {
config()->set('graph.client_id', 'platform-client-id');
config()->set('graph.client_secret', '');
$resolution = app(PlatformProviderIdentityResolver::class)->resolve('customer-tenant-id');
expect($resolution->resolved)->toBeFalse()
->and($resolution->effectiveReasonCode())->toBe(ProviderReasonCodes::PlatformIdentityIncomplete);
});