File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
tests/Unit/Http/Controllers/Base Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,36 @@ public function testGenerateTotpController()
9898 $ this ->assertResponseJsonEquals (['qrImage ' => 'qrCodeImage ' ], $ response );
9999 }
100100
101+ /**
102+ * Test TOTP setting controller when no exception is thrown by the service.
103+ */
104+ public function testSetTotpControllerSuccess ()
105+ {
106+ $ model = $ this ->generateRequestUserModel ();
107+
108+ $ this ->request ->shouldReceive ('input ' )->with ('token ' )->once ()->andReturn ('testToken ' );
109+ $ this ->toggleTwoFactorService ->shouldReceive ('handle ' )->with ($ model , 'testToken ' )->once ();
110+
111+ $ response = $ this ->getController ()->setTotp ($ this ->request );
112+ $ this ->assertIsResponse ($ response );
113+ $ this ->assertSame ('true ' , $ response ->getContent ());
114+ }
115+
116+ /**
117+ * Test TOTP setting controller when an exception is thrown by the service.
118+ */
119+ public function testSetTotpControllerWhenExceptionIsThrown ()
120+ {
121+ $ model = $ this ->generateRequestUserModel ();
122+
123+ $ this ->request ->shouldReceive ('input ' )->with ('token ' )->once ()->andReturn ('testToken ' );
124+ $ this ->toggleTwoFactorService ->shouldReceive ('handle ' )->with ($ model , 'testToken ' )->once ()->andThrow (new TwoFactorAuthenticationTokenInvalid ());
125+
126+ $ response = $ this ->getController ()->setTotp ($ this ->request );
127+ $ this ->assertIsResponse ($ response );
128+ $ this ->assertSame ('false ' , $ response ->getContent ());
129+ }
130+
101131 /**
102132 * Test the disable totp controller when no exception is thrown by the service.
103133 */
You can’t perform that action at this time.
0 commit comments