Some checks failed
Main Confidence / confidence (push) Failing after 49s
## Summary - unify provider-backed action starts behind the shared provider dispatch gate and shared start-result presenter - align tenant, onboarding, provider-connection, restore, directory, and monitoring surfaces with the same blocked, deduped, scope-busy, and accepted semantics - include the spec kit artifacts for spec 216 and the regression fixes that brought the full suite back to green ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/RestoreRunIdempotencyTest.php tests/Feature/ExecuteRestoreRunJobTest.php tests/Feature/Restore/RestoreRunProviderStartTest.php tests/Feature/Hardening/ExecuteRestoreRunJobGateTest.php tests/Feature/Hardening/BlockedWriteAuditLogTest.php tests/Feature/Onboarding/OnboardingDraftLifecycleTest.php` - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Browser/Spec177InventoryCoverageTruthSmokeTest.php` - `cd apps/platform && ./vendor/bin/sail artisan test --compact` ## Notes - branch: `216-provider-dispatch-gate` - commit: `34230be7` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #255
158 lines
6.3 KiB
PHP
158 lines
6.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Tests\Support\OpsUx\SourceFileScanner;
|
|
|
|
function providerDispatchGateSlice(string $source, string $startAnchor, ?string $endAnchor = null): string
|
|
{
|
|
$start = strpos($source, $startAnchor);
|
|
|
|
expect($start)->not->toBeFalse();
|
|
|
|
$start = is_int($start) ? $start : 0;
|
|
|
|
if ($endAnchor === null) {
|
|
return substr($source, $start);
|
|
}
|
|
|
|
$end = strpos($source, $endAnchor, $start + strlen($startAnchor));
|
|
|
|
expect($end)->not->toBeFalse();
|
|
|
|
$end = is_int($end) ? $end : strlen($source);
|
|
|
|
return substr($source, $start, $end - $start);
|
|
}
|
|
|
|
it('keeps first-slice route-bounded provider starts on canonical gate-owned entry points', function (): void {
|
|
$root = SourceFileScanner::projectRoot();
|
|
|
|
$checks = [
|
|
[
|
|
'file' => $root.'/app/Services/Verification/StartVerification.php',
|
|
'start' => 'public function providerConnectionCheckForTenant(',
|
|
'end' => 'public function providerConnectionCheckUsingConnection(',
|
|
'required' => [
|
|
'return $this->providers->start(',
|
|
"operationType: 'provider.connection.check'",
|
|
"'required_capability' => Capabilities::PROVIDER_RUN",
|
|
],
|
|
'forbidden' => ['ensureRun(', 'dispatchOrFail('],
|
|
],
|
|
[
|
|
'file' => $root.'/app/Services/Verification/StartVerification.php',
|
|
'start' => 'public function providerConnectionCheckUsingConnection(',
|
|
'end' => 'private function dispatchConnectionHealthCheck(',
|
|
'required' => [
|
|
'$result = $this->providers->start(',
|
|
"operationType: 'provider.connection.check'",
|
|
'ProviderVerificationStatus::Pending',
|
|
],
|
|
'forbidden' => ['ensureRun(', 'dispatchOrFail('],
|
|
],
|
|
[
|
|
'file' => $root.'/app/Services/Directory/EntraGroupSyncService.php',
|
|
'start' => 'public function startManualSync(',
|
|
'end' => 'public function sync(',
|
|
'required' => [
|
|
'return $this->providerStarts->start(',
|
|
"operationType: 'entra_group_sync'",
|
|
'EntraGroupSyncJob::dispatch(',
|
|
'->afterCommit()',
|
|
],
|
|
'forbidden' => ['ensureRun(', 'dispatchOrFail('],
|
|
],
|
|
[
|
|
'file' => $root.'/app/Services/Directory/RoleDefinitionsSyncService.php',
|
|
'start' => 'public function startManualSync(',
|
|
'end' => 'public function sync(',
|
|
'required' => [
|
|
'return $this->providerStarts->start(',
|
|
"operationType: 'directory_role_definitions.sync'",
|
|
'SyncRoleDefinitionsJob::dispatch(',
|
|
'->afterCommit()',
|
|
],
|
|
'forbidden' => ['ensureRun(', 'dispatchOrFail('],
|
|
],
|
|
[
|
|
'file' => $root.'/app/Filament/Resources/RestoreRunResource.php',
|
|
'start' => 'private static function startQueuedRestoreExecution(',
|
|
'end' => 'private static function detailPreviewState(',
|
|
'required' => [
|
|
'app(ProviderOperationStartGate::class)->start(',
|
|
"operationType: 'restore.execute'",
|
|
'ExecuteRestoreRunJob::dispatch(',
|
|
'->afterCommit()',
|
|
],
|
|
'forbidden' => ['ensureRun(', 'dispatchOrFail('],
|
|
],
|
|
[
|
|
'file' => $root.'/app/Filament/Resources/EntraGroupResource/Pages/ListEntraGroups.php',
|
|
'start' => "Action::make('sync_groups')",
|
|
'end' => '->requireCapability(Capabilities::TENANT_SYNC)',
|
|
'required' => [
|
|
'$syncService->startManualSync($tenant, $user)',
|
|
'ProviderOperationStartResultPresenter::class',
|
|
],
|
|
'forbidden' => ['ensureRun(', 'dispatchOrFail('],
|
|
],
|
|
[
|
|
'file' => $root.'/app/Filament/Resources/TenantResource.php',
|
|
'start' => 'public static function syncRoleDefinitionsAction(): Actions\\Action',
|
|
'end' => null,
|
|
'required' => [
|
|
'$result = $syncService->startManualSync($record, $user);',
|
|
'ProviderOperationStartResultPresenter::class',
|
|
],
|
|
'forbidden' => ['ensureRun(', 'dispatchOrFail('],
|
|
],
|
|
[
|
|
'file' => $root.'/app/Filament/Resources/ProviderConnectionResource.php',
|
|
'start' => 'private static function handleCheckConnectionAction(',
|
|
'end' => 'private static function handleProviderOperationAction(',
|
|
'required' => [
|
|
'$verification->providerConnectionCheck(',
|
|
'ProviderOperationStartResultPresenter::class',
|
|
'OperationRunLinks::view($result->run, $tenant)',
|
|
],
|
|
'forbidden' => ['ensureRun(', 'dispatchOrFail('],
|
|
],
|
|
[
|
|
'file' => $root.'/app/Filament/Resources/ProviderConnectionResource.php',
|
|
'start' => 'private static function handleProviderOperationAction(',
|
|
'end' => 'public static function getEloquentQuery(): Builder',
|
|
'required' => [
|
|
'$result = $gate->start(',
|
|
'ProviderOperationStartResultPresenter::class',
|
|
'OperationRunLinks::view($result->run, $tenant)',
|
|
],
|
|
'forbidden' => ['ensureRun(', 'dispatchOrFail('],
|
|
],
|
|
[
|
|
'file' => $root.'/app/Filament/Pages/Workspaces/ManagedTenantOnboardingWizard.php',
|
|
'start' => 'public function startBootstrap(array $operationTypes): void',
|
|
'end' => 'private function dispatchBootstrapJob(',
|
|
'required' => [
|
|
'app(ProviderOperationStartGate::class)->start(',
|
|
'ProviderOperationStartResultPresenter::class',
|
|
"'bootstrap_operation_types'",
|
|
],
|
|
'forbidden' => ['ensureRun(', 'dispatchOrFail('],
|
|
],
|
|
];
|
|
|
|
foreach ($checks as $check) {
|
|
$source = SourceFileScanner::read($check['file']);
|
|
$slice = providerDispatchGateSlice($source, $check['start'], $check['end']);
|
|
|
|
foreach ($check['required'] as $needle) {
|
|
expect($slice)->toContain($needle);
|
|
}
|
|
|
|
foreach ($check['forbidden'] as $needle) {
|
|
expect($slice)->not->toContain($needle);
|
|
}
|
|
}
|
|
})->group('surface-guard');
|