Fix typo in the check_path validator

This commit is contained in:
Nikita Konstantinov 2013-08-19 02:28:31 +04:00 committed by Fabien Potencier
parent 5f7219e2ab
commit 51022c30ae
5 changed files with 51 additions and 1 deletions

View File

@ -283,7 +283,7 @@ class MainConfiguration implements ConfigurationInterface
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']));
}
}

View File

@ -0,0 +1,16 @@
<?php
$container->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',
)
)
)
));

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<srv:container xmlns="http://symfony.com/schema/dic/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<config>
<provider name="default" id="foo" />
<firewall name="some_firewall" pattern="/secured_area/.*">
<form-login check-path="/some_area/login_check" />
</firewall>
</config>
</srv:container>

View File

@ -0,0 +1,9 @@
security:
providers:
default: { id: foo }
firewalls:
some_firewall:
pattern: /secured_area/.*
form_login:
check_path: /some_area/login_check

View File

@ -184,6 +184,15 @@ abstract class SecurityExtensionTest extends \PHPUnit_Framework_TestCase
$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();