summaryrefslogtreecommitdiffstats
path: root/Http/Tests/Firewall
diff options
context:
space:
mode:
Diffstat (limited to 'Http/Tests/Firewall')
-rw-r--r--Http/Tests/Firewall/ContextListenerTest.php8
-rw-r--r--Http/Tests/Firewall/ExceptionListenerTest.php14
2 files changed, 22 insertions, 0 deletions
diff --git a/Http/Tests/Firewall/ContextListenerTest.php b/Http/Tests/Firewall/ContextListenerTest.php
index ae1199a..0213330 100644
--- a/Http/Tests/Firewall/ContextListenerTest.php
+++ b/Http/Tests/Firewall/ContextListenerTest.php
@@ -18,6 +18,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
+use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Firewall\ContextListener;
@@ -85,6 +86,13 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($session->has('_security_session'));
}
+ public function testOnKernelResponseWillRemoveSessionOnAnonymousToken()
+ {
+ $session = $this->runSessionOnKernelResponse(new AnonymousToken('secret', 'anon.'), 'C:10:"serialized"');
+
+ $this->assertFalse($session->has('_security_session'));
+ }
+
public function testOnKernelResponseWithoutSession()
{
$tokenStorage = new TokenStorage();
diff --git a/Http/Tests/Firewall/ExceptionListenerTest.php b/Http/Tests/Firewall/ExceptionListenerTest.php
index 3d409e5..db0a242 100644
--- a/Http/Tests/Firewall/ExceptionListenerTest.php
+++ b/Http/Tests/Firewall/ExceptionListenerTest.php
@@ -65,6 +65,20 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
);
}
+ public function testExceptionWhenEntryPointReturnsBadValue()
+ {
+ $event = $this->createEvent(new AuthenticationException());
+
+ $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface');
+ $entryPoint->expects($this->once())->method('start')->will($this->returnValue('NOT A RESPONSE'));
+
+ $listener = $this->createExceptionListener(null, null, null, $entryPoint);
+ $listener->onKernelException($event);
+ // the exception has been replaced by our LogicException
+ $this->assertInstanceOf('LogicException', $event->getException());
+ $this->assertStringEndsWith('start() method must return a Response object (string returned)', $event->getException()->getMessage());
+ }
+
/**
* @dataProvider getAccessDeniedExceptionProvider
*/