From a38d1cd8bf19c7ffe4dd411ffc0e0ad5bbefbfaa Mon Sep 17 00:00:00 2001 From: Mathieu Morlon Date: Tue, 23 Sep 2014 11:21:00 +0200 Subject: [PATCH] bug #10242 Missing checkPreAuth from RememberMeAuthenticationProvider --- .../RememberMeAuthenticationProvider.php | 2 +- .../RememberMeAuthenticationProviderTest.php | 20 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php index 234bddbc43f9..82be1d13e9a9 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php @@ -50,7 +50,7 @@ public function authenticate(TokenInterface $token) } $user = $token->getUser(); - $this->userChecker->checkPostAuth($user); + $this->userChecker->checkPreAuth($user); $authenticatedToken = new RememberMeToken($user, $this->providerKey, $this->key); $authenticatedToken->setAttributes($token->getAttributes()); diff --git a/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/RememberMeAuthenticationProviderTest.php b/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/RememberMeAuthenticationProviderTest.php index 88eefbbd2a7b..54fb4ea9ed18 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/RememberMeAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/RememberMeAuthenticationProviderTest.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Security\Tests\Core\Authentication\Provider; use Symfony\Component\Security\Core\Authentication\Provider\RememberMeAuthenticationProvider; -use Symfony\Component\Security\Core\Exception\AccountExpiredException; +use Symfony\Component\Security\Core\Exception\DisabledException; use Symfony\Component\Security\Core\Role\Role; class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase @@ -45,15 +45,14 @@ public function testAuthenticateWhenKeysDoNotMatch() } /** - * @expectedException \Symfony\Component\Security\Core\Exception\AccountExpiredException + * @expectedException \Symfony\Component\Security\Core\Exception\DisabledException */ - public function testAuthenticateWhenPostChecksFails() + public function testAuthenticateWhenPreChecksFails() { $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); $userChecker->expects($this->once()) - ->method('checkPostAuth') - ->will($this->throwException(new AccountExpiredException())) - ; + ->method('checkPreAuth') + ->will($this->throwException(new DisabledException())); $provider = $this->getProvider($userChecker); @@ -65,8 +64,7 @@ public function testAuthenticate() $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); $user->expects($this->exactly(2)) ->method('getRoles') - ->will($this->returnValue(array('ROLE_FOO'))) - ; + ->will($this->returnValue(array('ROLE_FOO'))); $provider = $this->getProvider(); @@ -86,16 +84,14 @@ protected function getSupportedToken($user = null, $key = 'test') $user ->expects($this->any()) ->method('getRoles') - ->will($this->returnValue(array())) - ; + ->will($this->returnValue(array())); } $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('getProviderKey'), array($user, 'foo', $key)); $token ->expects($this->once()) ->method('getProviderKey') - ->will($this->returnValue('foo')) - ; + ->will($this->returnValue('foo')); return $token; }