53 lines
1.5 KiB
PHP
53 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\TenantOnboardingWizard;
|
|
use App\Models\OperationRun;
|
|
use App\Models\Tenant;
|
|
use App\Jobs\TenantOnboardingVerifyJob;
|
|
use Illuminate\Support\Facades\Bus;
|
|
use Livewire\Livewire;
|
|
|
|
it('returns 404 when a user is not a member of the tenant', function (): void {
|
|
[$member, $tenant] = createUserWithTenant(role: 'owner');
|
|
|
|
$outsider = \App\Models\User::factory()->create();
|
|
|
|
$this->actingAs($outsider)
|
|
->get('/admin/tenant-onboarding?tenant='.(string) $tenant->external_id)
|
|
->assertNotFound();
|
|
});
|
|
|
|
it('returns 403 when a member lacks provider run capability and tries to enqueue verification', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'readonly');
|
|
|
|
$this->actingAs($user);
|
|
|
|
Livewire::withQueryParams([
|
|
'tenant' => (string) $tenant->external_id,
|
|
])
|
|
->test(TenantOnboardingWizard::class)
|
|
->call('enqueueVerification')
|
|
->assertForbidden();
|
|
});
|
|
|
|
it('allows an owner to enqueue verification', function (): void {
|
|
Bus::fake();
|
|
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
|
|
$this->actingAs($user);
|
|
|
|
Livewire::withQueryParams([
|
|
'tenant' => (string) $tenant->external_id,
|
|
])
|
|
->test(TenantOnboardingWizard::class)
|
|
->call('enqueueVerification')
|
|
->assertSuccessful();
|
|
|
|
expect(OperationRun::query()->where('type', 'tenant.rbac.verify')->count())->toBe(1);
|
|
|
|
Bus::assertDispatched(TenantOnboardingVerifyJob::class, 1);
|
|
});
|