## 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
100 lines
3.5 KiB
PHP
100 lines
3.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\ProviderConnection;
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
use App\Models\WorkspaceMembership;
|
|
use App\Policies\ProviderConnectionPolicy;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Illuminate\Auth\Access\Response;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('allows tenant owners to manage dedicated overrides for accessible provider connections', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner', ensureDefaultMicrosoftProviderConnection: false);
|
|
|
|
$connection = ProviderConnection::factory()->platform()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'provider' => 'microsoft',
|
|
]);
|
|
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenant->workspace_id);
|
|
|
|
$result = app(ProviderConnectionPolicy::class)->manageDedicated($user, $connection);
|
|
|
|
expect($result)->toBeTrue();
|
|
});
|
|
|
|
it('forbids tenant managers from dedicated override actions while still allowing standard updates', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'manager', ensureDefaultMicrosoftProviderConnection: false);
|
|
|
|
$connection = ProviderConnection::factory()->platform()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'provider' => 'microsoft',
|
|
]);
|
|
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenant->workspace_id);
|
|
|
|
$policy = app(ProviderConnectionPolicy::class);
|
|
|
|
expect($policy->update($user, $connection))->toBeTrue();
|
|
|
|
$result = $policy->manageDedicated($user, $connection);
|
|
|
|
expect($result)->toBeFalse();
|
|
});
|
|
|
|
it('returns not found for non-members on dedicated override authorization checks', function (): void {
|
|
$tenant = Tenant::factory()->create();
|
|
$user = User::factory()->create();
|
|
|
|
$connection = ProviderConnection::factory()->platform()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'provider' => 'microsoft',
|
|
]);
|
|
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenant->workspace_id);
|
|
|
|
$result = app(ProviderConnectionPolicy::class)->manageDedicated($user, $connection);
|
|
|
|
expect($result)->toBeInstanceOf(Response::class)
|
|
->and($result->allowed())->toBeFalse()
|
|
->and($result->status())->toBe(404);
|
|
});
|
|
|
|
it('returns not found when the provider connection is outside the active workspace', function (): void {
|
|
[$user, $tenantA] = createUserWithTenant(role: 'owner', ensureDefaultMicrosoftProviderConnection: false);
|
|
|
|
$tenantB = Tenant::factory()->create();
|
|
|
|
WorkspaceMembership::factory()->create([
|
|
'workspace_id' => (int) $tenantB->workspace_id,
|
|
'user_id' => (int) $user->getKey(),
|
|
'role' => 'owner',
|
|
]);
|
|
|
|
$user->tenants()->syncWithoutDetaching([
|
|
(int) $tenantB->getKey() => ['role' => 'owner'],
|
|
]);
|
|
|
|
$connection = ProviderConnection::factory()->platform()->create([
|
|
'workspace_id' => (int) $tenantB->workspace_id,
|
|
'tenant_id' => (int) $tenantB->getKey(),
|
|
'provider' => 'microsoft',
|
|
]);
|
|
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenantA->workspace_id);
|
|
|
|
$result = app(ProviderConnectionPolicy::class)->manageDedicated($user, $connection);
|
|
|
|
expect($result)->toBeInstanceOf(Response::class)
|
|
->and($result->allowed())->toBeFalse()
|
|
->and($result->status())->toBe(404);
|
|
});
|