TenantAtlas/apps/platform/tests/Feature/Guards/Spec288NoLegacyRouteAndHelperGuardTest.php
ahmido 5722c4f051 feat: clean up managed environment terminology copy (#353)
## Summary
- replace tenant-first operator copy with environment and managed environment terminology across Filament pages, resources, services, Blade views, and localization
- align baseline compare, findings, governance, monitoring, backup schedule, and required-permissions surfaces with the managed-environment vocabulary
- update guard, feature, and browser smoke coverage and add the Spec 298 audit artifacts documenting allowed provider, internal, and regression-guard tenant references

## Validation
- cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Guards
- cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Localization
- cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Workspaces
- cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/ProviderConnections
- cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/RequiredPermissions
- cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Browser/Spec190BaselineCompareMatrixSmokeTest.php tests/Browser/Spec281ProviderConnectionScopeSmokeTest.php tests/Browser/Spec285WorkspaceRbacEnvironmentAccessSmokeTest.php tests/Browser/Dashboard/TenantDashboardProductizationSmokeTest.php
- cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent

## Notes
- Filament remains on Livewire v4.
- No panel provider or asset-strategy changes are included in this branch.
- Existing destructive actions retain their confirmation and authorization behavior.

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #353
2026-05-13 09:34:08 +00:00

141 lines
5.6 KiB
PHP

<?php
declare(strict_types=1);
it('keeps cutover-owned route emission seams free of retired management paths', function (): void {
$root = base_path();
$forbiddenPatternsByFile = [
'routes/web.php' => [
'/\/admin\/tenants\/[^\'"\n]*\/provider-connections(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/provider-connections(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/required-permissions(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/memberships(?:[\/?"\']|$)/',
'/\/admin\/t\/t\//',
],
'app/Providers/Filament/AdminPanelProvider.php' => [
'/panel:\s*[\'\"]tenant[\'\"]/',
'/\/admin\/tenants\/[^\'"\n]*\/provider-connections(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/provider-connections(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/required-permissions(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/memberships(?:[\/?"\']|$)/',
'/\/admin\/t\/t\//',
],
'app/Filament/Resources/TenantResource.php' => [
'/panel:\s*[\'\"]tenant[\'\"]/',
'/\/admin\/tenants\/[^\'"\n]*\/provider-connections(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/provider-connections(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/required-permissions(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/memberships(?:[\/?"\']|$)/',
'/\/admin\/t\/t\//',
],
'app/Support/OperationRunLinks.php' => [
'/panel:\s*[\'\"]tenant[\'\"]/',
'/\/admin\/tenants\/[^\'"\n]*\/provider-connections(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/provider-connections(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/required-permissions(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/memberships(?:[\/?"\']|$)/',
'/\/admin\/t\/t\//',
],
'app/Support/Verification/VerificationLinkBehavior.php' => [
'/panel:\s*[\'\"]tenant[\'\"]/',
'/\/admin\/tenants\/[^\'"\n]*\/provider-connections(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/provider-connections(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/required-permissions(?:[\/?"\']|$)/',
'/\/admin\/t\/[^\'"\n]*\/memberships(?:[\/?"\']|$)/',
'/\/admin\/t\/t\//',
],
];
$hits = [];
foreach ($forbiddenPatternsByFile as $relativePath => $patterns) {
$absolutePath = $root.'/'.$relativePath;
expect(is_file($absolutePath))->toBeTrue("Expected guard-owned seam [{$relativePath}] to exist.");
$contents = file_get_contents($absolutePath);
if (! is_string($contents) || $contents === '') {
continue;
}
$lines = preg_split('/\R/', $contents) ?: [];
foreach ($patterns as $pattern) {
foreach ($lines as $index => $line) {
if (preg_match($pattern, $line) !== 1) {
continue;
}
$hits[] = $relativePath.':'.($index + 1).' -> '.trim($line);
}
}
}
expect($hits)->toBeEmpty("Retired management path or tenant-panel route emission detected on a Spec 288 seam:\n".implode("\n", $hits));
});
it('keeps spec 288 proof seams free of reintroduced retired tenant-panel helpers', function (): void {
$root = base_path();
$forbiddenPatternsByFile = [
'tests/Pest.php' => [
'/Filament::setCurrentPanel\(\s*[\'\"]tenant[\'\"]\s*\)/',
'/Filament::getPanel\(\s*[\'\"]tenant[\'\"]\s*\)/',
],
'tests/Browser/Spec281ProviderConnectionScopeSmokeTest.php' => [
'/setTenantPanelContext\s*\(/',
'/panel:\s*[\'\"]tenant[\'\"]/',
'/Filament::setCurrentPanel\(\s*[\'\"]tenant[\'\"]\s*\)/',
'/Filament::getPanel\(\s*[\'\"]tenant[\'\"]\s*\)/',
],
'tests/Browser/Spec285WorkspaceRbacEnvironmentAccessSmokeTest.php' => [
'/setTenantPanelContext\s*\(/',
'/panel:\s*[\'\"]tenant[\'\"]/',
'/Filament::setCurrentPanel\(\s*[\'\"]tenant[\'\"]\s*\)/',
'/Filament::getPanel\(\s*[\'\"]tenant[\'\"]\s*\)/',
],
'tests/Feature/ProviderConnections/LegacyRedirectTest.php' => [
'/setTenantPanelContext\s*\(/',
'/panel:\s*[\'\"]tenant[\'\"]/',
],
'tests/Feature/ManagedEnvironment/LegacyTenantCoreGuardTest.php' => [
'/setTenantPanelContext\s*\(/',
'/panel:\s*[\'\"]tenant[\'\"]/',
],
'tests/Feature/Spec080WorkspaceManagedTenantAdminMigrationTest.php' => [
'/setTenantPanelContext\s*\(/',
'/panel:\s*[\'\"]tenant[\'\"]/',
],
];
$hits = [];
foreach ($forbiddenPatternsByFile as $relativePath => $patterns) {
$absolutePath = $root.'/'.$relativePath;
expect(is_file($absolutePath))->toBeTrue("Expected Spec 288 proof seam [{$relativePath}] to exist.");
$contents = file_get_contents($absolutePath);
if (! is_string($contents) || $contents === '') {
continue;
}
$lines = preg_split('/\R/', $contents) ?: [];
foreach ($patterns as $pattern) {
foreach ($lines as $index => $line) {
if (preg_match($pattern, $line) !== 1) {
continue;
}
$hits[] = $relativePath.':'.($index + 1).' -> '.trim($line);
}
}
}
expect($hits)->toBeEmpty("Forbidden retired tenant-panel helper or bootstrapping detected on a Spec 288 proof seam; setTenantPanelContext() must not be reintroduced as a current helper:\n".implode("\n", $hits));
});