summaryrefslogtreecommitdiffstats
path: root/Http/Tests
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2015-10-18 22:24:22 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2015-10-18 22:24:22 +0200
commitdfef828a55f3fd50ba06a45188ce7ae5a91b84f4 (patch)
treed2a748ee8a131676883476d77d66097f75f16b19 /Http/Tests
parentbcd6634e81903b837628e5b9a122eba2e8621fef (diff)
parent4786bbb2ac01bb89fc7aceb36bfe8cfe05dde675 (diff)
downloadsymfony-security-dfef828a55f3fd50ba06a45188ce7ae5a91b84f4.zip
symfony-security-dfef828a55f3fd50ba06a45188ce7ae5a91b84f4.tar.gz
symfony-security-dfef828a55f3fd50ba06a45188ce7ae5a91b84f4.tar.bz2
Merge branch '2.8'
* 2.8: [Routing] use constants in tests [Process] tweaked README [TwigBundle] Fix Twig cache is not properly warmed [Validator] Allow an empty path in a URL with only a fragment or a query [Security] Use SessionAuthenticationStrategy on RememberMe login [HttpFoundation] Fix some typo in the Request doc fixed CS Added separated handling of root paths
Diffstat (limited to 'Http/Tests')
-rw-r--r--Http/Tests/Firewall/RememberMeListenerTest.php77
-rw-r--r--Http/Tests/HttpUtilsTest.php3
2 files changed, 76 insertions, 4 deletions
diff --git a/Http/Tests/Firewall/RememberMeListenerTest.php b/Http/Tests/Firewall/RememberMeListenerTest.php
index e348355..b16d55b 100644
--- a/Http/Tests/Firewall/RememberMeListenerTest.php
+++ b/Http/Tests/Firewall/RememberMeListenerTest.php
@@ -181,6 +181,71 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
$listener->handle($event);
}
+ public function testSessionStrategy()
+ {
+ list($listener, $tokenStorage, $service, $manager, , $dispatcher, $sessionStrategy) = $this->getListener(false, true, true);
+
+ $tokenStorage
+ ->expects($this->once())
+ ->method('getToken')
+ ->will($this->returnValue(null))
+ ;
+
+ $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $service
+ ->expects($this->once())
+ ->method('autoLogin')
+ ->will($this->returnValue($token))
+ ;
+
+ $tokenStorage
+ ->expects($this->once())
+ ->method('setToken')
+ ->with($this->equalTo($token))
+ ;
+
+ $manager
+ ->expects($this->once())
+ ->method('authenticate')
+ ->will($this->returnValue($token))
+ ;
+
+ $session = $this->getMock('\Symfony\Component\HttpFoundation\Session\SessionInterface');
+ $session
+ ->expects($this->once())
+ ->method('isStarted')
+ ->will($this->returnValue(true))
+ ;
+
+ $request = $this->getMock('\Symfony\Component\HttpFoundation\Request');
+ $request
+ ->expects($this->once())
+ ->method('hasSession')
+ ->will($this->returnValue(true))
+ ;
+
+ $request
+ ->expects($this->once())
+ ->method('getSession')
+ ->will($this->returnValue($session))
+ ;
+
+ $event = $this->getGetResponseEvent();
+ $event
+ ->expects($this->once())
+ ->method('getRequest')
+ ->will($this->returnValue($request))
+ ;
+
+ $sessionStrategy
+ ->expects($this->once())
+ ->method('onAuthentication')
+ ->will($this->returnValue(null))
+ ;
+
+ $listener->handle($event);
+ }
+
public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherIsPresent()
{
list($listener, $tokenStorage, $service, $manager, , $dispatcher) = $this->getListener(true);
@@ -240,7 +305,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
return $this->getMock('Symfony\Component\HttpKernel\Event\FilterResponseEvent', array(), array(), '', false);
}
- protected function getListener($withDispatcher = false, $catchExceptions = true)
+ protected function getListener($withDispatcher = false, $catchExceptions = true, $withSessionStrategy = false)
{
$listener = new RememberMeListener(
$tokenStorage = $this->getTokenStorage(),
@@ -248,10 +313,11 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
$manager = $this->getManager(),
$logger = $this->getLogger(),
$dispatcher = ($withDispatcher ? $this->getDispatcher() : null),
- $catchExceptions
+ $catchExceptions,
+ $sessionStrategy = ($withSessionStrategy ? $this->getSessionStrategy() : null)
);
- return array($listener, $tokenStorage, $service, $manager, $logger, $dispatcher);
+ return array($listener, $tokenStorage, $service, $manager, $logger, $dispatcher, $sessionStrategy);
}
protected function getLogger()
@@ -278,4 +344,9 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
{
return $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
}
+
+ private function getSessionStrategy()
+ {
+ return $this->getMock('\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface');
+ }
}
diff --git a/Http/Tests/HttpUtilsTest.php b/Http/Tests/HttpUtilsTest.php
index 195fc48..45a0281 100644
--- a/Http/Tests/HttpUtilsTest.php
+++ b/Http/Tests/HttpUtilsTest.php
@@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Security\Core\Security;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Http\HttpUtils;
class HttpUtilsTest extends \PHPUnit_Framework_TestCase
@@ -43,7 +44,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
$urlGenerator
->expects($this->any())
->method('generate')
- ->with('foobar', array(), true)
+ ->with('foobar', array(), UrlGeneratorInterface::ABSOLUTE_URL)
->will($this->returnValue('http://localhost/foo/bar'))
;
$urlGenerator