emabusi's avatar

Login throttling unit test

I am using laravel auth scaffolding with loging throttling and I would like to write unit test (preferrably not dusk) to test that its working but dont know were to start with that as I cannot figure a way to get auth errors (or response data) using phpunit.

0 likes
2 replies
gMagicScott's avatar

Throttling adds a header to the response that you could check for.

/** @test */
function it_adds_throttle_headers() {
    $response = $this->post('/login', [ ...credential array here... ]);

    $response->assertHeader("X-RateLimit-Limit");
}
emabusi's avatar

@gMagicScott I doesnt work I get the erroer "Tests\Unit\AuthTest::it_adds_throttle_headers Header [X-RateLimit-Limit] not present on response. Failed asserting that false is true."

Please or to participate in this conversation.