improve code syntax

Cette révision appartient à :
Daniel Seifert 2022-11-25 20:24:09 +01:00
Parent a9a279a753
révision f14ce58d6e
Signé par: DanielS
ID de la clé GPG: 6A513E13AEE66170
13 fichiers modifiés avec 31 ajouts et 30 suppressions

Voir le fichier

@ -231,4 +231,4 @@ class d3totpadminlogin extends AdminController
{
return oxNew(LoginController::class);
}
}
}

Voir le fichier

@ -143,7 +143,7 @@ class d3totp extends BaseModel
{
if (false == $this->totp) {
$this->totp = TOTP::create($seed ?: $this->getSavedSecret());
$this->totp->setLabel($this->getUser()->getFieldData('oxusername')?: '');
$this->totp->setLabel($this->getUser()->getFieldData('oxusername') ?: '');
$this->totp->setIssuer(Registry::getConfig()->getActiveShop()->getFieldData('oxname'));
}

Voir le fichier

@ -27,4 +27,4 @@ class d3totp_conf
public const SESSION_ADMIN_CURRENTUSER = 'd3Totp_currentUser'; // oxid assigned to user from entered username
public const SESSION_ADMIN_PROFILE = 'd3Totp_currentProfile'; // selected profile
public const SESSION_ADMIN_CHLANGUAGE = 'd3Totp_currentChLanguage'; // selected language
}
}

Voir le fichier

@ -39,7 +39,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
protected function _afterLogin($oUser)
{
if (!$oUser instanceof User) {
throw oxNew( InvalidArgumentException::class, 'user argument must an instance of User class');
throw oxNew(InvalidArgumentException::class, 'user argument must an instance of User class');
}
if ($oUser->getId()) {

Voir le fichier

@ -99,7 +99,7 @@ class d3_totp_LoginController extends d3_totp_LoginController_parent
}
$myUtilsServer->setOxCookie("oxidadminlanguage", $aLanguages[$iLang]->abbr, time() + 31536000, "/");
$this->d3TotpGetLangObject()->setTplLanguage( $iLang);
$this->d3TotpGetLangObject()->setTplLanguage($iLang);
}
/**

Voir le fichier

@ -42,7 +42,8 @@ trait d3_totp_getUserTrait
if ($totp->isActive()
&& !$this->d3TotpGetSessionObject()->getVariable(
isAdmin() ? d3totp_conf::SESSION_ADMIN_AUTH : d3totp_conf::SESSION_AUTH)
isAdmin() ? d3totp_conf::SESSION_ADMIN_AUTH : d3totp_conf::SESSION_AUTH
)
) {
return false;
}

Voir le fichier

@ -97,4 +97,4 @@ class totpSystemEventHandler extends totpSystemEventHandler_parent
{
return oxNew(User::class);
}
}
}

Voir le fichier

@ -69,14 +69,14 @@ $aModule = [
LoginController::class => d3_totp_LoginController::class,
Utils::class => d3_totp_utils::class,
UserComponent::class => d3_totp_UserComponent::class,
SystemEventHandler::class => totpSystemEventHandler::class
SystemEventHandler::class => totpSystemEventHandler::class,
],
'controllers' => [
'd3user_totp' => d3user_totp::class,
'd3force_2fa' => d3force_2fa::class,
'd3totplogin' => d3totplogin::class,
'd3_account_totp' => d3_account_totp::class,
'd3totpadminlogin' => d3totpadminlogin::class
'd3totpadminlogin' => d3totpadminlogin::class,
],
'templates' => [
'd3user_totp.tpl' => 'd3/totp/Application/views/admin/tpl/d3user_totp.tpl',

Voir le fichier

@ -117,11 +117,11 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
/** @var Session|MockObject $oSessionMock */
$oSessionMock = $this->getMockBuilder(Session::class)
->onlyMethods([
'hasVariable'
'hasVariable',
])
->getMock();
$hasVariableMap = [
[d3totp_conf::SESSION_ADMIN_AUTH, $hasAuthAlready]
[d3totp_conf::SESSION_ADMIN_AUTH, $hasAuthAlready],
];
$oSessionMock->method('hasVariable')->willReturnMap($hasVariableMap);
@ -129,7 +129,7 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
$oControllerMock = $this->getMockBuilder(d3totpadminlogin::class)
->onlyMethods([
'd3TotpGetSession',
'd3TotpGetTotpObject'
'd3TotpGetTotpObject',
])
->getMock();
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
@ -173,7 +173,7 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
/** @var Session|MockObject $oSessionMock */
$oSessionMock = $this->getMockBuilder(Session::class)
->onlyMethods([
'hasVariable'
'hasVariable',
])
->getMock();
$hasVariableMap = [
@ -185,7 +185,7 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
/** @var d3totpadminlogin|MockObject $oControllerMock */
$oControllerMock = $this->getMockBuilder(d3totpadminlogin::class)
->onlyMethods([
'd3TotpGetSession'
'd3TotpGetSession',
])
->getMock();
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
@ -244,7 +244,7 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
'isTotpIsNotRequired',
'isTotpLoginNotPossible',
'd3TotpGetUtils',
'd3GetLoginController'
'd3GetLoginController',
])
->getMock();
$oControllerMock->method('isTotpIsNotRequired')->willReturn($totpRequired);
@ -431,7 +431,7 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
'getLogger',
'd3TotpHasValidTotp',
'd3TotpGetSession',
'd3GetLoginController'
'd3GetLoginController',
])
->getMock();
$oControllerMock->method('d3TotpHasValidTotp')
@ -494,7 +494,7 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
'getLogger',
'd3TotpHasValidTotp',
'd3TotpGetSession',
'd3GetLoginController'
'd3GetLoginController',
])
->getMock();
$oControllerMock->method('d3TotpHasValidTotp')->willReturn(true);

Voir le fichier

@ -77,7 +77,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
$oControllerMock->method('d3TotpGetUtils')->willReturn($oUtilsMock);
$this->expectException( InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);
$this->callMethod($oControllerMock, '_afterLogin', [$oUser]);
}
@ -204,7 +204,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
'd3GetTotpObject',
'd3TotpGetSession',
'd3TotpGetUtils',
'getParent'
'getParent',
])
->getMock();
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
@ -358,7 +358,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
'd3TotpGetUtilsView',
'd3GetTotpObject',
'd3TotpGetSession',
'setLoginStatus'
'setLoginStatus',
])
->getMock();
$oControllerMock->method('d3TotpIsNoTotpOrNoLogin')->willReturn(false);

Voir le fichier

@ -165,7 +165,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
return [
'no profile selected' => [null, $this->once(), '', $this->never()],
'valid profile selected' => [2, $this->once(), '2@geh@2', $this->once()],
'invalid profile selected' => [5, $this->never(), false, $this->never()]
'invalid profile selected' => [5, $this->never(), false, $this->never()],
];
}
@ -248,7 +248,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
/** @var d3_totp_LoginController|MockObject $oControllerMock */
$oControllerMock = $this->getMockBuilder(d3_totp_LoginController::class)
->onlyMethods([
'd3TotpGetSession'
'd3TotpGetSession',
])
->getMock();
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
@ -272,8 +272,8 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
{
return [
'totp not active, not logged in'=> [false, false, false],
'totp active, logged in' => [true , true, false],
'totp active, not logged in' => [true , false, true],
'totp active, logged in' => [true, true, false],
'totp active, not logged in' => [true, false, true],
'totp not active, logged in' => [false, true, false],
];
}

Voir le fichier

@ -86,7 +86,7 @@ trait d3_totp_getUserTestTrait
->onlyMethods([
'd3GetTotpObject',
'd3TotpGetSessionObject',
'd3CallMockableParent'
'd3CallMockableParent',
])
->getMock();
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
@ -135,7 +135,7 @@ trait d3_totp_getUserTestTrait
->onlyMethods([
'd3GetTotpObject',
'd3TotpGetSessionObject',
'd3CallMockableParent'
'd3CallMockableParent',
])
->getMock();
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
@ -185,7 +185,7 @@ trait d3_totp_getUserTestTrait
->onlyMethods([
'd3GetTotpObject',
'd3TotpGetSessionObject',
'd3CallMockableParent'
'd3CallMockableParent',
])
->getMock();
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);

Voir le fichier

@ -94,7 +94,7 @@ class totpSystemEventHandlerTest extends UnitTestCase
/** @var totpSystemEventHandler|MockObject $sut */
$sut = $this->getMockBuilder(SystemEventHandler::class)
->onlyMethods(['d3GetTotpObject', 'd3TotpGetSession', 'd3TotpLoginMissing',
'd3TotpGetUserObject', 'getUtilsObject'])
'd3TotpGetUserObject', 'getUtilsObject', ])
->getMock();
$sut->method('d3GetTotpObject')->willReturn($totpMock);
$sut->method('d3TotpGetSession')->willReturn($sessionMock);
@ -115,7 +115,7 @@ class totpSystemEventHandlerTest extends UnitTestCase
{
return [
'no totp missing' => [false, $this->never(), $this->never()],
'totp missing' => [true, $this->once(), $this->once()]
'totp missing' => [true, $this->once(), $this->once()],
];
}
@ -250,4 +250,4 @@ class totpSystemEventHandlerTest extends UnitTestCase
'totp exists' => [true, true, false],
];
}
}
}