TenantAtlas/apps/platform/tests/Feature/Rbac/AdminPanelAccessBoundaryTest.php
ahmido dd175c16a1 fix: tighten workspace RBAC access boundaries (#364)
## Summary
- tighten workspace RBAC and panel access boundaries
- remove non-owner workspace membership management capability from workspace role mapping
- add focused boundary coverage for admin panel, managed environments, providers, review packs, operation runs, finding exceptions, and workspace role capabilities
- include spec artifacts for feature 309

## Testing
- cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Auth/WorkspaceFirstManagedEnvironmentAccessTest.php tests/Feature/Rbac/RoleMatrix/ManagerAccessTest.php tests/Feature/Rbac/WorkspaceMembershipsRelationManagerUiEnforcementTest.php tests/Feature/Rbac/AdminPanelAccessBoundaryTest.php tests/Feature/Rbac/FindingExceptionLifecycleAccessBoundaryTest.php tests/Feature/Rbac/ManagedEnvironmentAccessBoundaryTest.php tests/Feature/Rbac/OperationRunAccessBoundaryTest.php tests/Feature/Rbac/ProviderConnectionAccessBoundaryTest.php tests/Feature/Rbac/ReviewPackAccessBoundaryTest.php tests/Feature/Rbac/SystemPanelAccessBoundaryTest.php tests/Feature/Rbac/WorkspaceRoleCapabilityBoundaryTest.php tests/Unit/Auth/CapabilityResolverTest.php tests/Unit/Auth/WorkspaceRoleCapabilityMapTest.php
- cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #364
2026-05-15 14:00:21 +00:00

39 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\PlatformUser;
use App\Models\User;
use Filament\PanelRegistry;
it('keeps tenant users scoped to the admin panel contract', function (): void {
$user = User::factory()->make();
expect($user->canAccessPanel(app(PanelRegistry::class)->get('admin')))->toBeTrue()
->and($user->canAccessPanel(app(PanelRegistry::class)->get('system')))->toBeFalse();
});
it('redirects unauthenticated direct admin panel access to admin login', function (): void {
$this->get('/admin')->assertRedirectContains('/admin/login');
});
it('denies platform sessions on admin panel routes as not found', function (): void {
$platformUser = PlatformUser::factory()->create();
$this->actingAs($platformUser, 'platform')
->get('/admin')
->assertNotFound();
});
it('does not render workspace admin surfaces for users without workspace authority', function (): void {
$user = User::factory()->create();
$this->actingAs($user)
->get('/admin')
->assertRedirect('/admin/choose-workspace');
$this->actingAs($user)
->get('/admin/alerts')
->assertRedirect('/admin/choose-workspace');
});