Some checks failed
Main Confidence / confidence (push) Failing after 1m23s
Removes the Findings lifecycle backfill from the Operational Controls UI and OperationalControlCatalog. This patch is a safe, controls-only change; runbooks, jobs and other runtime artifacts are NOT removed yet. Follow-up work will delete the runbook service/scope, jobs, commands, and update tests. Files changed: - apps/platform/app/Filament/System/Pages/Ops/Controls.php - apps/platform/app/Support/OperationalControls/OperationalControlCatalog.php - apps/platform/tests/Feature/System/OpsControls/OperationalControlManagementTest.php - apps/platform/tests/Unit/Support/OperationalControls/OperationalControlCatalogTest.php - apps/platform/tests/Unit/Support/OperationalControls/OperationalControlScopeResolutionTest.php Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #280
57 lines
2.2 KiB
PHP
57 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\OperationalControlActivation;
|
|
use App\Models\Workspace;
|
|
use App\Support\OperationalControls\OperationalControlEvaluator;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('prefers an active global pause over a workspace pause', function (): void {
|
|
$workspace = Workspace::factory()->create();
|
|
|
|
OperationalControlActivation::factory()->workspaceScoped()->create([
|
|
'control_key' => 'restore.execute',
|
|
'workspace_id' => (int) $workspace->getKey(),
|
|
'reason_text' => 'Workspace pause.',
|
|
]);
|
|
|
|
$globalActivation = OperationalControlActivation::factory()->forGlobalScope()->create([
|
|
'control_key' => 'restore.execute',
|
|
'reason_text' => 'Global incident pause.',
|
|
]);
|
|
|
|
$decision = app(OperationalControlEvaluator::class)->evaluate('restore.execute', $workspace);
|
|
|
|
expect($decision->isPaused())->toBeTrue()
|
|
->and($decision->matchedScopeType)->toBe('global')
|
|
->and($decision->workspaceId)->toBeNull()
|
|
->and($decision->reasonText)->toBe('Global incident pause.')
|
|
->and($decision->sourceActivationId)->toBe((int) $globalActivation->getKey());
|
|
});
|
|
|
|
it('ignores expired global activations when resolving the effective state', function (): void {
|
|
$workspace = Workspace::factory()->create();
|
|
|
|
OperationalControlActivation::factory()->forGlobalScope()->create([
|
|
'control_key' => 'restore.execute',
|
|
'reason_text' => 'Expired global pause.',
|
|
'expires_at' => now()->subMinute(),
|
|
]);
|
|
|
|
$workspaceActivation = OperationalControlActivation::factory()->workspaceScoped()->create([
|
|
'control_key' => 'restore.execute',
|
|
'workspace_id' => (int) $workspace->getKey(),
|
|
'reason_text' => 'Active workspace pause.',
|
|
]);
|
|
|
|
$decision = app(OperationalControlEvaluator::class)->evaluate('restore.execute', $workspace);
|
|
|
|
expect($decision->isPaused())->toBeTrue()
|
|
->and($decision->matchedScopeType)->toBe('workspace')
|
|
->and($decision->workspaceId)->toBe((int) $workspace->getKey())
|
|
->and($decision->reasonText)->toBe('Active workspace pause.')
|
|
->and($decision->sourceActivationId)->toBe((int) $workspaceActivation->getKey());
|
|
}); |