File tree Expand file tree Collapse file tree
src/Authentication/TwoFactorAuth/Settings
Unit/Authentication/TwoFactorAuth/Settings Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * Copyright © OXID eSales AG. All rights reserved.
5+ * See LICENSE file for license details.
6+ */
7+
8+ declare (strict_types=1 );
9+
10+ namespace OxidEsales \SecurityModule \Authentication \TwoFactorAuth \Settings ;
11+
12+ use OxidEsales \Eshop \Core \Config ;
13+
14+ class TwoFASettings implements TwoFASettingsInterface
15+ {
16+ public function __construct (
17+ private Config $ config ,
18+ ) {
19+ }
20+
21+ public function getVerificationUrl (): string
22+ {
23+ return $ this ->config ->getShopHomeUrl () . 'cl=twofactorauth ' ;
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * Copyright © OXID eSales AG. All rights reserved.
5+ * See LICENSE file for license details.
6+ */
7+
8+ declare (strict_types=1 );
9+
10+ namespace OxidEsales \SecurityModule \Authentication \TwoFactorAuth \Settings ;
11+
12+ interface TwoFASettingsInterface
13+ {
14+ public function getVerificationUrl (): string ;
15+ }
Original file line number Diff line number Diff line change 1+ services :
2+ _defaults :
3+ autowire : true
4+ public : false
5+
6+ OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFASettingsInterface :
7+ class : OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFASettings
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ public static function serviceAvailabilityDataProvider(): array
4747 [\OxidEsales \SecurityModule \Authentication \TwoFactorAuth \OTP \Infrastructure \Repository \OtpChallengeStateRepositoryInterface::class],
4848 [\OxidEsales \SecurityModule \Authentication \TwoFactorAuth \OTP \Service \OtpCodeGeneratorServiceInterface::class],
4949 [\OxidEsales \SecurityModule \Authentication \TwoFactorAuth \OTP \Service \OtpCodeHasherServiceInterface::class],
50+ [\OxidEsales \SecurityModule \Authentication \TwoFactorAuth \Settings \TwoFASettingsInterface::class],
5051 [\OxidEsales \SecurityModule \Authentication \TwoFactorAuth \OTP \Notifier \OtpNotifierInterface::class],
5152 [\OxidEsales \SecurityModule \Authentication \TwoFactorAuth \OTP \Notifier \Factory \OtpNotifierFactoryInterface::class],
5253 ];
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * Copyright © OXID eSales AG. All rights reserved.
5+ * See LICENSE file for license details.
6+ */
7+
8+ declare (strict_types=1 );
9+
10+ namespace OxidEsales \SecurityModule \Tests \Unit \Authentication \TwoFactorAuth \Settings ;
11+
12+ use OxidEsales \Eshop \Core \Config ;
13+ use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \Settings \TwoFASettings ;
14+ use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \Settings \TwoFASettingsInterface ;
15+ use PHPUnit \Framework \Attributes \Test ;
16+ use PHPUnit \Framework \TestCase ;
17+
18+ class TwoFASettingsTest extends TestCase
19+ {
20+ #[Test]
21+ public function getVerificationUrlReturnsVerificationControllerUrl (): void
22+ {
23+ $ configStub = $ this ->createStub (Config::class);
24+ $ configStub ->method ('getShopHomeUrl ' )->willReturn ($ homeUrl = uniqid ());
25+
26+ $ sut = $ this ->getSut (config: $ configStub );
27+
28+ $ this ->assertSame ($ homeUrl . 'cl=twofactorauth ' , $ sut ->getVerificationUrl ());
29+ }
30+
31+ #[Test]
32+ public function implementsInterface (): void
33+ {
34+ $ this ->assertInstanceOf (TwoFASettingsInterface::class, $ this ->getSut ());
35+ }
36+
37+ private function getSut (Config $ config = null ): TwoFASettings
38+ {
39+ return new TwoFASettings (
40+ config: $ config ?? $ this ->createStub (Config::class),
41+ );
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments