diff options
author | Fabien Potencier <fabien.potencier@gmail.com> | 2014-09-25 09:10:47 +0200 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2014-09-25 09:10:47 +0200 |
commit | 88ac10c21de12eece696dc8f8dde9bcb11da4b10 (patch) | |
tree | 66517d2a702342837c99998bf12f3edfd710e8fd /Http/Tests/Firewall | |
parent | d52740c8c0f0a5b98e31b4f759b6681ec364d576 (diff) | |
parent | 96a74b6c35c7ce8fd3450fbb117b7c7134849eb2 (diff) | |
download | symfony-security-88ac10c21de12eece696dc8f8dde9bcb11da4b10.zip symfony-security-88ac10c21de12eece696dc8f8dde9bcb11da4b10.tar.gz symfony-security-88ac10c21de12eece696dc8f8dde9bcb11da4b10.tar.bz2 |
feature #10694 [Security] Call AuthenticationManager in AnonymousAuthenticationListener (Kacper Gunia)
This PR was merged into the 2.6-dev branch.
Discussion
----------
[Security] Call AuthenticationManager in AnonymousAuthenticationListener
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | yes
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #10651
| License | MIT
| Doc PR | -
Commits
-------
78fa5e2 Call AuthenticationManager in AnonymousAuthenticationListener
Diffstat (limited to 'Http/Tests/Firewall')
-rw-r--r-- | Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php b/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php index 1fb7350..e6bab4e 100644 --- a/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php +++ b/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Security\Http\Tests\Firewall; +use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; use Symfony\Component\Security\Http\Firewall\AnonymousAuthenticationListener; class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase @@ -28,7 +29,13 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ->method('setToken') ; - $listener = new AnonymousAuthenticationListener($context, 'TheKey'); + $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager + ->expects($this->never()) + ->method('authenticate') + ; + + $listener = new AnonymousAuthenticationListener($context, 'TheKey', $authenticationManager); $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); } @@ -40,16 +47,27 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ->method('getToken') ->will($this->returnValue(null)) ; - $context + + $anonymousToken = new AnonymousToken('TheKey', 'anon.', array()); + + $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager ->expects($this->once()) - ->method('setToken') + ->method('authenticate') ->with(self::logicalAnd( - $this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken'), - $this->attributeEqualTo('key', 'TheKey') + $this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken'), + $this->attributeEqualTo('key', 'TheKey') )) + ->will($this->returnValue($anonymousToken)) ; - $listener = new AnonymousAuthenticationListener($context, 'TheKey'); + $context + ->expects($this->once()) + ->method('setToken') + ->with($anonymousToken) + ; + + $listener = new AnonymousAuthenticationListener($context, 'TheKey', $authenticationManager); $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); } @@ -66,7 +84,9 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ->with('Populated SecurityContext with an anonymous Token') ; - $listener = new AnonymousAuthenticationListener($context, 'TheKey', $logger); + $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + + $listener = new AnonymousAuthenticationListener($context, 'TheKey', $authenticationManager, $logger); $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); } } |