From d1a1227c81ea8115f17ae25dc246e1a55bdba0b1 Mon Sep 17 00:00:00 2001 From: Nikita Konstantinov Date: Mon, 19 Aug 2013 02:28:31 +0400 Subject: [PATCH] [SecurityBundle] Fix typo in the check_path validator --- .../DependencyInjection/MainConfiguration.php | 2 +- .../Fixtures/php/invalid_check_path.php | 16 ++++++++++++++++ .../Fixtures/xml/invalid_check_path.xml | 16 ++++++++++++++++ .../Fixtures/yml/invalid_check_path.yml | 9 +++++++++ .../SecurityExtensionTest.php | 9 +++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/invalid_check_path.php create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/invalid_check_path.xml create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/invalid_check_path.yml diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php index de825b9c4df11..c20530396719f 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php @@ -283,7 +283,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto continue; } - if (false !== strpos('/', $firewall[$k]['check_path']) && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) { + if (false !== strpos($firewall[$k]['check_path'], '/') && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) { throw new \LogicException(sprintf('The check_path "%s" for login method "%s" is not matched by the firewall pattern "%s".', $firewall[$k]['check_path'], $k, $firewall['pattern'])); } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/invalid_check_path.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/invalid_check_path.php new file mode 100644 index 0000000000000..62e1acbc6c477 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/invalid_check_path.php @@ -0,0 +1,16 @@ +loadFromExtension('security', array( + 'providers' => array( + 'default' => array('id' => 'foo'), + ), + + 'firewalls' => array( + 'some_firewall' => array( + 'pattern' => '/secured_area/.*', + 'form_login' => array( + 'check_path' => '/some_area/login_check', + ) + ) + ) +)); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/invalid_check_path.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/invalid_check_path.xml new file mode 100644 index 0000000000000..f507d7037ae1c --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/invalid_check_path.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/invalid_check_path.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/invalid_check_path.yml new file mode 100644 index 0000000000000..dcdef7120220e --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/invalid_check_path.yml @@ -0,0 +1,9 @@ +security: + providers: + default: { id: foo } + + firewalls: + some_firewall: + pattern: /secured_area/.* + form_login: + check_path: /some_area/login_check \ No newline at end of file diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php index 948e27220519b..2f5a884b8903a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -184,6 +184,15 @@ public function testCustomAclProvider() $this->assertEquals('foo', (string) $container->getAlias('security.acl.provider')); } + /** + * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException + * @expectedExceptionMessage not matched by the firewall pattern + */ + public function testInvalidCheckPath() + { + $container = $this->getContainer('invalid_check_path'); + } + protected function getContainer($file) { $container = new ContainerBuilder();