Some checks are pending
Main Confidence / confidence (push) Waiting to run
## Summary - add a shared provider target-scope descriptor, normalizer, identity-context metadata, and surface-summary layer - update provider connection list, detail, create, edit, and onboarding surfaces to use neutral target-scope vocabulary while keeping Microsoft identity contextual - align provider connection audit and resolver output with the neutral target-scope contract and add focused guard/unit/feature coverage for regressions ## Validation - browser smoke: opened the tenant-scoped provider connection list, drilled into detail, and verified the edit/create surfaces in local admin context ## Notes - this PR comes from the session branch created for the active feature work - no additional runtime or persistence layer was introduced in this slice Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #274
64 lines
3.2 KiB
PHP
64 lines
3.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\ProviderConnection;
|
|
use App\Support\Providers\TargetScope\ProviderConnectionSurfaceSummary;
|
|
use App\Support\Providers\TargetScope\ProviderConnectionTargetScopeDescriptor;
|
|
use App\Support\Providers\TargetScope\ProviderConnectionTargetScopeNormalizer;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('normalizes provider connections into neutral target-scope descriptors with contextual Microsoft metadata', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner', ensureDefaultMicrosoftProviderConnection: false);
|
|
|
|
$connection = ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'provider' => 'microsoft',
|
|
'entra_tenant_id' => '11111111-1111-1111-1111-111111111111',
|
|
'display_name' => 'Primary connection',
|
|
]);
|
|
|
|
$descriptor = app(ProviderConnectionTargetScopeNormalizer::class)
|
|
->descriptorForConnection($connection->fresh(['tenant']));
|
|
$summary = ProviderConnectionSurfaceSummary::forConnection($connection->fresh(['tenant']));
|
|
|
|
expect($user)->not->toBeNull()
|
|
->and($descriptor->provider)->toBe('microsoft')
|
|
->and($descriptor->scopeKind)->toBe(ProviderConnectionTargetScopeDescriptor::SCOPE_KIND_TENANT)
|
|
->and($descriptor->scopeIdentifier)->toBe('11111111-1111-1111-1111-111111111111')
|
|
->and($descriptor->sharedLabel)->toBe('Target scope')
|
|
->and($descriptor->summary())->toContain((string) $tenant->name)
|
|
->and($summary->targetScopeSummary())->toContain('11111111-1111-1111-1111-111111111111')
|
|
->and($summary->contextualIdentityDetails)->toHaveCount(1)
|
|
->and($summary->contextualIdentityDetails[0]->detailLabel)->toBe('Microsoft tenant ID');
|
|
});
|
|
|
|
it('blocks unsupported provider-scope combinations explicitly instead of inheriting Microsoft defaults', function (): void {
|
|
$result = app(ProviderConnectionTargetScopeNormalizer::class)->normalizeInput(
|
|
provider: 'unknown-provider',
|
|
scopeKind: ProviderConnectionTargetScopeDescriptor::SCOPE_KIND_TENANT,
|
|
scopeIdentifier: 'scope-1',
|
|
scopeDisplayName: 'Scope 1',
|
|
);
|
|
|
|
expect($result['status'])->toBe(ProviderConnectionTargetScopeNormalizer::STATUS_BLOCKED)
|
|
->and($result['failure_code'])->toBe(ProviderConnectionTargetScopeNormalizer::FAILURE_UNSUPPORTED_PROVIDER_SCOPE_COMBINATION)
|
|
->and($result['message'])->toContain('not supported');
|
|
});
|
|
|
|
it('blocks missing target-scope context with neutral validation language', function (): void {
|
|
$result = app(ProviderConnectionTargetScopeNormalizer::class)->normalizeInput(
|
|
provider: 'microsoft',
|
|
scopeKind: ProviderConnectionTargetScopeDescriptor::SCOPE_KIND_TENANT,
|
|
scopeIdentifier: '',
|
|
scopeDisplayName: 'Missing scope',
|
|
);
|
|
|
|
expect($result['status'])->toBe(ProviderConnectionTargetScopeNormalizer::STATUS_BLOCKED)
|
|
->and($result['failure_code'])->toBe(ProviderConnectionTargetScopeNormalizer::FAILURE_MISSING_PROVIDER_CONTEXT)
|
|
->and($result['message'])->toBe('A target scope identifier is required for this provider connection.');
|
|
});
|