TenantAtlas/apps/platform/tests/Feature/ProviderConnections/AuthorizationSemanticsTest.php
Ahmed Darrazi 8cd125e398
Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 1m45s
feat: implement environment CTA explicit filter contract
2026-05-16 13:49:05 +02:00

31 lines
1009 B
PHP

<?php
declare(strict_types=1);
use App\Models\ManagedEnvironment;
use App\Models\ProviderConnection;
use App\Models\User;
it('enforces 404 for non-members and 403 for missing manage capability on mutations', function (): void {
$tenant = ManagedEnvironment::factory()->create();
$connection = ProviderConnection::factory()->create([
'workspace_id' => (int) $tenant->workspace_id,
'managed_environment_id' => (int) $tenant->getKey(),
'provider' => 'microsoft',
]);
// Non-member outsider is redirected by workspace middleware (no workspace membership).
$outsider = User::factory()->create();
$this->actingAs($outsider)
->get('/admin/provider-connections/'.$connection->getKey().'/edit')
->assertRedirect();
[$readonly] = createUserWithTenant(tenant: $tenant, role: 'readonly');
$this->actingAs($readonly)
->get('/admin/provider-connections/create?environment_id='.(int) $tenant->getKey())
->assertForbidden();
});