@@ -32,7 +32,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
32
32
*/
33
33
public function testHandleWhenUsernameLength ($ username , $ ok )
34
34
{
35
- $ request = Request::create ('/login_check ' , 'POST ' , ['_username ' => $ username ]);
35
+ $ request = Request::create ('/login_check ' , 'POST ' , ['_username ' => $ username, ' _password ' => ' symfony ' ]);
36
36
$ request ->setSession ($ this ->getMockBuilder ('Symfony\Component\HttpFoundation\Session\SessionInterface ' )->getMock ());
37
37
38
38
$ httpUtils = $ this ->getMockBuilder ('Symfony\Component\Security\Http\HttpUtils ' )->getMock ();
@@ -161,7 +161,31 @@ public function testHandleNonStringUsernameWith__toString($postOnly)
161
161
->method ('__toString ' )
162
162
->willReturn ('someUsername ' );
163
163
164
- $ request = Request::create ('/login_check ' , 'POST ' , ['_username ' => $ usernameClass ]);
164
+ $ request = Request::create ('/login_check ' , 'POST ' , ['_username ' => $ usernameClass , '_password ' => 'symfony ' ]);
165
+ $ request ->setSession ($ this ->getMockBuilder ('Symfony\Component\HttpFoundation\Session\SessionInterface ' )->getMock ());
166
+ $ listener = new UsernamePasswordFormAuthenticationListener (
167
+ new TokenStorage (),
168
+ $ this ->getMockBuilder ('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface ' )->getMock (),
169
+ new SessionAuthenticationStrategy (SessionAuthenticationStrategy::NONE ),
170
+ $ httpUtils = new HttpUtils (),
171
+ 'foo ' ,
172
+ new DefaultAuthenticationSuccessHandler ($ httpUtils ),
173
+ new DefaultAuthenticationFailureHandler ($ this ->getMockBuilder ('Symfony\Component\HttpKernel\HttpKernelInterface ' )->getMock (), $ httpUtils ),
174
+ ['require_previous_session ' => false , 'post_only ' => $ postOnly ]
175
+ );
176
+ $ event = new GetResponseEvent ($ this ->getMockBuilder ('Symfony\Component\HttpKernel\HttpKernelInterface ' )->getMock (), $ request , HttpKernelInterface::MASTER_REQUEST );
177
+ $ listener ->handle ($ event );
178
+ }
179
+
180
+ /**
181
+ * @dataProvider postOnlyDataProvider
182
+ */
183
+ public function testHandleWhenPasswordAreNull ($ postOnly )
184
+ {
185
+ $ this ->expectException ('LogicException ' );
186
+ $ this ->expectExceptionMessage ('The key "_password" cannot be null. ' );
187
+
188
+ $ request = Request::create ('/login_check ' , 'POST ' , ['_username ' => 'symfony ' , 'password ' => 'symfony ' ]);
165
189
$ request ->setSession ($ this ->getMockBuilder ('Symfony\Component\HttpFoundation\Session\SessionInterface ' )->getMock ());
166
190
$ listener = new UsernamePasswordFormAuthenticationListener (
167
191
new TokenStorage (),
0 commit comments