## Summary - replace the legacy Tenant and TenantMembership core models with ManagedEnvironment and ManagedEnvironmentMembership - propagate the managed environment naming and key changes across Filament resources, pages, controllers, jobs, models, and supporting runtime paths - add feature 279 spec artifacts and focused managed-environment test coverage for model behavior, route binding, panel context, authorization, and legacy guardrails ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/ManagedEnvironment/LegacyTenantCoreGuardTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentAuthorizationTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentPanelContextTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentRouteBindingTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentContextResolverTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentModelTest.php` - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` ## Notes - branch pushed from commit `1123b122` - browser smoke test file was added but not run in this pass Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #335
67 lines
2.3 KiB
PHP
67 lines
2.3 KiB
PHP
<?php
|
|
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Models\User;
|
|
use App\Models\Workspace;
|
|
use App\Models\WorkspaceMembership;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('resolves the temporary environment shell by managed-environment slug during smoke login', function (): void {
|
|
[$user, $environment] = createUserWithTenant(role: 'owner', workspaceRole: 'manager');
|
|
|
|
$this
|
|
->get(route('admin.local.smoke-login', [
|
|
'email' => $user->email,
|
|
'workspace' => $environment->workspace->slug,
|
|
'tenant' => $environment->slug,
|
|
'redirect' => '/admin/t/'.$environment->slug,
|
|
]))
|
|
->assertRedirect('/admin/t/'.$environment->slug)
|
|
->assertSessionHas('current_workspace_id', (int) $environment->workspace_id);
|
|
});
|
|
|
|
it('returns not found when route binding targets an environment outside the requested workspace', function (): void {
|
|
[$user, $environment] = createUserWithTenant(role: 'owner');
|
|
$otherWorkspace = Workspace::factory()->create();
|
|
|
|
WorkspaceMembership::factory()->create([
|
|
'workspace_id' => (int) $otherWorkspace->getKey(),
|
|
'user_id' => (int) $user->getKey(),
|
|
'role' => 'owner',
|
|
]);
|
|
|
|
$this->actingAs($user)->withSession([
|
|
WorkspaceContext::SESSION_KEY => (int) $otherWorkspace->getKey(),
|
|
]);
|
|
|
|
$this
|
|
->get(route('admin.provider-connections.legacy-index', ['tenant' => $environment]))
|
|
->assertNotFound();
|
|
});
|
|
|
|
it('returns not found when a workspace member lacks managed-environment membership', function (): void {
|
|
$workspace = Workspace::factory()->create();
|
|
$environment = ManagedEnvironment::factory()->create([
|
|
'workspace_id' => (int) $workspace->getKey(),
|
|
]);
|
|
$user = User::factory()->create();
|
|
|
|
WorkspaceMembership::factory()->create([
|
|
'workspace_id' => (int) $workspace->getKey(),
|
|
'user_id' => (int) $user->getKey(),
|
|
'role' => 'manager',
|
|
]);
|
|
|
|
$this
|
|
->get(route('admin.local.smoke-login', [
|
|
'email' => $user->email,
|
|
'workspace' => $workspace->slug,
|
|
'tenant' => $environment->slug,
|
|
'redirect' => '/admin/t/'.$environment->slug,
|
|
]))
|
|
->assertNotFound();
|
|
});
|