Skip to content

Commit b22f1df

Browse files
committed
minor symfony#26113 [SecurityBundle] Backport test (chalasr)
This PR was merged into the 2.7 branch. Discussion ---------- [SecurityBundle] Backport test | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a <!-- - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. - Replace this comment by a description of what your PR is solving. --> Commits ------- d195a6f [SecurityBundle] Backport test
2 parents f7d9701 + d195a6f commit b22f1df

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ public function testHandleWhenUsernameLength($username, $ok)
7777
}
7878

7979
/**
80+
* @dataProvider postOnlyDataProvider
8081
* @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
8182
* @expectedExceptionMessage The key "_username" must be a string, "array" given.
8283
*/
83-
public function testHandleNonStringUsername()
84+
public function testHandleNonStringUsername($postOnly)
8485
{
8586
$request = Request::create('/login_check', 'POST', array('_username' => array()));
8687
$request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock());
87-
8888
$listener = new UsernamePasswordFormAuthenticationListener(
8989
new TokenStorage(),
9090
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(),
@@ -93,14 +93,20 @@ public function testHandleNonStringUsername()
9393
'foo',
9494
new DefaultAuthenticationSuccessHandler($httpUtils),
9595
new DefaultAuthenticationFailureHandler($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $httpUtils),
96-
array('require_previous_session' => false)
96+
array('require_previous_session' => false, 'post_only' => $postOnly)
9797
);
98-
9998
$event = new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);
100-
10199
$listener->handle($event);
102100
}
103101

102+
public function postOnlyDataProvider()
103+
{
104+
return array(
105+
array(true),
106+
array(false),
107+
);
108+
}
109+
104110
public function getUsernameForLength()
105111
{
106112
return array(

0 commit comments

Comments
 (0)