1010namespace OxidEsales \SecurityModule \Tests \Unit \Authentication \TwoFactorAuth \OTP ;
1111
1212use DateTimeImmutable ;
13- use OxidEsales \Eshop \Core \Utils ;
1413use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \OTP \Notifier \Factory \OtpNotifierFactoryInterface ;
1514use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \OTP \Notifier \OtpNotifierInterface ;
1615use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \OTP \OtpFacade ;
1716use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \OTP \Service \OtpChallengeStateServiceInterface ;
1817use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \OTP \Service \OtpCodeGeneratorServiceInterface ;
1918use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \OTP \Service \OtpCodeValidatorServiceInterface ;
20- use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \Settings \TwoFASettingsInterface ;
2119use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \OTP \DTO \OtpChallengeStateInterface ;
22- use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \Service \ TwoFAServiceInterface ;
20+ use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \Exception \ InvalidCodeException ;
2321use PHPUnit \Framework \Attributes \Test ;
2422use PHPUnit \Framework \TestCase ;
2523
@@ -170,20 +168,10 @@ public function triggerChallengeGeneratesCodeCreatesStateAndNotifies(): void
170168 $ notifierFactoryStub = $ this ->createStub (OtpNotifierFactoryInterface::class);
171169 $ notifierFactoryStub ->method ('create ' )->willReturn ($ notifierSpy );
172170
173- $ settingsStub = $ this ->createStub (TwoFASettingsInterface::class);
174- $ settingsStub ->method ('getVerificationUrl ' )->willReturn ($ verificationUrl = uniqid ());
175-
176- $ utilsSpy = $ this ->createMock (Utils::class);
177- $ utilsSpy ->expects ($ this ->once ())
178- ->method ('redirect ' )
179- ->with ($ verificationUrl );
180-
181171 $ sut = $ this ->getSut (
182172 stateService: $ stateServiceSpy ,
183173 codeGenerator: $ codeGeneratorStub ,
184174 notifierFactory: $ notifierFactoryStub ,
185- settings: $ settingsStub ,
186- utils: $ utilsSpy ,
187175 );
188176
189177 $ sut ->triggerChallenge (userId: $ userId );
@@ -194,16 +182,12 @@ private function getSut(
194182 OtpCodeValidatorServiceInterface $ codeValidator = null ,
195183 OtpCodeGeneratorServiceInterface $ codeGenerator = null ,
196184 OtpNotifierFactoryInterface $ notifierFactory = null ,
197- TwoFASettingsInterface $ settings = null ,
198- Utils $ utils = null ,
199185 ): OtpFacade {
200186 return new OtpFacade (
201187 stateService: $ stateService ?? $ this ->createStub (OtpChallengeStateServiceInterface::class),
202188 codeValidator: $ codeValidator ?? $ this ->createStub (OtpCodeValidatorServiceInterface::class),
203189 codeGenerator: $ codeGenerator ?? $ this ->createStub (OtpCodeGeneratorServiceInterface::class),
204190 notifierFactory: $ notifierFactory ?? $ this ->createStub (OtpNotifierFactoryInterface::class),
205- settings: $ settings ?? $ this ->createStub (TwoFASettingsInterface::class),
206- utils: $ utils ?? $ this ->createStub (Utils::class),
207191 );
208192 }
209193}
0 commit comments