rename module methods in extended OXID classes to prevent conflicts with other modules, move totp check to _afterLogin for webauthn module compatibility
This commit is contained in:
parent
f110142474
commit
c80b5f626f
@ -13,7 +13,7 @@ class d3force_2fa extends d3user_totp
|
||||
{
|
||||
$this->addTplParam('force2FA', true);
|
||||
|
||||
$userID = $this->d3GetSessionObject()->getVariable("auth");
|
||||
$userID = $this->d3TotpGetSessionObject()->getVariable("auth");
|
||||
$this->_sEditObjectId = $userID;
|
||||
|
||||
return parent::render();
|
||||
@ -22,7 +22,7 @@ class d3force_2fa extends d3user_totp
|
||||
|
||||
protected function _authorize()
|
||||
{
|
||||
$userID = $this->d3GetSessionObject()->getVariable("auth");
|
||||
$userID = $this->d3TotpGetSessionObject()->getVariable("auth");
|
||||
|
||||
return ($this->d3IsAdminForce2FA() && !empty($userID));
|
||||
}
|
||||
@ -30,7 +30,7 @@ class d3force_2fa extends d3user_totp
|
||||
/**
|
||||
* @return Session
|
||||
*/
|
||||
private function d3GetSessionObject()
|
||||
private function d3TotpGetSessionObject()
|
||||
{
|
||||
return Registry::getSession();
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class d3backupcode extends BaseModel
|
||||
public function d3EncodeBC($code, $sUserId)
|
||||
{
|
||||
$oDb = DatabaseProvider::getDb();
|
||||
$oUser = $this->d3GetUserObject();
|
||||
$oUser = $this->d3TotpGetUserObject();
|
||||
$oUser->load($sUserId);
|
||||
$salt = $oUser->getFieldData('oxpasssalt');
|
||||
$sSelect = "SELECT BINARY MD5( CONCAT( " . $oDb->quote($code) . ", UNHEX( ".$oDb->quote($salt)." ) ) )";
|
||||
@ -83,7 +83,7 @@ class d3backupcode extends BaseModel
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function d3GetUserObject()
|
||||
public function d3TotpGetUserObject()
|
||||
{
|
||||
return oxNew(User::class);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
<form action="[{$oViewConf->getSelfActionLink()}]" method="post" name="login" id="login">
|
||||
[{$oViewConf->getHiddenSid()}]
|
||||
|
||||
<input type="hidden" name="fnc" value="d3TotpCheckTotpLogin">
|
||||
<input type="hidden" name="fnc" value="checkTotplogin">
|
||||
<input type="hidden" name="cl" value="[{$oView->getPreviousClass()}]">
|
||||
[{$navFormParams}]
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
<form action="[{$oViewConf->getSelfActionLink()}]" method="post" name="login" id="login">
|
||||
[{$oViewConf->getHiddenSid()}]
|
||||
|
||||
<input type="hidden" name="fnc" value="d3TotpCancelTotpLogin">
|
||||
<input type="hidden" name="fnc" value="cancelTotplogin">
|
||||
<input type="hidden" name="cl" value="[{$oView->getPreviousClass()}]">
|
||||
[{$navFormParams}]
|
||||
|
||||
|
@ -18,6 +18,7 @@ namespace D3\Totp\Modules\Application\Component;
|
||||
use D3\Totp\Application\Model\d3totp;
|
||||
use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use InvalidArgumentException;
|
||||
use OxidEsales\Eshop\Application\Model\User;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
@ -28,29 +29,31 @@ use OxidEsales\Eshop\Core\UtilsView;
|
||||
class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
* @param User $oUser
|
||||
*
|
||||
* @return string
|
||||
* @throws DatabaseConnectionException
|
||||
*/
|
||||
public function login()
|
||||
protected function _afterLogin($oUser)
|
||||
{
|
||||
parent::login();
|
||||
if (!$oUser instanceof User) {
|
||||
throw oxNew( InvalidArgumentException::class, 'user argument must an instance of User class');
|
||||
}
|
||||
|
||||
$oUser = $this->getUser();
|
||||
|
||||
if ($oUser instanceof User && $oUser->getId()) {
|
||||
if ($oUser->getId()) {
|
||||
$totp = $this->d3GetTotpObject();
|
||||
$totp->loadByUserId($oUser->getId());
|
||||
|
||||
if ($totp->isActive()
|
||||
&& !$this->d3TotpGetSession()->getVariable(d3totp::TOTP_SESSION_VARNAME)
|
||||
&& !$this->d3GetSession()->getVariable(d3totp::TOTP_SESSION_VARNAME)
|
||||
) {
|
||||
$this->d3TotpGetSession()->setVariable(
|
||||
$this->d3GetSession()->setVariable(
|
||||
d3totp::TOTP_SESSION_CURRENTCLASS,
|
||||
$this->getParent()->getClassKey() != 'd3totplogin' ? $this->getParent()->getClassKey() : 'start'
|
||||
);
|
||||
|
||||
$this->d3TotpGetSession()->setVariable(d3totp::TOTP_SESSION_CURRENTUSER, $oUser->getId());
|
||||
$this->d3TotpGetSession()->setVariable(
|
||||
$this->d3GetSession()->setVariable(d3totp::TOTP_SESSION_CURRENTUSER, $oUser->getId());
|
||||
$this->d3GetSession()->setVariable(
|
||||
d3totp::TOTP_SESSION_NAVFORMPARAMS,
|
||||
$this->getParent()->getViewConfig()->getNavFormParams()
|
||||
);
|
||||
@ -58,9 +61,11 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
||||
$oUser->logout();
|
||||
|
||||
$sUrl = Registry::getConfig()->getShopHomeUrl() . 'cl=d3totplogin';
|
||||
$this->d3TotpGetUtils()->redirect($sUrl, false);
|
||||
$this->d3GetUtils()->redirect($sUrl, false);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::_afterLogin($oUser);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,7 +80,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
||||
* @throws DBALException
|
||||
* @throws DatabaseConnectionException
|
||||
*/
|
||||
public function d3TotpCheckTotpLogin()
|
||||
public function checkTotplogin()
|
||||
{
|
||||
$sTotp = Registry::getRequest()->getRequestEscapedParameter('d3totp', true);
|
||||
|
||||
@ -87,10 +92,10 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
||||
$totp->loadByUserId($sUserId);
|
||||
|
||||
try {
|
||||
if (!$this->d3TotpIsNoTotpOrNoLogin($totp) && $this->d3TotpHasValidTotp($sTotp, $totp)) {
|
||||
if (!$this->isNoTotpOrNoLogin($totp) && $this->hasValidTotp($sTotp, $totp)) {
|
||||
// relogin, don't extract from this try block
|
||||
$this->d3TotpGetSession()->setVariable(d3totp::TOTP_SESSION_VARNAME, $sTotp);
|
||||
$this->d3TotpGetSession()->setVariable('usr', $oUser->getId());
|
||||
$this->d3GetSession()->setVariable(d3totp::TOTP_SESSION_VARNAME, $sTotp);
|
||||
$this->d3GetSession()->setVariable('usr', $oUser->getId());
|
||||
$this->setUser(null);
|
||||
$this->setLoginStatus(USER_LOGIN_SUCCESS);
|
||||
$this->_afterLogin($oUser);
|
||||
@ -100,7 +105,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
||||
return false;
|
||||
}
|
||||
} catch (d3totp_wrongOtpException $oEx) {
|
||||
$this->d3TotpGetUtilsView()->addErrorToDisplay($oEx, false, false, "", 'd3totplogin');
|
||||
$this->d3GetUtilsView()->addErrorToDisplay($oEx, false, false, "", 'd3totplogin');
|
||||
}
|
||||
|
||||
return 'd3totplogin';
|
||||
@ -109,7 +114,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
||||
/**
|
||||
* @return UtilsView
|
||||
*/
|
||||
public function d3TotpGetUtilsView(): UtilsView
|
||||
public function d3GetUtilsView()
|
||||
{
|
||||
return Registry::getUtilsView();
|
||||
}
|
||||
@ -117,12 +122,12 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
||||
/**
|
||||
* @return Utils
|
||||
*/
|
||||
public function d3TotpGetUtils()
|
||||
public function d3GetUtils()
|
||||
{
|
||||
return Registry::getUtils();
|
||||
}
|
||||
|
||||
public function d3TotpCancelTotpLogin()
|
||||
public function cancelTotpLogin()
|
||||
{
|
||||
$this->d3TotpClearSessionVariables();
|
||||
|
||||
@ -133,7 +138,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
||||
* @param d3totp $totp
|
||||
* @return bool
|
||||
*/
|
||||
public function d3TotpIsNoTotpOrNoLogin($totp)
|
||||
public function isNoTotpOrNoLogin($totp)
|
||||
{
|
||||
return false == Registry::getSession()->getVariable(d3totp::TOTP_SESSION_CURRENTUSER)
|
||||
|| false == $totp->isActive();
|
||||
@ -146,7 +151,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
||||
* @throws DatabaseConnectionException
|
||||
* @throws d3totp_wrongOtpException
|
||||
*/
|
||||
public function d3TotpHasValidTotp($sTotp, $totp)
|
||||
public function hasValidTotp($sTotp, $totp)
|
||||
{
|
||||
return Registry::getSession()->getVariable(d3totp::TOTP_SESSION_VARNAME) ||
|
||||
(
|
||||
@ -156,15 +161,15 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
||||
|
||||
public function d3TotpClearSessionVariables()
|
||||
{
|
||||
$this->d3TotpGetSession()->deleteVariable(d3totp::TOTP_SESSION_CURRENTCLASS);
|
||||
$this->d3TotpGetSession()->deleteVariable(d3totp::TOTP_SESSION_CURRENTUSER);
|
||||
$this->d3TotpGetSession()->deleteVariable(d3totp::TOTP_SESSION_NAVFORMPARAMS);
|
||||
$this->d3GetSession()->deleteVariable(d3totp::TOTP_SESSION_CURRENTCLASS);
|
||||
$this->d3GetSession()->deleteVariable(d3totp::TOTP_SESSION_CURRENTUSER);
|
||||
$this->d3GetSession()->deleteVariable(d3totp::TOTP_SESSION_NAVFORMPARAMS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Session
|
||||
*/
|
||||
public function d3TotpGetSession(): Session
|
||||
public function d3GetSession()
|
||||
{
|
||||
return Registry::getSession();
|
||||
}
|
||||
|
@ -163,14 +163,14 @@ class d3_totp_LoginController extends d3_totp_LoginController_parent
|
||||
|
||||
public function d3CancelLogin()
|
||||
{
|
||||
$oUser = $this->d3GetUserObject();
|
||||
$oUser = $this->d3TotpGetUserObject();
|
||||
$oUser->logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function d3GetUserObject()
|
||||
public function d3TotpGetUserObject()
|
||||
{
|
||||
return oxNew(User::class);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ trait d3_totp_getUserTrait
|
||||
$totp->loadByUserId($oUser->getId());
|
||||
|
||||
if ($totp->isActive()
|
||||
&& !$this->d3GetSessionObject()->getVariable(d3totp::TOTP_SESSION_VARNAME)
|
||||
&& !$this->d3TotpGetSessionObject()->getVariable(d3totp::TOTP_SESSION_VARNAME)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@ -56,7 +56,7 @@ trait d3_totp_getUserTrait
|
||||
/**
|
||||
* @return Session
|
||||
*/
|
||||
public function d3GetSessionObject()
|
||||
public function d3TotpGetSessionObject()
|
||||
{
|
||||
return Registry::getSession();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class d3_totp_user extends d3_totp_user_parent
|
||||
{
|
||||
$return = parent::logout();
|
||||
|
||||
$this->d3TotpGetSession()->deleteVariable(d3totp::TOTP_SESSION_VARNAME);
|
||||
$this->d3GetSession()->deleteVariable(d3totp::TOTP_SESSION_VARNAME);
|
||||
|
||||
return $return;
|
||||
}
|
||||
@ -41,7 +41,7 @@ class d3_totp_user extends d3_totp_user_parent
|
||||
/**
|
||||
* @return Session
|
||||
*/
|
||||
public function d3TotpGetSession()
|
||||
public function d3GetSession()
|
||||
{
|
||||
return Registry::getSession();
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ class d3_totp_utils extends d3_totp_utils_parent
|
||||
$blAuth = parent::checkAccessRights();
|
||||
|
||||
$blAuth = $this->d3AuthHook($blAuth);
|
||||
$userID = $this->d3GetSessionObject()->getVariable("auth");
|
||||
$totpAuth = (bool) $this->d3GetSessionObject()->getVariable(d3totp::TOTP_SESSION_VARNAME);
|
||||
$userID = $this->d3TotpGetSessionObject()->getVariable("auth");
|
||||
$totpAuth = (bool) $this->d3TotpGetSessionObject()->getVariable(d3totp::TOTP_SESSION_VARNAME);
|
||||
/** @var d3totp $totp */
|
||||
$totp = $this->d3GetTotpObject();
|
||||
$totp->loadByUserId($userID);
|
||||
@ -70,7 +70,7 @@ class d3_totp_utils extends d3_totp_utils_parent
|
||||
/**
|
||||
* @return Session
|
||||
*/
|
||||
public function d3GetSessionObject()
|
||||
public function d3TotpGetSessionObject()
|
||||
{
|
||||
return Registry::getSession();
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class d3force_2faTest extends d3user_totpTest
|
||||
* @test
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Application\Controller\Admin\d3force_2fa::d3GetSessionObject
|
||||
* @covers \D3\Totp\Application\Controller\Admin\d3force_2fa::d3TotpGetSessionObject
|
||||
*/
|
||||
public function testD3GetSessionObject()
|
||||
{
|
||||
@ -100,7 +100,7 @@ class d3force_2faTest extends d3user_totpTest
|
||||
Session::class,
|
||||
$this->callMethod(
|
||||
$this->_oController,
|
||||
'd3GetSessionObject'
|
||||
'd3TotpGetSessionObject'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -109,9 +109,9 @@ class d3backupcodeTest extends d3TotpUnitTestCase
|
||||
|
||||
/** @var d3backupcode|MockObject $oModelMock */
|
||||
$oModelMock = $this->getMockBuilder(d3backupcode::class)
|
||||
->onlyMethods(['d3GetUserObject'])
|
||||
->onlyMethods(['d3TotpGetUserObject'])
|
||||
->getMock();
|
||||
$oModelMock->method('d3GetUserObject')->willReturn($oUserMock);
|
||||
$oModelMock->method('d3TotpGetUserObject')->willReturn($oUserMock);
|
||||
|
||||
$this->_oModel = $oModelMock;
|
||||
|
||||
@ -169,13 +169,13 @@ class d3backupcodeTest extends d3TotpUnitTestCase
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Application\Model\d3backupcode::d3GetUserObject
|
||||
* @covers \D3\Totp\Application\Model\d3backupcode::d3TotpGetUserObject
|
||||
*/
|
||||
public function d3getUserObjectReturnsRightInstance()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
User::class,
|
||||
$this->callMethod($this->_oModel, 'd3GetUserObject')
|
||||
$this->callMethod($this->_oModel, 'd3TotpGetUserObject')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ use D3\Totp\Application\Model\d3totp;
|
||||
use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException;
|
||||
use D3\Totp\Modules\Application\Component\d3_totp_UserComponent;
|
||||
use D3\Totp\tests\unit\d3TotpUnitTestCase;
|
||||
use InvalidArgumentException;
|
||||
use OxidEsales\Eshop\Application\Component\UserComponent;
|
||||
use OxidEsales\Eshop\Application\Model\User;
|
||||
use OxidEsales\Eshop\Core\Controller\BaseController;
|
||||
@ -54,9 +55,9 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::login
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::_afterLogin
|
||||
*/
|
||||
public function loginFailsIfNoUserLoggedIn()
|
||||
public function afterLoginFailsIfNoUserLoggedIn()
|
||||
{
|
||||
$oUser = false;
|
||||
|
||||
@ -82,31 +83,29 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var UserComponent|MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMockBuilder(UserComponent::class)
|
||||
->onlyMethods([
|
||||
'getUser',
|
||||
'd3GetTotpObject',
|
||||
'd3TotpGetSession',
|
||||
'd3TotpGetUtils',
|
||||
'd3GetSession',
|
||||
'd3GetUtils',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('getUser')->willReturn($oUser);
|
||||
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3TotpGetUtils')->willReturn($oUtilsMock);
|
||||
|
||||
$_GET['lgn_usr'] = 'username';
|
||||
$oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3GetUtils')->willReturn($oUtilsMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
$this->callMethod($this->_oController, 'login');
|
||||
$this->expectException( InvalidArgumentException::class);
|
||||
|
||||
$this->callMethod($this->_oController, '_afterLogin', [$oUser]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::login
|
||||
* @dataProvider loginFailTotpNotActiveOrAlreadyCheckedDataProvider
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::_afterLogin
|
||||
* @dataProvider afterLoginFailTotpNotActiveOrAlreadyCheckedDataProvider
|
||||
*/
|
||||
public function loginFailTotpNotActiveOrAlreadyChecked($isActive, $checked)
|
||||
public function afterLoginFailTotpNotActiveOrAlreadyChecked($isActive, $checked)
|
||||
{
|
||||
/** @var User|MockObject $oUserMock */
|
||||
$oUserMock = $this->getMockBuilder(User::class)
|
||||
@ -145,28 +144,24 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var UserComponent|MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMockBuilder(UserComponent::class)
|
||||
->onlyMethods([
|
||||
'getUser',
|
||||
'd3GetTotpObject',
|
||||
'd3TotpGetSession',
|
||||
'd3TotpGetUtils',
|
||||
'd3GetSession',
|
||||
'd3GetUtils',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('getUser')->willReturn($oUserMock);
|
||||
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3TotpGetUtils')->willReturn($oUtilsMock);
|
||||
|
||||
$_GET['lgn_usr'] = 'username';
|
||||
$oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3GetUtils')->willReturn($oUtilsMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
$this->callMethod($this->_oController, 'login');
|
||||
$this->callMethod($this->_oController, '_afterLogin', [$oUserMock]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function loginFailTotpNotActiveOrAlreadyCheckedDataProvider(): array
|
||||
public function afterLoginFailTotpNotActiveOrAlreadyCheckedDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'TOTP not active, not checked' => [false, null],
|
||||
@ -178,9 +173,9 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::login
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::_afterLogin
|
||||
*/
|
||||
public function loginPass()
|
||||
public function afterLoginPass()
|
||||
{
|
||||
/** @var User|MockObject $oUserMock */
|
||||
$oUserMock = $this->getMockBuilder(User::class)
|
||||
@ -225,24 +220,20 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var UserComponent|MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMockBuilder(UserComponent::class)
|
||||
->onlyMethods([
|
||||
'getUser',
|
||||
'd3GetTotpObject',
|
||||
'd3TotpGetSession',
|
||||
'd3TotpGetUtils',
|
||||
'd3GetSession',
|
||||
'd3GetUtils',
|
||||
'getParent'
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('getUser')->willReturn($oUserMock);
|
||||
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
$oControllerMock->method('getParent')->willReturn($oParentMock);
|
||||
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3TotpGetUtils')->willReturn($oUtilsMock);
|
||||
|
||||
$_GET['lgn_usr'] = 'username';
|
||||
$oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3GetUtils')->willReturn($oUtilsMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
$this->callMethod($this->_oController, 'login');
|
||||
$this->callMethod($this->_oController, '_afterLogin', [$oUserMock]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -261,7 +252,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpCheckTotpLogin
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::checkTotplogin
|
||||
*/
|
||||
public function checkTotploginNoTotpLogin()
|
||||
{
|
||||
@ -281,29 +272,29 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var UserComponent|MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMockBuilder(UserComponent::class)
|
||||
->onlyMethods([
|
||||
'd3TotpIsNoTotpOrNoLogin',
|
||||
'd3TotpHasValidTotp',
|
||||
'isNoTotpOrNoLogin',
|
||||
'hasValidTotp',
|
||||
'd3GetTotpObject',
|
||||
'd3TotpGetSession',
|
||||
'd3GetSession',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('d3TotpIsNoTotpOrNoLogin')->willReturn(true);
|
||||
$oControllerMock->expects($this->never())->method('d3TotpHasValidTotp')->willReturn(false);
|
||||
$oControllerMock->method('isNoTotpOrNoLogin')->willReturn(true);
|
||||
$oControllerMock->expects($this->never())->method('hasValidTotp')->willReturn(false);
|
||||
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
$this->assertSame(
|
||||
'd3totplogin',
|
||||
$this->callMethod($this->_oController, 'd3TotpCheckTotpLogin')
|
||||
$this->callMethod($this->_oController, 'checkTotplogin')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpCheckTotpLogin
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::checkTotplogin
|
||||
*/
|
||||
public function checkTotploginUnvalidTotp()
|
||||
{
|
||||
@ -334,31 +325,31 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var UserComponent|MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMockBuilder(UserComponent::class)
|
||||
->onlyMethods([
|
||||
'd3TotpIsNoTotpOrNoLogin',
|
||||
'd3TotpHasValidTotp',
|
||||
'd3TotpGetUtilsView',
|
||||
'isNoTotpOrNoLogin',
|
||||
'hasValidTotp',
|
||||
'd3GetUtilsView',
|
||||
'd3GetTotpObject',
|
||||
'd3TotpGetSession',
|
||||
'd3GetSession',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('d3TotpIsNoTotpOrNoLogin')->willReturn(false);
|
||||
$oControllerMock->expects($this->once())->method('d3TotpHasValidTotp')->willThrowException($oTotpExceptionMock);
|
||||
$oControllerMock->method('d3TotpGetUtilsView')->willReturn($oUtilsViewMock);
|
||||
$oControllerMock->method('isNoTotpOrNoLogin')->willReturn(false);
|
||||
$oControllerMock->expects($this->once())->method('hasValidTotp')->willThrowException($oTotpExceptionMock);
|
||||
$oControllerMock->method('d3GetUtilsView')->willReturn($oUtilsViewMock);
|
||||
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
$this->assertSame(
|
||||
'd3totplogin',
|
||||
$this->callMethod($this->_oController, 'd3TotpCheckTotpLogin')
|
||||
$this->callMethod($this->_oController, 'checkTotplogin')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpCheckTotpLogin
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::checkTotplogin
|
||||
*/
|
||||
public function checkTotploginValidTotp()
|
||||
{
|
||||
@ -384,19 +375,19 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/** @var UserComponent|MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMockBuilder(UserComponent::class)
|
||||
->onlyMethods([
|
||||
'd3TotpIsNoTotpOrNoLogin',
|
||||
'd3TotpHasValidTotp',
|
||||
'd3TotpGetUtilsView',
|
||||
'isNoTotpOrNoLogin',
|
||||
'hasValidTotp',
|
||||
'd3GetUtilsView',
|
||||
'd3GetTotpObject',
|
||||
'd3TotpGetSession',
|
||||
'd3GetSession',
|
||||
'setLoginStatus'
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('d3TotpIsNoTotpOrNoLogin')->willReturn(false);
|
||||
$oControllerMock->expects($this->once())->method('d3TotpHasValidTotp')->willReturn(true);
|
||||
$oControllerMock->method('d3TotpGetUtilsView')->willReturn($oUtilsViewMock);
|
||||
$oControllerMock->method('isNoTotpOrNoLogin')->willReturn(false);
|
||||
$oControllerMock->expects($this->once())->method('hasValidTotp')->willReturn(true);
|
||||
$oControllerMock->method('d3GetUtilsView')->willReturn($oUtilsViewMock);
|
||||
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
|
||||
$oControllerMock->expects($this->once())->method('setLoginStatus')->with(
|
||||
$this->identicalTo(USER_LOGIN_SUCCESS)
|
||||
);
|
||||
@ -404,27 +395,27 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
$this->assertFalse(
|
||||
$this->callMethod($this->_oController, 'd3TotpCheckTotpLogin')
|
||||
$this->callMethod($this->_oController, 'checkTotplogin')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpGetUtilsView
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3GetUtilsView
|
||||
*/
|
||||
public function d3GetUtilsViewReturnsRightInstance()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
UtilsView::class,
|
||||
$this->callMethod($this->_oController, 'd3TotpGetUtilsView')
|
||||
$this->callMethod($this->_oController, 'd3GetUtilsView')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpCancelTotpLogin
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::cancelTotpLogin
|
||||
*/
|
||||
public function canCancelTotpLogin()
|
||||
{
|
||||
@ -436,13 +427,13 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
$this->callMethod($this->_oController, 'd3TotpCancelTotpLogin');
|
||||
$this->callMethod($this->_oController, 'cancelTotpLogin');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpIsNoTotpOrNoLogin
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::isNoTotpOrNoLogin
|
||||
*/
|
||||
public function isNoTotpOrNoLoginTrueNoSessionVariable()
|
||||
{
|
||||
@ -456,14 +447,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
$oTotpMock->method('isActive')->willReturn(true);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->callMethod($this->_oController, 'd3TotpIsNoTotpOrNoLogin', [$oTotpMock])
|
||||
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', [$oTotpMock])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpIsNoTotpOrNoLogin
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::isNoTotpOrNoLogin
|
||||
*/
|
||||
public function isNoTotpOrNoLoginTrueTotpNotActive()
|
||||
{
|
||||
@ -477,14 +468,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
$oTotpMock->method('isActive')->willReturn(false);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->callMethod($this->_oController, 'd3TotpIsNoTotpOrNoLogin', [$oTotpMock])
|
||||
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', [$oTotpMock])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpIsNoTotpOrNoLogin
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::isNoTotpOrNoLogin
|
||||
*/
|
||||
public function isNoTotpOrNoLoginFalse()
|
||||
{
|
||||
@ -498,14 +489,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
$oTotpMock->method('isActive')->willReturn(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$this->callMethod($this->_oController, 'd3TotpIsNoTotpOrNoLogin', [$oTotpMock])
|
||||
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', [$oTotpMock])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpHasValidTotp
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::hasValidTotp
|
||||
*/
|
||||
public function hasValidTotpTrueSessionVarname()
|
||||
{
|
||||
@ -519,14 +510,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
$oTotpMock->method('verify')->willReturn(false);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', ['123456', $oTotpMock])
|
||||
$this->callMethod($this->_oController, 'hasValidTotp', ['123456', $oTotpMock])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpHasValidTotp
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::hasValidTotp
|
||||
*/
|
||||
public function hasValidTotpTrueValidTotp()
|
||||
{
|
||||
@ -540,14 +531,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
$oTotpMock->method('verify')->willReturn(true);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', ['123456', $oTotpMock])
|
||||
$this->callMethod($this->_oController, 'hasValidTotp', ['123456', $oTotpMock])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpHasValidTotp
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::hasValidTotp
|
||||
*/
|
||||
public function hasValidTotpFalseMissingTotp()
|
||||
{
|
||||
@ -561,14 +552,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
$oTotpMock->method('verify')->willReturn(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', [null, $oTotpMock])
|
||||
$this->callMethod($this->_oController, 'hasValidTotp', [null, $oTotpMock])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpHasValidTotp
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::hasValidTotp
|
||||
*/
|
||||
public function hasValidTotpFalseUnverifiedTotp()
|
||||
{
|
||||
@ -582,7 +573,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
$oTotpMock->method('verify')->willReturn(false);
|
||||
|
||||
$this->assertFalse(
|
||||
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', ['123456', $oTotpMock])
|
||||
$this->callMethod($this->_oController, 'hasValidTotp', ['123456', $oTotpMock])
|
||||
);
|
||||
}
|
||||
|
||||
@ -601,9 +592,9 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
|
||||
/** @var UserComponent|MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMockBuilder(UserComponent::class)
|
||||
->onlyMethods(['d3TotpGetSession'])
|
||||
->onlyMethods(['d3GetSession'])
|
||||
->getMock();
|
||||
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
@ -613,13 +604,13 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpGetSession
|
||||
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3GetSession
|
||||
*/
|
||||
public function d3GetSessionReturnsRightInstance()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
Session::class,
|
||||
$this->callMethod($this->_oController, 'd3TotpGetSession')
|
||||
$this->callMethod($this->_oController, 'd3GetSession')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -691,9 +691,9 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
|
||||
/** @var d3_totp_LoginController|MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMockBuilder(d3_totp_LoginController::class)
|
||||
->onlyMethods(['d3GetUserObject'])
|
||||
->onlyMethods(['d3TotpGetUserObject'])
|
||||
->getMock();
|
||||
$oControllerMock->method('d3GetUserObject')->willReturn($oUserMock);
|
||||
$oControllerMock->method('d3TotpGetUserObject')->willReturn($oUserMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
@ -703,13 +703,13 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Controller\Admin\d3_totp_LoginController::d3GetUserObject
|
||||
* @covers \D3\Totp\Modules\Application\Controller\Admin\d3_totp_LoginController::d3TotpGetUserObject
|
||||
*/
|
||||
public function d3GetUserObjectReturnsRightObject()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
User::class,
|
||||
$this->callMethod($this->_oController, 'd3GetUserObject')
|
||||
$this->callMethod($this->_oController, 'd3TotpGetUserObject')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -80,11 +80,11 @@ trait d3_totp_getUserTestTrait
|
||||
$oControllerMock = $this->getMockBuilder($this->sControllerClass)
|
||||
->onlyMethods([
|
||||
'd3GetTotpObject',
|
||||
'd3GetSessionObject',
|
||||
'd3TotpGetSessionObject',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
$oControllerMock->method('d3GetSessionObject')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3TotpGetSessionObject')->willReturn($oSessionMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
@ -131,11 +131,11 @@ trait d3_totp_getUserTestTrait
|
||||
$oControllerMock = $this->getMockBuilder($this->sControllerClass)
|
||||
->onlyMethods([
|
||||
'd3GetTotpObject',
|
||||
'd3GetSessionObject',
|
||||
'd3TotpGetSessionObject',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
$oControllerMock->method('d3GetSessionObject')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3TotpGetSessionObject')->willReturn($oSessionMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
@ -183,11 +183,11 @@ trait d3_totp_getUserTestTrait
|
||||
$oControllerMock = $this->getMockBuilder($this->sControllerClass)
|
||||
->onlyMethods([
|
||||
'd3GetTotpObject',
|
||||
'd3GetSessionObject',
|
||||
'd3TotpGetSessionObject',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
$oControllerMock->method('d3GetSessionObject')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3TotpGetSessionObject')->willReturn($oSessionMock);
|
||||
|
||||
$this->_oController = $oControllerMock;
|
||||
|
||||
@ -216,9 +216,9 @@ trait d3_totp_getUserTestTrait
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Controller\d3_totp_OrderController::d3GetSessionObject
|
||||
* @covers \D3\Totp\Modules\Application\Controller\d3_totp_PaymentController::d3GetSessionObject
|
||||
* @covers \D3\Totp\Modules\Application\Controller\d3_totp_UserController::d3GetSessionObject
|
||||
* @covers \D3\Totp\Modules\Application\Controller\d3_totp_OrderController::d3TotpGetSessionObject
|
||||
* @covers \D3\Totp\Modules\Application\Controller\d3_totp_PaymentController::d3TotpGetSessionObject
|
||||
* @covers \D3\Totp\Modules\Application\Controller\d3_totp_UserController::d3TotpGetSessionObject
|
||||
*/
|
||||
public function d3GetSessionObjectReturnsRightObject()
|
||||
{
|
||||
@ -226,7 +226,7 @@ trait d3_totp_getUserTestTrait
|
||||
Session::class,
|
||||
$this->callMethod(
|
||||
$this->_oController,
|
||||
'd3GetSessionObject'
|
||||
'd3TotpGetSessionObject'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ class d3_totp_userTest extends d3TotpUnitTestCase
|
||||
|
||||
/** @var d3_totp_user|MockObject $oModelMock */
|
||||
$oModelMock = $this->getMockBuilder(User::class)
|
||||
->onlyMethods(['d3TotpGetSession'])
|
||||
->onlyMethods(['d3GetSession'])
|
||||
->getMock();
|
||||
$oModelMock->method('d3TotpGetSession')->willReturn($oSessionMock);
|
||||
$oModelMock->method('d3GetSession')->willReturn($oSessionMock);
|
||||
|
||||
$this->_oModel = $oModelMock;
|
||||
|
||||
@ -88,13 +88,13 @@ class d3_totp_userTest extends d3TotpUnitTestCase
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Application\Model\d3_totp_user::d3TotpGetSession
|
||||
* @covers \D3\Totp\Modules\Application\Model\d3_totp_user::d3GetSession
|
||||
*/
|
||||
public function d3GetSessionReturnsRightInstance()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
Session::class,
|
||||
$this->callMethod($this->_oModel, 'd3TotpGetSession')
|
||||
$this->callMethod($this->_oModel, 'd3GetSession')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -182,13 +182,13 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
|
||||
$oCoreMock = $this->getMockBuilder(Utils::class)
|
||||
->onlyMethods([
|
||||
'd3GetTotpObject',
|
||||
'd3GetSessionObject',
|
||||
'd3TotpGetSessionObject',
|
||||
'fetchRightsForUser',
|
||||
'redirect',
|
||||
])
|
||||
->getMock();
|
||||
$oCoreMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
$oCoreMock->method('d3GetSessionObject')->willReturn($oSessionMock);
|
||||
$oCoreMock->method('d3TotpGetSessionObject')->willReturn($oSessionMock);
|
||||
$oCoreMock->method('fetchRightsForUser')->willReturn('malladmin');
|
||||
$oCoreMock->expects($this->never())->method('redirect')->willReturn(true);
|
||||
|
||||
@ -235,13 +235,13 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
|
||||
$oCoreMock = $this->getMockBuilder(Utils::class)
|
||||
->onlyMethods([
|
||||
'd3GetTotpObject',
|
||||
'd3GetSessionObject',
|
||||
'd3TotpGetSessionObject',
|
||||
'fetchRightsForUser',
|
||||
'redirect',
|
||||
])
|
||||
->getMock();
|
||||
$oCoreMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
$oCoreMock->method('d3GetSessionObject')->willReturn($oSessionMock);
|
||||
$oCoreMock->method('d3TotpGetSessionObject')->willReturn($oSessionMock);
|
||||
$oCoreMock->method('fetchRightsForUser')->willReturn('malladmin');
|
||||
$oCoreMock->expects($this->once())->method('redirect')->willReturn(true);
|
||||
|
||||
@ -253,13 +253,13 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\Totp\Modules\Core\d3_totp_utils::d3GetSessionObject
|
||||
* @covers \D3\Totp\Modules\Core\d3_totp_utils::d3TotpGetSessionObject
|
||||
*/
|
||||
public function d3GetSessionObjectReturnsRightInstance()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
Session::class,
|
||||
$this->callMethod($this->_oCoreClass, 'd3GetSessionObject')
|
||||
$this->callMethod($this->_oCoreClass, 'd3TotpGetSessionObject')
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user