create(); $workspaceB = Workspace::factory()->create(); $user = User::factory()->create(); WorkspaceMembership::factory()->create([ 'workspace_id' => $workspaceA->getKey(), 'user_id' => $user->getKey(), 'role' => 'owner', ]); $tenantB = Tenant::factory()->create([ 'status' => 'active', 'workspace_id' => (int) $workspaceB->getKey(), ]); $runB = OperationRun::factory()->create([ 'tenant_id' => (int) $tenantB->getKey(), 'workspace_id' => (int) $workspaceB->getKey(), 'type' => 'policy.sync', 'initiator_name' => 'WorkspaceB', ]); $this->actingAs($user) ->withSession([WorkspaceContext::SESSION_KEY => (int) $workspaceA->getKey()]) ->get(route('admin.operations.view', ['run' => (int) $runB->getKey()])) ->assertNotFound(); }); it('returns 403 when a workspace member without workspace.manage tries to edit a workspace', function (): void { $user = User::factory()->create(); $workspace = Workspace::factory()->create(); WorkspaceMembership::factory()->create([ 'workspace_id' => $workspace->getKey(), 'user_id' => $user->getKey(), 'role' => 'manager', ]); $this->actingAs($user) ->withSession([WorkspaceContext::SESSION_KEY => (int) $workspace->getKey()]) ->get('/admin/workspaces/'.(int) $workspace->getKey().'/edit') ->assertForbidden(); });