Implements Spec 081 provider-connection cutover. Highlights: - Adds provider connection resolution + gating for operations/verification. - Adds provider credential observer wiring. - Updates Filament tenant verify flow to block with next-steps when provider connection isn’t ready. - Adds spec docs under specs/081-provider-connection-cutover/ and extensive Spec081 test coverage. Tests: - vendor/bin/sail artisan test --compact tests/Feature/Filament/TenantSetupTest.php - Focused suites for ProviderConnections/Verification ran during implementation (see local logs). Co-authored-by: Ahmed Darrazi <ahmeddarrazi@MacBookPro.fritz.box> Reviewed-on: #98
51 lines
1.9 KiB
PHP
51 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\Tenant;
|
|
use App\Services\OperationRunService;
|
|
use App\Support\OperationRunOutcome;
|
|
use App\Support\OperationRunStatus;
|
|
use App\Support\Providers\ProviderReasonCodes;
|
|
|
|
it('Spec081 stores blocked operation runs with sanitized reason and link-only next steps', function (): void {
|
|
$tenant = Tenant::factory()->create();
|
|
$service = app(OperationRunService::class);
|
|
|
|
$run = $service->ensureRunWithIdentity(
|
|
tenant: $tenant,
|
|
type: 'provider.connection.check',
|
|
identityInputs: [
|
|
'provider_connection_id' => 99,
|
|
],
|
|
context: [
|
|
'provider' => 'microsoft',
|
|
'provider_connection_id' => 99,
|
|
'target_scope' => [
|
|
'entra_tenant_id' => $tenant->graphTenantId(),
|
|
],
|
|
],
|
|
);
|
|
|
|
$finalized = $service->finalizeBlockedRun(
|
|
run: $run,
|
|
reasonCode: ProviderReasonCodes::ProviderCredentialMissing,
|
|
nextSteps: [
|
|
['label' => 'Update Credentials', 'url' => '/admin/tenants/demo/provider-connections'],
|
|
['label' => '', 'url' => '/invalid'],
|
|
],
|
|
message: 'client_secret=super-secret',
|
|
);
|
|
|
|
$finalized->refresh();
|
|
|
|
expect($finalized->status)->toBe(OperationRunStatus::Completed->value)
|
|
->and($finalized->outcome)->toBe(OperationRunOutcome::Blocked->value)
|
|
->and($finalized->context['reason_code'] ?? null)->toBe(ProviderReasonCodes::ProviderCredentialMissing)
|
|
->and($finalized->context['next_steps'] ?? [])->toBe([
|
|
['label' => 'Update Credentials', 'url' => '/admin/tenants/demo/provider-connections'],
|
|
])
|
|
->and($finalized->failure_summary[0]['reason_code'] ?? null)->toBe(ProviderReasonCodes::ProviderCredentialMissing)
|
|
->and((string) ($finalized->failure_summary[0]['message'] ?? ''))->not->toContain('secret');
|
|
});
|