change and add tests
This commit is contained in:
parent
2ffb5a4d73
commit
c77f6fa9e2
@ -166,6 +166,6 @@ class d3user_totp extends AdminDetailsController
|
||||
public function getAvailableBackupCodeCount()
|
||||
{
|
||||
$oBackupCodeList = $this->getBackupcodeListObject();
|
||||
return $oBackupCodeList->getAvailableCodeCount($this->getUser()->getId());
|
||||
return $oBackupCodeList->getAvailableCodeCount($this->getEditObjectId());
|
||||
}
|
||||
}
|
@ -51,7 +51,6 @@ class d3totp extends BaseModel
|
||||
|
||||
/**
|
||||
* @param $userId
|
||||
* @return bool
|
||||
* @throws DBALException
|
||||
* @throws DatabaseConnectionException
|
||||
*/
|
||||
@ -66,10 +65,8 @@ class d3totp extends BaseModel
|
||||
->where("oxuserid = " . $oQB->createNamedParameter($userId))
|
||||
->setMaxResults(1);
|
||||
|
||||
return $this->load(DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getOne($oQB->getSQL(), $oQB->getParameters()));
|
||||
$this->load(DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getOne($oQB->getSQL(), $oQB->getParameters()));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,8 @@
|
||||
[{include file="headitem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign}]
|
||||
|
||||
[{assign var="totp" value=$edit->d3GetTotp()}]
|
||||
[{assign var="userid" value=$edit->getId()}]
|
||||
[{$totp->loadByUserId($userid)}]
|
||||
|
||||
[{if $readonly}]
|
||||
[{assign var="readonly" value="readonly disabled"}]
|
||||
|
@ -3,6 +3,8 @@
|
||||
<h1 class="page-header">[{oxmultilang ident="D3_TOTP_ACCOUNT"}]</h1>
|
||||
|
||||
[{assign var="totp" value=$user->d3GetTotp()}]
|
||||
[{assign var="userid" value=$user->getId()}]
|
||||
[{$totp->loadByUserId($userid)}]
|
||||
|
||||
<style type="text/css">
|
||||
.registerNew {
|
||||
|
@ -39,10 +39,7 @@ class d3_totp_user extends d3_totp_user_parent
|
||||
*/
|
||||
public function d3getTotp()
|
||||
{
|
||||
$oTotp = oxNew(d3totp::class);
|
||||
$oTotp->loadByUserId($this->getId());
|
||||
|
||||
return $oTotp;
|
||||
return oxNew(d3totp::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,7 +15,7 @@
|
||||
* @link http://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\Totp\tests\unit\Application\Controller;
|
||||
namespace D3\Totp\tests\unit\Application\Controller\Admin;
|
||||
|
||||
use D3\Totp\Application\Controller\Admin\d3user_totp;
|
||||
use D3\Totp\Application\Model\d3backupcodelist;
|
||||
@ -104,6 +104,49 @@ class d3user_totpTest extends d3TotpUnitTestCase
|
||||
$this->assertSame($oxid, 'foobar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canRenderUnloadableUser()
|
||||
{
|
||||
/** @var User|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
$oUserMock = $this->getMock(User::class, array(
|
||||
'getId',
|
||||
'load',
|
||||
));
|
||||
$oUserMock->expects($this->never())->method('getId');
|
||||
$oUserMock->expects($this->atLeast(1))->method('load')->willReturn(false);
|
||||
|
||||
/** @var d3user_totp|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMock(d3user_totp::class, array(
|
||||
'getEditObjectId',
|
||||
'getUserObject',
|
||||
'addTplParam'
|
||||
));
|
||||
$oControllerMock->method('getEditObjectId')->willReturn('foobar');
|
||||
$oControllerMock->expects($this->once())->method('getUserObject')->willReturn($oUserMock);
|
||||
$oControllerMock->expects($this->exactly(3))->method('addTplParam')->with(
|
||||
$this->logicalOr(
|
||||
$this->stringContains('sSaveError'),
|
||||
$this->stringContains('oxid'),
|
||||
$this->stringContains('edit')
|
||||
)
|
||||
);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
$this->setValue($this->_oController, '_sSaveError', 'foo');
|
||||
|
||||
$sTpl = $this->callMethod($this->_oController, 'render');
|
||||
$tplUser = $this->callMethod($this->_oController, 'getViewDataElement', array('edit'));
|
||||
$oxid = $this->callMethod($this->_oController, 'getViewDataElement', array('oxid'));
|
||||
|
||||
$this->assertSame('d3user_totp.tpl', $sTpl);
|
||||
$this->assertNull($tplUser);
|
||||
$this->assertSame($oxid, 'foobar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
@ -155,7 +198,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'save',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->never())->method('save')->willReturn(true);
|
||||
|
||||
/** @var User|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
@ -202,7 +245,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
|
||||
'verify',
|
||||
'saveSecret',
|
||||
'assign'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('load')->willReturn(true);
|
||||
$oTotpMock->expects($this->never())->method('save')->willReturn(true);
|
||||
$oTotpMock->expects($this->once())->method('verify')->willThrowException(new Exception());
|
||||
@ -255,8 +298,8 @@ class d3user_totpTest extends d3TotpUnitTestCase
|
||||
'verify',
|
||||
'saveSecret',
|
||||
'assign'
|
||||
));
|
||||
$oTotpMock->method('load')->willReturn(true);
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->never())->method('load')->willReturn(true);
|
||||
$oTotpMock->expects($this->once())->method('save')->willReturn(true);
|
||||
$oTotpMock->expects($this->once())->method('verify')->willReturn(true);
|
||||
$oTotpMock->method('saveSecret')->willReturn(true);
|
||||
@ -287,6 +330,64 @@ class d3user_totpTest extends d3TotpUnitTestCase
|
||||
$this->callMethod($this->_oController, 'save');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canSaveWithKnownOXID()
|
||||
{
|
||||
$aEditval = [
|
||||
'd3totp__oxid' => 'foo'
|
||||
];
|
||||
$_GET['editval'] = $aEditval;
|
||||
|
||||
/** @var d3backupcodelist|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
$oBackupCodeListMock = $this->getMock(d3backupcodelist::class, array(
|
||||
'save',
|
||||
'generateBackupCodes'
|
||||
));
|
||||
$oBackupCodeListMock->expects($this->once())->method('save')->willReturn(true);
|
||||
$oBackupCodeListMock->method('generateBackupCodes')->willReturn(true);
|
||||
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'load',
|
||||
'save',
|
||||
'verify',
|
||||
'saveSecret',
|
||||
'assign'
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->once())->method('load')->willReturn(true);
|
||||
$oTotpMock->expects($this->once())->method('save')->willReturn(true);
|
||||
$oTotpMock->expects($this->never())->method('verify')->willReturn(true);
|
||||
$oTotpMock->method('saveSecret')->willReturn(true);
|
||||
$oTotpMock->method('assign')->willReturn(true);
|
||||
|
||||
/** @var User|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
$oUserMock = $this->getMock(User::class, array(
|
||||
'load',
|
||||
'isSamePassword',
|
||||
));
|
||||
$oUserMock->expects($this->atLeast(1))->method('load')->willReturn(true);
|
||||
$oUserMock->expects($this->atLeast(1))->method('isSamePassword')->willReturn(true);
|
||||
|
||||
/** @var d3user_totp|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMock(d3user_totp::class, array(
|
||||
'getEditObjectId',
|
||||
'getUserObject',
|
||||
'getTotpObject',
|
||||
'getBackupcodeListObject'
|
||||
));
|
||||
$oControllerMock->method('getEditObjectId')->willReturn('foobar');
|
||||
$oControllerMock->expects($this->once())->method('getUserObject')->willReturn($oUserMock);
|
||||
$oControllerMock->method('getTotpObject')->willReturn($oTotpMock);
|
||||
$oControllerMock->method('getBackupcodeListObject')->willReturn($oBackupCodeListMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
$this->callMethod($this->_oController, 'save');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
@ -317,7 +418,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'delete'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->never())->method('delete');
|
||||
|
||||
/** @var d3user_totp|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
@ -344,9 +445,11 @@ class d3user_totpTest extends d3TotpUnitTestCase
|
||||
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'delete'
|
||||
));
|
||||
'delete',
|
||||
'load'
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->once())->method('delete')->willReturn(true);
|
||||
$oTotpMock->method('load')->willReturn(true);
|
||||
|
||||
/** @var d3user_totp|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMock(d3user_totp::class, array(
|
||||
|
@ -202,7 +202,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
|
||||
'assign',
|
||||
'verify',
|
||||
'save'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('saveSecret')->willReturn(true);
|
||||
$oTotpMock->method('assign')->willReturn(true);
|
||||
$oTotpMock->expects($this->once())->method('verify')->willThrowException(new Exception('foo'));
|
||||
@ -250,7 +250,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
|
||||
'verify',
|
||||
'save',
|
||||
'setId',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('saveSecret')->willReturn(true);
|
||||
$oTotpMock->method('assign')->willReturn(true);
|
||||
$oTotpMock->method('verify')->willReturn(true);
|
||||
@ -305,7 +305,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'delete'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->never())->method('delete');
|
||||
|
||||
/** @var d3_account_totp|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
@ -331,9 +331,11 @@ class d3_account_totpTest extends d3TotpUnitTestCase
|
||||
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'delete'
|
||||
));
|
||||
'delete',
|
||||
'loadByUserId'
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->once())->method('delete')->willReturn(true);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
$oUser = oxNew(User::class);
|
||||
$oUser->setId('foo');
|
||||
@ -350,4 +352,16 @@ class d3_account_totpTest extends d3TotpUnitTestCase
|
||||
|
||||
$this->callMethod($this->_oController, 'delete');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function getTotpObjectReturnsRightObject()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
d3totp::class,
|
||||
$this->callMethod($this->_oController, 'getTotpObject')
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This Software is the property of Data Development and is protected
|
||||
* by copyright law - it is NOT Freeware.
|
||||
*
|
||||
* Any unauthorized use of this software without a valid license
|
||||
* is a violation of the license agreement and will be prosecuted by
|
||||
* civil and criminal law.
|
||||
*
|
||||
* http://www.shopmodule.com
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\Totp\tests\unit\Application\Model\Exceptions;
|
||||
|
||||
use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException;
|
||||
use D3\Totp\tests\unit\d3TotpUnitTestCase;
|
||||
use ReflectionException;
|
||||
|
||||
class d3totp_wrongOtpExceptionTest extends d3TotpUnitTestCase
|
||||
{
|
||||
/** @var d3totp_wrongOtpException */
|
||||
protected $_oModel;
|
||||
|
||||
/**
|
||||
* setup basic requirements
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->_oModel = oxNew(d3totp_wrongOtpException::class);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
unset($this->_oModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function constructorHasRightDefaultMessage()
|
||||
{
|
||||
$this->_oModel = oxNew(d3totp_wrongOtpException::class);
|
||||
$this->assertSame(
|
||||
'D3_TOTP_ERROR_UNVALID',
|
||||
$this->callMethod($this->_oModel, 'getMessage')
|
||||
);
|
||||
}
|
||||
}
|
57
src/tests/unit/Application/Model/d3RandomGeneratorTest.php
Normal file
57
src/tests/unit/Application/Model/d3RandomGeneratorTest.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This Software is the property of Data Development and is protected
|
||||
* by copyright law - it is NOT Freeware.
|
||||
*
|
||||
* Any unauthorized use of this software without a valid license
|
||||
* is a violation of the license agreement and will be prosecuted by
|
||||
* civil and criminal law.
|
||||
*
|
||||
* http://www.shopmodule.com
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\Totp\tests\unit\Application\Model;
|
||||
|
||||
use D3\Totp\Application\Model\d3RandomGenerator;
|
||||
use D3\Totp\tests\unit\d3TotpUnitTestCase;
|
||||
use ReflectionException;
|
||||
|
||||
class d3RandomGeneratorTest extends d3TotpUnitTestCase
|
||||
{
|
||||
/** @var d3RandomGenerator */
|
||||
protected $_oModel;
|
||||
|
||||
/**
|
||||
* setup basic requirements
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->_oModel = oxNew(d3RandomGenerator::class);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
unset($this->_oModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function getRandomTotpBackupCodeReturnsRightCode()
|
||||
{
|
||||
$this->assertRegExp(
|
||||
'@[0-9]{6}@',
|
||||
$this->callMethod($this->_oModel, 'getRandomTotpBackupCode')
|
||||
);
|
||||
}
|
||||
}
|
@ -71,7 +71,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->never())->method('isActive')->willReturn(false);
|
||||
|
||||
/** @var UserComponent|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
@ -112,9 +112,11 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
));
|
||||
'loadByUserId'
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->once())->method('isActive')->willReturn(false);
|
||||
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
/** @var UserComponent|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMock(UserComponent::class, array(
|
||||
'getUser',
|
||||
@ -153,8 +155,10 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
));
|
||||
'loadByUserId'
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->once())->method('isActive')->willReturn(true);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
/** @var UserComponent|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMock(UserComponent::class, array(
|
||||
@ -192,15 +196,23 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
*/
|
||||
public function checkTotploginNoTotpLogin()
|
||||
{
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'loadByUserId'
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
/** @var UserComponent|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMock(UserComponent::class, array(
|
||||
'isNoTotpOrNoLogin',
|
||||
'hasValidTotp',
|
||||
'd3TotpRelogin'
|
||||
'd3TotpRelogin',
|
||||
'd3GetTotpObject'
|
||||
));
|
||||
$oControllerMock->method('isNoTotpOrNoLogin')->willReturn(true);
|
||||
$oControllerMock->expects($this->never())->method('hasValidTotp')->willReturn(false);
|
||||
$oControllerMock->expects($this->never())->method('d3TotpRelogin')->willReturn(false);
|
||||
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
@ -216,6 +228,15 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
*/
|
||||
public function checkTotploginUnvalidTotp()
|
||||
{
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'loadByUserId'
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
/** @var d3totp_wrongOtpException|PHPUnit_Framework_MockObject_MockObject $oUtilsViewMock */
|
||||
$oTotpExceptionMock = $this->getMock(d3totp_wrongOtpException::class, array(), array(), '', false);
|
||||
|
||||
/** @var UtilsView|PHPUnit_Framework_MockObject_MockObject $oUtilsViewMock */
|
||||
$oUtilsViewMock = $this->getMock(UtilsView::class, array(
|
||||
'addErrorToDisplay',
|
||||
@ -227,12 +248,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
'isNoTotpOrNoLogin',
|
||||
'hasValidTotp',
|
||||
'd3TotpRelogin',
|
||||
'd3GetUtilsView'
|
||||
'd3GetUtilsView',
|
||||
'd3GetTotpObject'
|
||||
));
|
||||
$oControllerMock->method('isNoTotpOrNoLogin')->willReturn(false);
|
||||
$oControllerMock->expects($this->once())->method('hasValidTotp')->willThrowException(oxNew(d3totp_wrongOtpException::class));
|
||||
$oControllerMock->expects($this->once())->method('hasValidTotp')->willThrowException($oTotpExceptionMock);
|
||||
$oControllerMock->expects($this->never())->method('d3TotpRelogin')->willReturn(false);
|
||||
$oControllerMock->method('d3GetUtilsView')->willReturn($oUtilsViewMock);
|
||||
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
@ -248,6 +271,12 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
*/
|
||||
public function checkTotploginValidTotp()
|
||||
{
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'loadByUserId'
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
/** @var UtilsView|PHPUnit_Framework_MockObject_MockObject $oUtilsViewMock */
|
||||
$oUtilsViewMock = $this->getMock(UtilsView::class, array(
|
||||
'addErrorToDisplay',
|
||||
@ -259,12 +288,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
'isNoTotpOrNoLogin',
|
||||
'hasValidTotp',
|
||||
'd3TotpRelogin',
|
||||
'd3GetUtilsView'
|
||||
'd3GetUtilsView',
|
||||
'd3GetTotpObject'
|
||||
));
|
||||
$oControllerMock->method('isNoTotpOrNoLogin')->willReturn(false);
|
||||
$oControllerMock->expects($this->once())->method('hasValidTotp')->willReturn(true);
|
||||
$oControllerMock->expects($this->once())->method('d3TotpRelogin')->willReturn(true);
|
||||
$oControllerMock->method('d3GetUtilsView')->willReturn($oUtilsViewMock);
|
||||
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
@ -313,7 +344,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('isActive')->willReturn(true);
|
||||
|
||||
$this->assertTrue(
|
||||
@ -332,7 +363,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('isActive')->willReturn(false);
|
||||
|
||||
$this->assertTrue(
|
||||
@ -351,7 +382,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('isActive')->willReturn(true);
|
||||
|
||||
$this->assertFalse(
|
||||
@ -370,7 +401,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'verify',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('verify')->willReturn(false);
|
||||
|
||||
$this->assertTrue(
|
||||
@ -389,7 +420,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'verify',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('verify')->willReturn(true);
|
||||
|
||||
$this->assertTrue(
|
||||
@ -408,7 +439,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'verify',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('verify')->willReturn(true);
|
||||
|
||||
$this->assertFalse(
|
||||
@ -427,7 +458,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'verify',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('verify')->willReturn(false);
|
||||
|
||||
$this->assertFalse(
|
||||
|
@ -61,7 +61,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
'loadByUserId'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->never())->method('isActive')->willReturn(false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
@ -97,7 +97,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
'loadByUserId'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->once())->method('isActive')->willReturn(false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
@ -133,7 +133,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
'loadByUserId'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->once())->method('isActive')->willReturn(false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
@ -169,7 +169,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
'loadByUserId'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->expects($this->once())->method('isActive')->willReturn(true);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
@ -252,7 +252,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'loadByUserId'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
/** @var d3_totp_LoginController|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
@ -276,6 +276,9 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
*/
|
||||
public function checkloginUnvalidTotp()
|
||||
{
|
||||
/** @var d3totp_wrongOtpException|PHPUnit_Framework_MockObject_MockObject $oUtilsViewMock */
|
||||
$oTotpExceptionMock = $this->getMock(d3totp_wrongOtpException::class, array(), array(), '', false);
|
||||
|
||||
/** @var UtilsView|PHPUnit_Framework_MockObject_MockObject $utilsViewMock */
|
||||
$utilsViewMock = $this->getMock(UtilsView::class, array(
|
||||
'addErrorToDisplay',
|
||||
@ -285,7 +288,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'loadByUserId'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
/** @var d3_totp_LoginController|PHPUnit_Framework_MockObject_MockObject $oControllerMock */
|
||||
@ -297,7 +300,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
));
|
||||
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
$oControllerMock->method('isNoTotpOrNoLogin')->willReturn(false);
|
||||
$oControllerMock->method('hasValidTotp')->willThrowException(oxNew(d3totp_wrongOtpException::class));
|
||||
$oControllerMock->method('hasValidTotp')->willThrowException($oTotpExceptionMock);
|
||||
$oControllerMock->method('d3GetUtilsView')->willReturn($utilsViewMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
@ -320,7 +323,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'loadByUserId'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
/** @var Session|PHPUnit_Framework_MockObject_MockObject $oSessionMock */
|
||||
@ -411,7 +414,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('isActive')->willReturn(true);
|
||||
|
||||
/** @var Session|PHPUnit_Framework_MockObject_MockObject $oSessionMock */
|
||||
@ -442,7 +445,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('isActive')->willReturn(true);
|
||||
|
||||
/** @var Session|PHPUnit_Framework_MockObject_MockObject $oSessionMock */
|
||||
@ -473,7 +476,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('isActive')->willReturn(false);
|
||||
|
||||
/** @var Session|PHPUnit_Framework_MockObject_MockObject $oSessionMock */
|
||||
@ -506,7 +509,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'verify',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('verify')->willReturn(false);
|
||||
|
||||
$this->assertTrue(
|
||||
@ -525,7 +528,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'verify',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('verify')->willReturn(true);
|
||||
|
||||
$this->assertTrue(
|
||||
@ -544,7 +547,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'verify',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('verify')->willReturn(true);
|
||||
|
||||
$this->assertFalse(
|
||||
@ -563,7 +566,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
/** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'verify',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('verify')->willReturn(false);
|
||||
|
||||
$this->assertFalse(
|
||||
|
@ -64,7 +64,7 @@ trait d3_totp_getUserTestTrait
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
'loadByUserId'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('isActive')->willReturn(false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
@ -107,7 +107,7 @@ trait d3_totp_getUserTestTrait
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
'loadByUserId'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('isActive')->willReturn(true);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
@ -150,7 +150,7 @@ trait d3_totp_getUserTestTrait
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'isActive',
|
||||
'loadByUserId'
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('isActive')->willReturn(true);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
|
||||
|
@ -60,7 +60,7 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'loadByUserId',
|
||||
'isActive',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
$oTotpMock->method('isActive')->willReturn(false);
|
||||
|
||||
@ -91,7 +91,7 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'loadByUserId',
|
||||
'isActive',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
$oTotpMock->method('isActive')->willReturn(false);
|
||||
|
||||
@ -130,7 +130,7 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'loadByUserId',
|
||||
'isActive',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
$oTotpMock->method('isActive')->willReturn(true);
|
||||
|
||||
@ -177,7 +177,7 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
|
||||
$oTotpMock = $this->getMock(d3totp::class, array(
|
||||
'loadByUserId',
|
||||
'isActive',
|
||||
));
|
||||
), array(), '', false);
|
||||
$oTotpMock->method('loadByUserId')->willReturn(true);
|
||||
$oTotpMock->method('isActive')->willReturn(true);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user