mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Добавлена возможность указывать длину генерируемого otp_secret
This commit is contained in:
@ -6,8 +6,10 @@ use common\helpers\Error as E;
|
||||
use common\models\Account;
|
||||
use OTPHP\TOTP;
|
||||
use tests\codeception\api\unit\TestCase;
|
||||
use tests\codeception\common\_support\ProtectedCaller;
|
||||
|
||||
class TwoFactorAuthFormTest extends TestCase {
|
||||
use ProtectedCaller;
|
||||
|
||||
public function testGetCredentials() {
|
||||
/** @var Account|\PHPUnit_Framework_MockObject_MockObject $account */
|
||||
@ -162,4 +164,23 @@ class TwoFactorAuthFormTest extends TestCase {
|
||||
$this->assertEquals('Ely.by', $totp->getIssuer());
|
||||
}
|
||||
|
||||
public function testSetOtpSecret() {
|
||||
/** @var Account|\PHPUnit_Framework_MockObject_MockObject $account */
|
||||
$account = $this->getMockBuilder(Account::class)
|
||||
->setMethods(['save'])
|
||||
->getMock();
|
||||
|
||||
$account->expects($this->exactly(2))
|
||||
->method('save')
|
||||
->willReturn(true);
|
||||
|
||||
$model = new TwoFactorAuthForm($account);
|
||||
$this->callProtected($model, 'setOtpSecret');
|
||||
$this->assertEquals(24, strlen($model->getAccount()->otp_secret));
|
||||
|
||||
$model = new TwoFactorAuthForm($account);
|
||||
$this->callProtected($model, 'setOtpSecret', 25);
|
||||
$this->assertEquals(25, strlen($model->getAccount()->otp_secret));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user