Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f0743b1

Browse filesBrowse files
committed
Merge pull request #1 from pylebecq/2.0
[FrameworkBundle] Added tests for trusted_proxies configuration.
2 parents a0e2391 + 555e777 commit f0743b1
Copy full SHA for f0743b1

File tree

1 file changed

+78
-0
lines changed
Filter options

1 file changed

+78
-0
lines changed
+78Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
13+
14+
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
15+
use Symfony\Component\Config\Definition\Processor;
16+
17+
class ConfigurationTest extends \PHPUnit_Framework_TestCase
18+
{
19+
/**
20+
* @dataProvider getTestConfigTreeData
21+
*/
22+
public function testConfigTree($options, $results)
23+
{
24+
$processor = new Processor();
25+
$configuration = new Configuration(array());
26+
$config = $processor->processConfiguration($configuration, array($options));
27+
28+
$this->assertEquals($results, $config);
29+
}
30+
31+
public function getTestConfigTreeData()
32+
{
33+
return array(
34+
array(array('secret' => 's3cr3t'), array('secret' => 's3cr3t', 'trusted_proxies' => array(), 'trust_proxy_headers' => false, 'ide' => NULL, 'annotations' => array('cache' => 'file', 'file_cache_dir' => '%kernel.cache_dir%/annotations', 'debug' => false))),
35+
);
36+
}
37+
38+
/**
39+
* @dataProvider getTestValidTrustedProxiesData
40+
*/
41+
public function testValidTrustedProxies($options, $results)
42+
{
43+
$processor = new Processor();
44+
$configuration = new Configuration(array());
45+
$config = $processor->processConfiguration($configuration, array($options));
46+
47+
$this->assertEquals($results, $config);
48+
}
49+
50+
public function getTestValidTrustedProxiesData()
51+
{
52+
return array(
53+
array(array('secret' => 's3cr3t', 'trusted_proxies' => array('127.0.0.1')), array('secret' => 's3cr3t', 'trusted_proxies' => array('127.0.0.1'), 'trust_proxy_headers' => false, 'ide' => NULL, 'annotations' => array('cache' => 'file', 'file_cache_dir' => '%kernel.cache_dir%/annotations', 'debug' => false))),
54+
array(array('secret' => 's3cr3t', 'trusted_proxies' => array('::1')), array('secret' => 's3cr3t', 'trusted_proxies' => array('::1'), 'trust_proxy_headers' => false, 'ide' => NULL, 'annotations' => array('cache' => 'file', 'file_cache_dir' => '%kernel.cache_dir%/annotations', 'debug' => false))),
55+
array(array('secret' => 's3cr3t', 'trusted_proxies' => array('127.0.0.1', '::1')), array('secret' => 's3cr3t', 'trusted_proxies' => array('127.0.0.1', '::1'), 'trust_proxy_headers' => false, 'ide' => NULL, 'annotations' => array('cache' => 'file', 'file_cache_dir' => '%kernel.cache_dir%/annotations', 'debug' => false))),
56+
);
57+
}
58+
59+
/**
60+
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidTypeException
61+
*/
62+
public function testInvalidTypeTrustedProxies()
63+
{
64+
$processor = new Processor();
65+
$configuration = new Configuration(array());
66+
$config = $processor->processConfiguration($configuration, array(array('secret' => 's3cr3t', 'trusted_proxies' => 'Not an IP address')));
67+
}
68+
69+
/**
70+
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
71+
*/
72+
public function testInvalidValueTrustedProxies()
73+
{
74+
$processor = new Processor();
75+
$configuration = new Configuration(array());
76+
$config = $processor->processConfiguration($configuration, array(array('secret' => 's3cr3t', 'trusted_proxies' => array('Not an IP address'))));
77+
}
78+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.