varias alteracoes
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-06 14:50:12 +02:00
parent 4f35313d06
commit e65cb26901
333 changed files with 54656 additions and 2058 deletions
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace Tests\Feature;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Tests\TestCase;
class SimulationRateLimitTest extends TestCase
{
public function test_public_calculation_endpoint_limits_repeated_requests_per_anonymous_token(): void
{
$token = Str::random(48);
$limiterKey = 'simulation-calculation:anonymous:'.hash('sha256', $token);
RateLimiter::clear($limiterKey);
try {
for ($attempt = 0; $attempt < 10; $attempt++) {
$this->postJson('/api/v1/simulations', [], [
'X-Simulation-Token' => $token,
])->assertUnprocessable();
}
$response = $this->postJson('/api/v1/simulations', [], [
'X-Simulation-Token' => $token,
])->assertTooManyRequests()->assertHeader('Retry-After');
$this->assertStringContainsString('demasiados', (string) $response->json('message'));
} finally {
RateLimiter::clear($limiterKey);
}
}
}