File tree Expand file tree Collapse file tree 2 files changed +11
-17
lines changed
Model/Provider/Engine/DuoSecurity
Test/Integration/Model/Provider/Engine/DuoSecurity Expand file tree Collapse file tree 2 files changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -67,20 +67,15 @@ public function getConfigurationData(string $tfaToken)
6767
6868 /**
6969 * @inheritDoc
70- * @throws \LocalizedException
7170 */
7271 public function activate (string $ tfaToken ): void
7372 {
74- try {
75- $ user = $ this ->userAuthenticator ->authenticateWithTokenAndProvider ($ tfaToken , DuoSecurity::CODE );
76- $ userId = (int )$ user ->getId ();
73+ $ user = $ this ->userAuthenticator ->authenticateWithTokenAndProvider ($ tfaToken , DuoSecurity::CODE );
74+ $ userId = (int )$ user ->getId ();
7775
78- if ($ this ->duo ->assertUserIsValid ($ user ->getUserName ()) == "auth " ) {
79- $ this ->tfa ->getProviderByCode (DuoSecurity::CODE )
80- ->activate ($ userId );
81- }
82- } catch (\Exception $ e ) {
83- throw new \LocalizedException (__ ('Could not activate Duo Security provider. ' ));
76+ if ($ this ->duo ->assertUserIsValid ($ user ->getUserName ()) == "auth " ) {
77+ $ this ->tfa ->getProviderByCode (DuoSecurity::CODE )
78+ ->activate ($ userId );
8479 }
8580 }
8681}
Original file line number Diff line number Diff line change @@ -269,13 +269,12 @@ public function testActivateInvalidDataThrowsException()
269269 $ userId = $ this ->getUserId ();
270270 $ tfat = $ this ->tokenManager ->issueFor ($ userId );
271271
272- $ this ->duo ->method ('assertUserIsValid ' )
273- ->with ($ this ->callback (function ($ username ) use ($ userId ) {
274- // Assuming $username corresponds to a user object or username string.
275- // Replace 'getUserById' with the relevant logic for obtaining the username
276- $ user = $ this ->userFactory ->create ()->load ($ userId );
277- return $ username === $ user ->getUserName ();
278- }))
272+ $ userName = 'adminUser ' ;
273+
274+ $ this ->duo
275+ ->expects ($ this ->once ())
276+ ->method ('assertUserIsValid ' )
277+ ->with ($ userName )
279278 ->willThrowException (new \InvalidArgumentException ('Something ' ));
280279
281280 // Call activate without a signature, as per your updated logic
You can’t perform that action at this time.
0 commit comments