## 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
63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Policy;
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Models\Workspace;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Str;
|
|
|
|
class PoliciesSeeder extends Seeder
|
|
{
|
|
public function run(): void
|
|
{
|
|
$seedManagedEnvironmentSlug = env('INTUNE_TENANT_ID', 'local-tenant');
|
|
|
|
$workspace = Workspace::query()->firstOrCreate(
|
|
['slug' => 'default'],
|
|
['name' => 'Default Workspace', 'slug' => 'default'],
|
|
);
|
|
|
|
$tenant = ManagedEnvironment::query()->firstOrCreate([
|
|
'slug' => $seedManagedEnvironmentSlug,
|
|
], [
|
|
'workspace_id' => (int) $workspace->getKey(),
|
|
'name' => 'Default Managed Environment',
|
|
'display_name' => 'Default Managed Environment',
|
|
'metadata' => [],
|
|
]);
|
|
|
|
if ($tenant->workspace_id === null) {
|
|
$tenant->forceFill([
|
|
'workspace_id' => (int) $workspace->getKey(),
|
|
])->saveQuietly();
|
|
}
|
|
|
|
$supported = config('tenantpilot.supported_policy_types', []);
|
|
$now = now();
|
|
|
|
foreach ($supported as $index => $type) {
|
|
$policyType = $type['type'];
|
|
$platform = $type['platform'] ?? null;
|
|
$externalId = 'seed-'.$policyType.'-'.($platform ?? 'any').'-'.$index;
|
|
|
|
Policy::updateOrCreate(
|
|
[
|
|
'workspace_id' => (int) $workspace->getKey(),
|
|
'managed_environment_id' => $tenant->id,
|
|
'external_id' => $externalId,
|
|
'policy_type' => $policyType,
|
|
],
|
|
[
|
|
'workspace_id' => (int) $workspace->getKey(),
|
|
'display_name' => $type['label'] ?? ucfirst($policyType),
|
|
'platform' => $platform,
|
|
'last_synced_at' => $now,
|
|
'metadata' => ['seeded' => true],
|
|
]
|
|
);
|
|
}
|
|
}
|
|
}
|