diff options
author | Fabien Potencier <fabien.potencier@gmail.com> | 2012-08-10 13:48:23 +0200 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2012-08-10 13:48:23 +0200 |
commit | 3d7bc6981737b48b504afbc9813c1a491cdfa4c1 (patch) | |
tree | f2c9431548b7c5758fcd589cd8a0a49554bf32ce /Tests/Http | |
parent | 554ad6bb1448fdd54274a061d6a9ee8951284078 (diff) | |
download | symfony-security-3d7bc6981737b48b504afbc9813c1a491cdfa4c1.zip symfony-security-3d7bc6981737b48b504afbc9813c1a491cdfa4c1.tar.gz symfony-security-3d7bc6981737b48b504afbc9813c1a491cdfa4c1.tar.bz2 |
merged 2.0
Diffstat (limited to 'Tests/Http')
-rw-r--r-- | Tests/Http/Firewall/ContextListenerTest.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Tests/Http/Firewall/ContextListenerTest.php b/Tests/Http/Firewall/ContextListenerTest.php index 646ed23..d360ef5 100644 --- a/Tests/Http/Firewall/ContextListenerTest.php +++ b/Tests/Http/Firewall/ContextListenerTest.php @@ -125,4 +125,47 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase $this->assertFalse($request->hasSession()); } + + /** + * @dataProvider provideInvalidToken + */ + public function testInvalidTokenInSession($token) + { + $context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') + ->disableOriginalConstructor() + ->getMock(); + $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session') + ->disableOriginalConstructor() + ->getMock(); + + $event->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($request)); + $request->expects($this->any()) + ->method('hasPreviousSession') + ->will($this->returnValue(true)); + $request->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($session)); + $session->expects($this->any()) + ->method('get') + ->with('_security_key123') + ->will($this->returnValue(serialize($token))); + $context->expects($this->once()) + ->method('setToken') + ->with(null); + + $listener = new ContextListener($context, array(), 'key123'); + $listener->handle($event); + } + + public function provideInvalidToken() + { + return array( + array(new \__PHP_Incomplete_Class()), + array(null), + ); + } } |