## Summary - migrate provider connections to the canonical three-dimension state model: lifecycle via `is_enabled`, consent via `consent_status`, and verification via `verification_status` - remove legacy provider status and health badge paths, update admin and system directory surfaces, and align onboarding, consent callback, verification, resolver, and mutation flows with the new model - add the Spec 188 artifact set, schema migrations, guard coverage, and expanded provider-state tests across admin, system, onboarding, verification, and rendering paths ## Verification - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Auth/SystemPanelAuthTest.php tests/Feature/Filament/TenantGlobalSearchLifecycleScopeTest.php tests/Feature/ProviderConnections/ProviderConnectionEnableDisableTest.php tests/Feature/ProviderConnections/ProviderConnectionTruthCleanupSpec179Test.php` - integrated browser smoke: validated admin provider list/detail/edit, tenant provider summary, system directory tenant detail, provider-connection search exclusion, and cleaned up the temporary smoke record afterward ## Filament / implementation notes - Livewire v4.0+ compliance: preserved; this change targets Filament v5 on Livewire v4 and does not introduce older APIs - Provider registration location: unchanged; Laravel 11+ panel providers remain registered in `bootstrap/providers.php` - Globally searchable resources: `ProviderConnectionResource` remains intentionally excluded from global search; tenant global search remains enabled and continues to resolve to view pages - Destructive actions: no new destructive action surface was introduced without confirmation or authorization; existing capability checks continue to gate provider mutations - Asset strategy: unchanged; no new Filament assets were added, so deploy behavior for `php artisan filament:assets` remains unchanged - Testing plan covered: system auth, tenant global search, provider lifecycle enable/disable behavior, and provider truth cleanup cutover behavior Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #219
64 lines
2.5 KiB
PHP
64 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\ProviderConnection;
|
|
use App\Models\Tenant;
|
|
use App\Support\Providers\ProviderConnectionType;
|
|
use App\Support\Providers\ProviderConsentStatus;
|
|
use App\Support\Providers\ProviderReasonCodes;
|
|
use App\Support\Providers\ProviderVerificationStatus;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('stores a successful callback as a platform connection with separate consent and verification states', function (): void {
|
|
$tenant = Tenant::factory()->create([
|
|
'tenant_id' => 'tenant-platform-ok',
|
|
'name' => 'Contoso Platform',
|
|
]);
|
|
|
|
$this->get(route('admin.consent.callback', [
|
|
'tenant' => $tenant->tenant_id,
|
|
'admin_consent' => 'true',
|
|
]))->assertOk();
|
|
|
|
$connection = ProviderConnection::query()
|
|
->where('tenant_id', (int) $tenant->getKey())
|
|
->where('provider', 'microsoft')
|
|
->where('entra_tenant_id', $tenant->graphTenantId())
|
|
->firstOrFail();
|
|
|
|
expect($connection->connection_type)->toBe(ProviderConnectionType::Platform)
|
|
->and($connection->is_enabled)->toBeTrue()
|
|
->and($connection->consent_status)->toBe(ProviderConsentStatus::Granted)
|
|
->and($connection->verification_status)->toBe(ProviderVerificationStatus::Unknown)
|
|
->and($connection->credential()->exists())->toBeFalse()
|
|
->and($connection->last_error_reason_code)->toBeNull();
|
|
});
|
|
|
|
it('stores callback failures without promoting the platform connection to a verified state', function (): void {
|
|
$tenant = Tenant::factory()->create([
|
|
'tenant_id' => 'tenant-platform-error',
|
|
'name' => 'Fabrikam Platform',
|
|
]);
|
|
|
|
$this->get(route('admin.consent.callback', [
|
|
'tenant' => $tenant->tenant_id,
|
|
'error' => 'access_denied',
|
|
]))->assertOk();
|
|
|
|
$connection = ProviderConnection::query()
|
|
->where('tenant_id', (int) $tenant->getKey())
|
|
->where('provider', 'microsoft')
|
|
->where('entra_tenant_id', $tenant->graphTenantId())
|
|
->firstOrFail();
|
|
|
|
expect($connection->connection_type)->toBe(ProviderConnectionType::Platform)
|
|
->and($connection->is_enabled)->toBeTrue()
|
|
->and($connection->consent_status)->toBe(ProviderConsentStatus::Failed)
|
|
->and($connection->verification_status)->toBe(ProviderVerificationStatus::Unknown)
|
|
->and($connection->last_error_reason_code)->toBe(ProviderReasonCodes::ProviderAuthFailed)
|
|
->and($connection->credential()->exists())->toBeFalse();
|
|
});
|