Automated PR provided by Codex via Gitea API. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #482
32 lines
1.3 KiB
PHP
32 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Jobs\TenantConfiguration\CaptureTenantConfigurationEvidenceJob;
|
|
use App\Models\ProviderConnection;
|
|
use App\Services\TenantConfiguration\StartTenantConfigurationCapture;
|
|
use App\Support\OperationRunStatus;
|
|
use Illuminate\Support\Facades\Queue;
|
|
|
|
it('reuses active capture runs and keeps queued context sanitized', function (): void {
|
|
Queue::fake();
|
|
|
|
[$user, $tenant] = createMinimalUserWithTenant(role: 'owner');
|
|
$connection = ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'managed_environment_id' => (int) $tenant->getKey(),
|
|
]);
|
|
|
|
$service = app(StartTenantConfigurationCapture::class);
|
|
|
|
$first = $service->start($tenant, $connection, $user, ['deviceAndAppManagementAssignmentFilter']);
|
|
$second = $service->start($tenant, $connection, $user, ['deviceAndAppManagementAssignmentFilter']);
|
|
|
|
expect($second->getKey())->toBe($first->getKey())
|
|
->and($first->status)->toBe(OperationRunStatus::Queued->value)
|
|
->and(json_encode($first->context, JSON_THROW_ON_ERROR))->not->toContain('client_secret')
|
|
->and(json_encode($first->context, JSON_THROW_ON_ERROR))->not->toContain('access_token');
|
|
|
|
Queue::assertPushed(CaptureTenantConfigurationEvidenceJob::class, 1);
|
|
});
|