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
97 lines
3.2 KiB
PHP
97 lines
3.2 KiB
PHP
<?php
|
|
|
|
use App\Filament\Resources\ProviderConnectionResource;
|
|
use App\Models\ProviderConnection;
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
|
|
test('owners can manage provider connections in their tenant', function () {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
|
|
$connection = ProviderConnection::factory()->create([
|
|
'tenant_id' => $tenant->getKey(),
|
|
'display_name' => 'Contoso',
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->get(ProviderConnectionResource::getUrl('index', tenant: $tenant))
|
|
->assertOk();
|
|
|
|
$this->actingAs($user)
|
|
->get(ProviderConnectionResource::getUrl('create', tenant: $tenant))
|
|
->assertOk();
|
|
|
|
$this->actingAs($user)
|
|
->get(ProviderConnectionResource::getUrl('edit', ['record' => $connection], tenant: $tenant))
|
|
->assertOk()
|
|
->assertSee('Contoso');
|
|
});
|
|
|
|
test('operators can view provider connections but cannot manage them', function () {
|
|
[$user, $tenant] = createUserWithTenant(role: 'operator');
|
|
|
|
$createUrl = ProviderConnectionResource::getUrl('create', tenant: $tenant);
|
|
$createPath = parse_url($createUrl, PHP_URL_PATH) ?: $createUrl;
|
|
|
|
$connection = ProviderConnection::factory()->create([
|
|
'tenant_id' => $tenant->getKey(),
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->get(ProviderConnectionResource::getUrl('index', tenant: $tenant))
|
|
->assertOk()
|
|
->assertDontSee($createPath);
|
|
|
|
$this->actingAs($user)
|
|
->get(ProviderConnectionResource::getUrl('create', tenant: $tenant))
|
|
->assertForbidden();
|
|
|
|
$this->actingAs($user)
|
|
->get(ProviderConnectionResource::getUrl('edit', ['record' => $connection], tenant: $tenant))
|
|
->assertOk();
|
|
});
|
|
|
|
test('readonly users can view provider connections but cannot manage them', function () {
|
|
[$user, $tenant] = createUserWithTenant(role: 'readonly');
|
|
|
|
$createUrl = ProviderConnectionResource::getUrl('create', tenant: $tenant);
|
|
$createPath = parse_url($createUrl, PHP_URL_PATH) ?: $createUrl;
|
|
|
|
$connection = ProviderConnection::factory()->create([
|
|
'tenant_id' => $tenant->getKey(),
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->get(ProviderConnectionResource::getUrl('index', tenant: $tenant))
|
|
->assertOk()
|
|
->assertDontSee($createPath);
|
|
|
|
$this->actingAs($user)
|
|
->get(ProviderConnectionResource::getUrl('create', tenant: $tenant))
|
|
->assertForbidden();
|
|
|
|
$this->actingAs($user)
|
|
->get(ProviderConnectionResource::getUrl('edit', ['record' => $connection], tenant: $tenant))
|
|
->assertOk();
|
|
});
|
|
|
|
test('provider connection edit is not accessible cross-tenant', function () {
|
|
$tenantA = Tenant::factory()->create();
|
|
$tenantB = Tenant::factory()->create();
|
|
|
|
$connectionB = ProviderConnection::factory()->create([
|
|
'tenant_id' => $tenantB->getKey(),
|
|
'display_name' => 'Tenant B Connection',
|
|
]);
|
|
|
|
$user = User::factory()->create();
|
|
$user->tenants()->syncWithoutDetaching([
|
|
$tenantA->getKey() => ['role' => 'owner'],
|
|
$tenantB->getKey() => ['role' => 'owner'],
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->get(ProviderConnectionResource::getUrl('edit', ['record' => $connectionB], tenant: $tenantA))
|
|
->assertNotFound();
|
|
});
|