diff options
author | Fabien Potencier <fabien.potencier@gmail.com> | 2015-05-21 06:29:49 +0200 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2015-05-21 06:29:49 +0200 |
commit | b3d032613d74a7d5d7babeee28d9ac8f870ff36c (patch) | |
tree | f640f6ea6fdfd03c692cf500e014e33d6d7d256b /Tests/Http | |
parent | a3fffdc56ce7a29745d3dea4800058de1a4edd84 (diff) | |
parent | fc2175946153bee537787dc1b6d8854c827f5e36 (diff) | |
download | symfony-security-b3d032613d74a7d5d7babeee28d9ac8f870ff36c.zip symfony-security-b3d032613d74a7d5d7babeee28d9ac8f870ff36c.tar.gz symfony-security-b3d032613d74a7d5d7babeee28d9ac8f870ff36c.tar.bz2 |
minor #14670 [Security] TokenBasedRememberMeServices test to show why encoding username is required (MacDada)v2.3.30v2.3.29
This PR was squashed before being merged into the 2.3 branch (closes #14670).
Discussion
----------
[Security] TokenBasedRememberMeServices test to show why encoding username is required
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #14577
| License | MIT
| Doc PR | no
241538d shows that it's not actually tested, 257b796 reimplements it with test.
I can remove the POC commit if it's not needed.
Commits
-------
63a9736 [Security] TokenBasedRememberMeServices test to show why encoding username is required
Diffstat (limited to 'Tests/Http')
-rw-r--r-- | Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php b/Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php index 4606003..511ddcc 100644 --- a/Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php +++ b/Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php @@ -105,7 +105,12 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase $this->assertTrue($request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME)->isCleared()); } - public function testAutoLogin() + /** + * @dataProvider provideUsernamesForAutoLogin + * + * @param string $username + */ + public function testAutoLogin($username) { $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); $user @@ -123,13 +128,13 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase $userProvider ->expects($this->once()) ->method('loadUserByUsername') - ->with($this->equalTo('foouser')) + ->with($this->equalTo($username)) ->will($this->returnValue($user)) ; $service = $this->getService($userProvider, array('name' => 'foo', 'always_remember_me' => true, 'lifetime' => 3600)); $request = new Request(); - $request->cookies->set('foo', $this->getCookie('fooclass', 'foouser', time() + 3600, 'foopass')); + $request->cookies->set('foo', $this->getCookie('fooclass', $username, time() + 3600, 'foopass')); $returnedToken = $service->autoLogin($request); @@ -138,6 +143,14 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase $this->assertEquals('fookey', $returnedToken->getKey()); } + public function provideUsernamesForAutoLogin() + { + return array( + array('foouser', 'Simple username'), + array('foo'.TokenBasedRememberMeServices::COOKIE_DELIMITER.'user', 'Username might contain the delimiter'), + ); + } + public function testLogout() { $service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null)); |