mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-12 15:53:46 -04:00
- Remove tests that only check markup, CSS, static text, wire:key strings, framework behavior, copied app logic, or expect(true) - Replace source-grep and Reflection checks of security fixes with tests that run the real code (shell quoting, locked properties, 403 checks, webhook fork trust, log redaction, Sentinel token cleanup) - Assert response bodies and unchanged data on API error paths - Run the Traefik version job through handle() instead of private methods - Update stale tests for scheduled task props, the default Postgres image, and the disabled transfer link of unvalidated servers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.7 KiB
PHP
47 lines
1.7 KiB
PHP
<?php
|
|
|
|
use App\Jobs\ScheduledJobManager;
|
|
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
it('uses WithoutOverlapping middleware with expireAfter to prevent stale locks', function () {
|
|
$job = new ScheduledJobManager;
|
|
$middleware = $job->middleware();
|
|
|
|
// Assert middleware exists
|
|
expect($middleware)->toBeArray()
|
|
->and($middleware)->toHaveCount(1);
|
|
|
|
$overlappingMiddleware = $middleware[0];
|
|
|
|
// Assert it's a WithoutOverlapping instance
|
|
expect($overlappingMiddleware)->toBeInstanceOf(WithoutOverlapping::class);
|
|
|
|
// Use reflection to check private properties
|
|
$reflection = new ReflectionClass($overlappingMiddleware);
|
|
|
|
// Check expireAfter is set (should be 60 seconds - matches job frequency)
|
|
$expiresAfterProperty = $reflection->getProperty('expiresAfter');
|
|
$expiresAfterProperty->setAccessible(true);
|
|
$expiresAfter = $expiresAfterProperty->getValue($overlappingMiddleware);
|
|
|
|
expect($expiresAfter)->toBe(90)
|
|
->and($expiresAfter)->toBeGreaterThan(0, 'expireAfter must be set to prevent stale locks');
|
|
|
|
// Check releaseAfter is NOT set (we use dontRelease)
|
|
$releaseAfterProperty = $reflection->getProperty('releaseAfter');
|
|
$releaseAfterProperty->setAccessible(true);
|
|
$releaseAfter = $releaseAfterProperty->getValue($overlappingMiddleware);
|
|
|
|
expect($releaseAfter)->toBeNull('releaseAfter should be null when using dontRelease()');
|
|
|
|
// Check the lock key
|
|
$keyProperty = $reflection->getProperty('key');
|
|
$keyProperty->setAccessible(true);
|
|
$key = $keyProperty->getValue($overlappingMiddleware);
|
|
|
|
expect($key)->toBe('scheduled-job-manager');
|
|
});
|