bug #10242 Missing checkPreAuth from RememberMeAuthenticationProvider
This commit is contained in:
parent
bc8ee6f497
commit
a38d1cd8bf
@ -50,7 +50,7 @@ class RememberMeAuthenticationProvider implements AuthenticationProviderInterfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
$user = $token->getUser();
|
$user = $token->getUser();
|
||||||
$this->userChecker->checkPostAuth($user);
|
$this->userChecker->checkPreAuth($user);
|
||||||
|
|
||||||
$authenticatedToken = new RememberMeToken($user, $this->providerKey, $this->key);
|
$authenticatedToken = new RememberMeToken($user, $this->providerKey, $this->key);
|
||||||
$authenticatedToken->setAttributes($token->getAttributes());
|
$authenticatedToken->setAttributes($token->getAttributes());
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\Security\Tests\Core\Authentication\Provider;
|
namespace Symfony\Component\Security\Tests\Core\Authentication\Provider;
|
||||||
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Provider\RememberMeAuthenticationProvider;
|
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;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
|
||||||
class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
||||||
@ -45,15 +45,14 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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 = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
|
||||||
$userChecker->expects($this->once())
|
$userChecker->expects($this->once())
|
||||||
->method('checkPostAuth')
|
->method('checkPreAuth')
|
||||||
->will($this->throwException(new AccountExpiredException()))
|
->will($this->throwException(new DisabledException()));
|
||||||
;
|
|
||||||
|
|
||||||
$provider = $this->getProvider($userChecker);
|
$provider = $this->getProvider($userChecker);
|
||||||
|
|
||||||
@ -65,8 +64,7 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
|
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
|
||||||
$user->expects($this->exactly(2))
|
$user->expects($this->exactly(2))
|
||||||
->method('getRoles')
|
->method('getRoles')
|
||||||
->will($this->returnValue(array('ROLE_FOO')))
|
->will($this->returnValue(array('ROLE_FOO')));
|
||||||
;
|
|
||||||
|
|
||||||
$provider = $this->getProvider();
|
$provider = $this->getProvider();
|
||||||
|
|
||||||
@ -86,16 +84,14 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$user
|
$user
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getRoles')
|
->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 = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('getProviderKey'), array($user, 'foo', $key));
|
||||||
$token
|
$token
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getProviderKey')
|
->method('getProviderKey')
|
||||||
->will($this->returnValue('foo'))
|
->will($this->returnValue('foo'));
|
||||||
;
|
|
||||||
|
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user