## Summary - move the Laravel application into `apps/platform` and keep the repository root for orchestration, docs, and tooling - update the local command model, Sail/Docker wiring, runtime paths, and ignore rules around the new platform location - add relocation quickstart/contracts plus focused smoke coverage for bootstrap, command model, routes, and runtime behavior ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/PlatformRelocation` - integrated browser smoke validated `/up`, `/`, `/admin`, `/admin/choose-workspace`, and tenant route semantics for `200`, `403`, and `404` ## Remaining Rollout Checks - validate Dokploy build context and working-directory assumptions against the new `apps/platform` layout - confirm web, queue, and scheduler processes all start from the expected working directory in staging/production - verify no legacy volume mounts or asset-publish paths still point at the old root-level `public/` or `storage/` locations Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #213
63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?php
|
|
|
|
use Illuminate\Filesystem\Filesystem;
|
|
|
|
it('does not use role-string checks outside the RBAC core', function () {
|
|
/**
|
|
* This guard test is intentionally narrow:
|
|
* - It targets comparisons / branching on role strings (authorization-by-role patterns).
|
|
* - It does NOT forbid role literals used as data values (e.g., form options, seed data).
|
|
*/
|
|
$allowedFiles = collect([
|
|
app_path('Services/Auth/RoleCapabilityMap.php'),
|
|
app_path('Services/Auth/TenantMembershipManager.php'),
|
|
])->map(fn (string $path) => realpath($path) ?: $path)->all();
|
|
|
|
$roleValuePattern = '(owner|manager|operator|readonly)';
|
|
|
|
$patterns = [
|
|
// $membership->role === 'owner' / !== 'owner'
|
|
'/->role\s*(===|==|!==|!=)\s*(["\'])'.$roleValuePattern.'\2/i',
|
|
|
|
// $role === 'owner'
|
|
'/\$role\s*(===|==|!==|!=)\s*(["\'])'.$roleValuePattern.'\2/i',
|
|
|
|
// case 'owner':
|
|
'/\bcase\s*(["\'])'.$roleValuePattern.'\1\s*:/i',
|
|
|
|
// match (...) { 'owner' => ... }
|
|
'/\bmatch\b[\s\S]*?\{[\s\S]*?(["\'])'.$roleValuePattern.'\1\s*=>/i',
|
|
];
|
|
|
|
$filesystem = new Filesystem;
|
|
|
|
$violations = [];
|
|
|
|
foreach ($filesystem->allFiles(app_path()) as $file) {
|
|
$path = $file->getRealPath();
|
|
|
|
if ($path === false) {
|
|
continue;
|
|
}
|
|
|
|
if (in_array($path, $allowedFiles, true)) {
|
|
continue;
|
|
}
|
|
|
|
$contents = $filesystem->get($path);
|
|
|
|
foreach ($patterns as $pattern) {
|
|
if (preg_match($pattern, $contents) === 1) {
|
|
$violations[] = $path;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($violations !== []) {
|
|
throw new RuntimeException('Role-string checks must live in RoleCapabilityMap / TenantMembershipManager only. Offenders: '.implode(', ', $violations));
|
|
}
|
|
|
|
expect($violations)->toBeEmpty();
|
|
});
|