## 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
82 lines
3.5 KiB
PHP
82 lines
3.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\Finding;
|
|
use App\Models\FindingException;
|
|
use App\Services\Findings\FindingExceptionService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('creates a pending exception request for an open finding', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
$finding = Finding::factory()->for($tenant)->create(['status' => Finding::STATUS_NEW]);
|
|
|
|
Carbon::setTestNow('2026-03-19 10:00:00');
|
|
|
|
$exception = app(FindingExceptionService::class)->request($finding, $tenant, $user, [
|
|
'owner_user_id' => (int) $user->getKey(),
|
|
'request_reason' => 'Operational risk accepted temporarily',
|
|
'review_due_at' => now()->addDays(14)->toDateTimeString(),
|
|
'expires_at' => now()->addDays(30)->toDateTimeString(),
|
|
]);
|
|
|
|
expect($exception->status)->toBe(FindingException::STATUS_PENDING)
|
|
->and($exception->requested_by_user_id)->toBe((int) $user->getKey())
|
|
->and($exception->request_reason)->toBe('Operational risk accepted temporarily')
|
|
->and($exception->currentDecision?->decision_type)->toBe('requested');
|
|
|
|
Carbon::setTestNow();
|
|
});
|
|
|
|
it('blocks overlapping pending requests for the same finding', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
$finding = Finding::factory()->for($tenant)->create(['status' => Finding::STATUS_NEW]);
|
|
|
|
$service = app(FindingExceptionService::class);
|
|
|
|
$service->request($finding, $tenant, $user, [
|
|
'owner_user_id' => (int) $user->getKey(),
|
|
'request_reason' => 'First request',
|
|
'review_due_at' => now()->addDays(7)->toDateTimeString(),
|
|
]);
|
|
|
|
expect(fn () => $service->request($finding, $tenant, $user, [
|
|
'owner_user_id' => (int) $user->getKey(),
|
|
'request_reason' => 'Second request',
|
|
'review_due_at' => now()->addDays(10)->toDateTimeString(),
|
|
]))->toThrow(InvalidArgumentException::class, 'An exception request is already pending for this finding.');
|
|
});
|
|
|
|
it('blocks self approval and approves with finding mutation otherwise', function (): void {
|
|
[$requester, $tenant] = createUserWithTenant(role: 'owner');
|
|
$approver = \App\Models\User::factory()->create();
|
|
createUserWithTenant(tenant: $tenant, user: $approver, role: 'owner');
|
|
|
|
$finding = Finding::factory()->for($tenant)->create(['status' => Finding::STATUS_NEW]);
|
|
$service = app(FindingExceptionService::class);
|
|
|
|
$exception = $service->request($finding, $tenant, $requester, [
|
|
'owner_user_id' => (int) $requester->getKey(),
|
|
'request_reason' => 'Needs temporary exception',
|
|
'review_due_at' => now()->addDays(7)->toDateTimeString(),
|
|
]);
|
|
|
|
expect(fn () => $service->approve($exception, $requester, [
|
|
'effective_from' => now()->addHour()->toDateTimeString(),
|
|
'expires_at' => now()->addDays(30)->toDateTimeString(),
|
|
]))->toThrow(InvalidArgumentException::class, 'Requesters cannot approve their own exception requests.');
|
|
|
|
$approved = $service->approve($exception->fresh(), $approver, [
|
|
'effective_from' => now()->addHour()->toDateTimeString(),
|
|
'expires_at' => now()->addDays(30)->toDateTimeString(),
|
|
'approval_reason' => 'Approved with compensating controls',
|
|
]);
|
|
|
|
expect($approved->status)->toBe(FindingException::STATUS_ACTIVE)
|
|
->and($approved->currentDecision?->decision_type)->toBe('approved')
|
|
->and($finding->fresh()?->status)->toBe(Finding::STATUS_RISK_ACCEPTED);
|
|
});
|