mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
В форму включения двухфакторной аутентификации добавлено поле для фиксации времени запроса
This commit is contained in:
@ -14,7 +14,7 @@ class TotpValidatorTest extends TestCase {
|
||||
public function testValidateValue() {
|
||||
$account = new Account();
|
||||
$account->otp_secret = 'some secret';
|
||||
$controlTotp = new TOTP(null, 'some secret');
|
||||
$controlTotp = new TOTP(null, $account->otp_secret);
|
||||
|
||||
$validator = new TotpValidator(['account' => $account]);
|
||||
|
||||
@ -27,9 +27,24 @@ class TotpValidatorTest extends TestCase {
|
||||
$result = $this->callProtected($validator, 'validateValue', $controlTotp->at(time() - 31));
|
||||
$this->assertEquals([E::OTP_TOKEN_INCORRECT, []], $result);
|
||||
|
||||
$validator->window = 60;
|
||||
$validator->window = 2;
|
||||
$result = $this->callProtected($validator, 'validateValue', $controlTotp->at(time() - 31));
|
||||
$this->assertNull($result);
|
||||
|
||||
$at = time() - 400;
|
||||
$validator->timestamp = $at;
|
||||
$result = $this->callProtected($validator, 'validateValue', $controlTotp->now());
|
||||
$this->assertEquals([E::OTP_TOKEN_INCORRECT, []], $result);
|
||||
|
||||
$result = $this->callProtected($validator, 'validateValue', $controlTotp->at($at));
|
||||
$this->assertNull($result);
|
||||
|
||||
$at = function() {
|
||||
return time() - 700;
|
||||
};
|
||||
$validator->timestamp = $at;
|
||||
$result = $this->callProtected($validator, 'validateValue', $controlTotp->at($at()));
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user