[FrameworkBundle] fixed XSD for the trusted-proxies setting
This commit is contained in:
parent
16c554bc1f
commit
0085798dff
@ -48,6 +48,10 @@ class Configuration implements ConfigurationInterface
|
||||
->children()
|
||||
->scalarNode('charset')->end()
|
||||
->arrayNode('trusted_proxies')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return !is_array($v); })
|
||||
->then(function($v) { return preg_split('/\s*,\s*/', $v); })
|
||||
->end()
|
||||
->prototype('scalar')
|
||||
->validate()
|
||||
->ifTrue(function($v) { return !filter_var($v, FILTER_VALIDATE_IP); })
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
<xsd:attribute name="charset" type="xsd:string" />
|
||||
<xsd:attribute name="trust-proxy-headers" type="xsd:string" />
|
||||
<xsd:attribute name="trusted-proxies" type="xsd:string" />
|
||||
<xsd:attribute name="ide" type="xsd:string" />
|
||||
<xsd:attribute name="secret" type="xsd:string" />
|
||||
<xsd:attribute name="test" type="xsd:boolean" />
|
||||
|
@ -57,7 +57,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidTypeException
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
*/
|
||||
public function testInvalidTypeTrustedProxies()
|
||||
{
|
||||
|
@ -3,6 +3,8 @@
|
||||
$container->loadFromExtension('framework', array(
|
||||
'secret' => 's3cr3t',
|
||||
'form' => null,
|
||||
'trust_proxy_headers' => true,
|
||||
'trusted_proxies' => array('127.0.0.1', '10.0.0.1'),
|
||||
'csrf_protection' => array(
|
||||
'enabled' => true,
|
||||
'field_name' => '_csrf',
|
||||
|
@ -6,7 +6,7 @@
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config secret="s3cr3t" ide="file%%link%%format">
|
||||
<framework:config secret="s3cr3t" ide="file%%link%%format" trust-proxy-headers="true" trusted-proxies="127.0.0.1, 10.0.0.1">
|
||||
<framework:csrf-protection enabled="true" field-name="_csrf" />
|
||||
<framework:form />
|
||||
<framework:esi enabled="true" />
|
||||
|
@ -1,6 +1,8 @@
|
||||
framework:
|
||||
secret: s3cr3t
|
||||
form: ~
|
||||
trust_proxy_headers: true
|
||||
trusted_proxies: ['127.0.0.1', '10.0.0.1']
|
||||
csrf_protection:
|
||||
enabled: true
|
||||
field_name: _csrf
|
||||
|
@ -33,6 +33,14 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertEquals('s3cr3t', $container->getParameterBag()->resolveValue($container->findDefinition('form.csrf_provider')->getArgument(1)));
|
||||
}
|
||||
|
||||
public function testProxies()
|
||||
{
|
||||
$container = $this->createContainerFromFile('full');
|
||||
|
||||
$this->assertTrue($container->getParameter('kernel.trust_proxy_headers'));
|
||||
$this->assertEquals(array('127.0.0.1', '10.0.0.1'), $container->getParameter('kernel.trusted_proxies'));
|
||||
}
|
||||
|
||||
public function testEsi()
|
||||
{
|
||||
$container = $this->createContainerFromFile('full');
|
||||
|
Reference in New Issue
Block a user