test(auth): cover password reset expiration
This commit is contained in:
@@ -49,6 +49,27 @@ class ValidateResetPasswordAttemptControllerTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_it_expires_an_attempt_and_returns_the_expired_code_message(): void
|
||||
{
|
||||
$user = User::factory()->create(['email' => 'ada@example.com']);
|
||||
$attempt = $user->resetPasswordAttempts()->create([
|
||||
'codigo' => '1234',
|
||||
'expires_at' => now()->subSecond(),
|
||||
]);
|
||||
|
||||
$this->postJson('/api/password/reset-attempts/validate', [
|
||||
'email' => 'ada@example.com',
|
||||
'codigo' => '1234',
|
||||
])->assertUnprocessable()
|
||||
->assertJsonValidationErrors('codigo')
|
||||
->assertJsonPath('errors.codigo.0', __('api.auth.reset_code_expired'));
|
||||
|
||||
$this->assertSame(
|
||||
ResetPasswordAttempt::STATUS_EXPIRED,
|
||||
$attempt->fresh()->status,
|
||||
);
|
||||
}
|
||||
|
||||
public function test_it_rejects_an_expired_or_already_validated_attempt(): void
|
||||
{
|
||||
$user = User::factory()->create(['email' => 'ada@example.com']);
|
||||
|
||||
Reference in New Issue
Block a user