diff options
Diffstat (limited to 'Http')
-rw-r--r-- | Http/EntryPoint/DigestAuthenticationEntryPoint.php | 2 | ||||
-rw-r--r-- | Http/Firewall/AccessListener.php | 2 | ||||
-rw-r--r-- | Http/Firewall/ContextListener.php | 3 | ||||
-rw-r--r-- | Http/Firewall/ExceptionListener.php | 4 | ||||
-rw-r--r-- | Http/RememberMe/PersistentTokenBasedRememberMeServices.php | 2 | ||||
-rw-r--r-- | Http/RememberMe/RememberMeServicesInterface.php | 11 | ||||
-rw-r--r-- | Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php | 2 | ||||
-rw-r--r-- | Http/Tests/Firewall/ContextListenerTest.php | 36 | ||||
-rw-r--r-- | Http/Tests/Firewall/ExceptionListenerTest.php | 6 | ||||
-rw-r--r-- | Http/Tests/Firewall/RememberMeListenerTest.php | 8 | ||||
-rw-r--r-- | Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php | 4 | ||||
-rw-r--r-- | Http/composer.json | 1 | ||||
-rw-r--r-- | Http/phpunit.xml.dist | 4 |
13 files changed, 59 insertions, 26 deletions
diff --git a/Http/EntryPoint/DigestAuthenticationEntryPoint.php b/Http/EntryPoint/DigestAuthenticationEntryPoint.php index 8143a41..89f80ad 100644 --- a/Http/EntryPoint/DigestAuthenticationEntryPoint.php +++ b/Http/EntryPoint/DigestAuthenticationEntryPoint.php @@ -50,7 +50,7 @@ class DigestAuthenticationEntryPoint implements AuthenticationEntryPointInterfac $authenticateHeader = sprintf('Digest realm="%s", qop="auth", nonce="%s"', $this->realmName, $nonceValueBase64); if ($authException instanceof NonceExpiredException) { - $authenticateHeader = $authenticateHeader.', stale="true"'; + $authenticateHeader .= ', stale="true"'; } if (null !== $this->logger) { diff --git a/Http/Firewall/AccessListener.php b/Http/Firewall/AccessListener.php index 93d20be..6fd68f3 100644 --- a/Http/Firewall/AccessListener.php +++ b/Http/Firewall/AccessListener.php @@ -55,7 +55,7 @@ class AccessListener implements ListenerInterface $request = $event->getRequest(); - list($attributes, $channel) = $this->map->getPatterns($request); + list($attributes) = $this->map->getPatterns($request); if (null === $attributes) { return; diff --git a/Http/Firewall/ContextListener.php b/Http/Firewall/ContextListener.php index 8df0d34..013586c 100644 --- a/Http/Firewall/ContextListener.php +++ b/Http/Firewall/ContextListener.php @@ -115,6 +115,9 @@ class ContextListener implements ListenerInterface return; } + $this->dispatcher->removeListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse')); + $this->registered = false; + $request = $event->getRequest(); $session = $request->getSession(); diff --git a/Http/Firewall/ExceptionListener.php b/Http/Firewall/ExceptionListener.php index 7001532..213a837 100644 --- a/Http/Firewall/ExceptionListener.php +++ b/Http/Firewall/ExceptionListener.php @@ -94,7 +94,7 @@ class ExceptionListener } elseif ($exception instanceof AccessDeniedException) { return $this->handleAccessDeniedException($event, $exception); } elseif ($exception instanceof LogoutException) { - return $this->handleLogoutException($event, $exception); + return $this->handleLogoutException($exception); } } while (null !== $exception = $exception->getPrevious()); } @@ -160,7 +160,7 @@ class ExceptionListener } } - private function handleLogoutException(GetResponseForExceptionEvent $event, LogoutException $exception) + private function handleLogoutException(LogoutException $exception) { if (null !== $this->logger) { $this->logger->info('A LogoutException was thrown.', array('exception' => $exception)); diff --git a/Http/RememberMe/PersistentTokenBasedRememberMeServices.php b/Http/RememberMe/PersistentTokenBasedRememberMeServices.php index d0a70b7..f800668 100644 --- a/Http/RememberMe/PersistentTokenBasedRememberMeServices.php +++ b/Http/RememberMe/PersistentTokenBasedRememberMeServices.php @@ -73,7 +73,7 @@ class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices if (null !== ($cookie = $request->cookies->get($this->options['name'])) && count($parts = $this->decodeCookie($cookie)) === 2 ) { - list($series, $tokenValue) = $parts; + list($series) = $parts; $this->tokenProvider->deleteTokenBySeries($series); } } diff --git a/Http/RememberMe/RememberMeServicesInterface.php b/Http/RememberMe/RememberMeServicesInterface.php index a00dcef..7adb827 100644 --- a/Http/RememberMe/RememberMeServicesInterface.php +++ b/Http/RememberMe/RememberMeServicesInterface.php @@ -1,9 +1,4 @@ <?php -namespace Symfony\Component\Security\Http\RememberMe; - -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Request; /* * This file is part of the Symfony package. @@ -14,6 +9,12 @@ use Symfony\Component\HttpFoundation\Request; * file that was distributed with this source code. */ +namespace Symfony\Component\Security\Http\RememberMe; + +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\Request; + /** * Interface that needs to be implemented by classes which provide remember-me * capabilities. diff --git a/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php b/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php index 97167c9..6e79b07 100644 --- a/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php +++ b/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php @@ -31,7 +31,7 @@ class SimpleAuthenticationHandlerTest extends \PHPUnit_Framework_TestCase private $response; - public function setUp() + protected function setUp() { $this->successHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface'); $this->failureHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface'); diff --git a/Http/Tests/Firewall/ContextListenerTest.php b/Http/Tests/Firewall/ContextListenerTest.php index cb9685a..ae1199a 100644 --- a/Http/Tests/Firewall/ContextListenerTest.php +++ b/Http/Tests/Firewall/ContextListenerTest.php @@ -21,6 +21,7 @@ use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Http\Firewall\ContextListener; +use Symfony\Component\EventDispatcher\EventDispatcher; class ContextListenerTest extends \PHPUnit_Framework_TestCase { @@ -99,7 +100,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase new Response() ); - $listener = new ContextListener($tokenStorage, array(), 'session'); + $listener = new ContextListener($tokenStorage, array(), 'session', null, new EventDispatcher()); $listener->onKernelResponse($event); $this->assertTrue($session->isStarted()); @@ -118,7 +119,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase new Response() ); - $listener = new ContextListener(new TokenStorage(), array(), 'session'); + $listener = new ContextListener(new TokenStorage(), array(), 'session', null, new EventDispatcher()); $listener->onKernelResponse($event); $this->assertFalse($session->isStarted()); @@ -190,6 +191,35 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase $listener->handle($event); } + public function testOnKernelResponseListenerRemovesItself() + { + $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent') + ->disableOriginalConstructor() + ->getMock(); + + $listener = new ContextListener($tokenStorage, array(), 'key123', null, $dispatcher); + + $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request->expects($this->any()) + ->method('hasSession') + ->will($this->returnValue(true)); + + $event->expects($this->any()) + ->method('isMasterRequest') + ->will($this->returnValue(true)); + $event->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($request)); + + $dispatcher->expects($this->once()) + ->method('removeListener') + ->with(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); + + $listener->onKernelResponse($event); + } + public function testHandleRemovesTokenIfNoPreviousSessionWasFound() { $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); @@ -229,7 +259,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase new Response() ); - $listener = new ContextListener($tokenStorage, array(), 'session'); + $listener = new ContextListener($tokenStorage, array(), 'session', null, new EventDispatcher()); $listener->onKernelResponse($event); return $session; diff --git a/Http/Tests/Firewall/ExceptionListenerTest.php b/Http/Tests/Firewall/ExceptionListenerTest.php index d7d1826..3d409e5 100644 --- a/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/Http/Tests/Firewall/ExceptionListenerTest.php @@ -172,9 +172,9 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase private function createExceptionListener(TokenStorageInterface $tokenStorage = null, AuthenticationTrustResolverInterface $trustResolver = null, HttpUtils $httpUtils = null, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null) { return new ExceptionListener( - $tokenStorage ? $tokenStorage : $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'), - $trustResolver ? $trustResolver : $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'), - $httpUtils ? $httpUtils : $this->getMock('Symfony\Component\Security\Http\HttpUtils'), + $tokenStorage ?: $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'), + $trustResolver ?: $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'), + $httpUtils ?: $this->getMock('Symfony\Component\Security\Http\HttpUtils'), 'key', $authenticationEntryPoint, $errorPage, diff --git a/Http/Tests/Firewall/RememberMeListenerTest.php b/Http/Tests/Firewall/RememberMeListenerTest.php index f6c30b8..ec1c35d 100644 --- a/Http/Tests/Firewall/RememberMeListenerTest.php +++ b/Http/Tests/Firewall/RememberMeListenerTest.php @@ -20,7 +20,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase { public function testOnCoreSecurityDoesNotTryToPopulateNonEmptyTokenStorage() { - list($listener, $tokenStorage, , , ,) = $this->getListener(); + list($listener, $tokenStorage) = $this->getListener(); $tokenStorage ->expects($this->once()) @@ -38,7 +38,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase public function testOnCoreSecurityDoesNothingWhenNoCookieIsSet() { - list($listener, $tokenStorage, $service, ,) = $this->getListener(); + list($listener, $tokenStorage, $service) = $this->getListener(); $tokenStorage ->expects($this->once()) @@ -64,7 +64,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenticationManagerImplementation() { - list($listener, $tokenStorage, $service, $manager,) = $this->getListener(); + list($listener, $tokenStorage, $service, $manager) = $this->getListener(); $tokenStorage ->expects($this->once()) @@ -144,7 +144,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase public function testOnCoreSecurity() { - list($listener, $tokenStorage, $service, $manager,) = $this->getListener(); + list($listener, $tokenStorage, $service, $manager) = $this->getListener(); $tokenStorage ->expects($this->once()) diff --git a/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php b/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php index 794841d..0a1286c 100644 --- a/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php +++ b/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php @@ -92,7 +92,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $listener->handle($this->event); } - public function setUp() + protected function setUp() { $this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager') ->disableOriginalConstructor() @@ -115,7 +115,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); } - public function tearDown() + protected function tearDown() { $this->authenticationManager = null; $this->dispatcher = null; diff --git a/Http/composer.json b/Http/composer.json index 007ae75..80a0387 100644 --- a/Http/composer.json +++ b/Http/composer.json @@ -23,6 +23,7 @@ "symfony/http-kernel": "~2.4|~3.0.0" }, "require-dev": { + "symfony/phpunit-bridge": "~2.7|~3.0.0", "symfony/routing": "~2.2|~3.0.0", "symfony/security-csrf": "~2.4|~3.0.0", "psr/log": "~1.0" diff --git a/Http/phpunit.xml.dist b/Http/phpunit.xml.dist index 58fe58e..49b36f2 100644 --- a/Http/phpunit.xml.dist +++ b/Http/phpunit.xml.dist @@ -12,9 +12,7 @@ bootstrap="vendor/autoload.php" > <php> - <!-- Disable E_USER_DEPRECATED until 3.0 --> - <!-- php -r 'echo -1 & ~E_USER_DEPRECATED;' --> - <ini name="error_reporting" value="-16385"/> + <ini name="error_reporting" value="-1" /> </php> <testsuites> |