Skip to content

Commit 9952ef9

Browse files
Merge branch '2.8'
* 2.8: [Bridge/Twig] Fix lowest form dep [Bridge/Doctrine] Fix legacy tests Make sure security.role_hierarchy.roles always exists [Form] Fix tests and reference usage [SecurityBundle] Fix disabling of RoleHierarchyVoter when passing empty hierarchy Conflicts: src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/AbstractEntityChoiceListCompositeIdTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/AbstractEntityChoiceListSingleAssociationToIntIdTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/AbstractEntityChoiceListSingleIntIdTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/AbstractEntityChoiceListSingleStringIdTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/AbstractEntityChoiceListTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/LoadedEntityChoiceListCompositeIdTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/LoadedEntityChoiceListSingleAssociationToIntIdTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/LoadedEntityChoiceListSingleIntIdTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/LoadedEntityChoiceListSingleStringIdTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListCompositeIdTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListCompositeIdWithQueryBuilderTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleAssociationToIntIdTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleAssociationToIntIdWithQueryBuilderTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleIntIdTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleIntIdWithQueryBuilderTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleStringIdTest.php src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleStringIdWithQueryBuilderTest.php src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
2 parents a3f48a5 + b255dfe commit 9952ef9

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private function configureDbalAclProvider(array $config, ContainerBuilder $conta
172172
*/
173173
private function createRoleHierarchy($config, ContainerBuilder $container)
174174
{
175-
if (!isset($config['role_hierarchy'])) {
175+
if (!isset($config['role_hierarchy']) || 0 === count($config['role_hierarchy'])) {
176176
$container->removeDefinition('security.access.role_hierarchy_voter');
177177

178178
return;

src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<parameters>
88
<parameter key="security.authentication.trust_resolver.anonymous_class">Symfony\Component\Security\Core\Authentication\Token\AnonymousToken</parameter>
99
<parameter key="security.authentication.trust_resolver.rememberme_class">Symfony\Component\Security\Core\Authentication\Token\RememberMeToken</parameter>
10+
<parameter key="security.role_hierarchy.roles" type="collection" />
1011
</parameters>
1112

1213
<services>

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,30 @@ public function testFirewallWithInvalidUserProvider()
9494
$container->compile();
9595
}
9696

97+
public function testDisableRoleHierarchyVoter()
98+
{
99+
$container = $this->getRawContainer();
100+
101+
$container->loadFromExtension('security', array(
102+
'providers' => array(
103+
'default' => array('id' => 'foo'),
104+
),
105+
106+
'role_hierarchy' => null,
107+
108+
'firewalls' => array(
109+
'some_firewall' => array(
110+
'pattern' => '/.*',
111+
'http_basic' => null,
112+
),
113+
),
114+
));
115+
116+
$container->compile();
117+
118+
$this->assertFalse($container->hasDefinition('security.access.role_hierarchy_voter'));
119+
}
120+
97121
protected function getRawContainer()
98122
{
99123
$container = new ContainerBuilder();

src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleHierarchyVoterTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,19 @@ public function getVoteTests()
3333
array(array('ROLE_FOO'), array('ROLE_FOOBAR'), VoterInterface::ACCESS_GRANTED),
3434
));
3535
}
36+
37+
/**
38+
* @dataProvider getVoteWithEmptyHierarchyTests
39+
*/
40+
public function testVoteWithEmptyHierarchy($roles, $attributes, $expected)
41+
{
42+
$voter = new RoleHierarchyVoter(new RoleHierarchy(array()));
43+
44+
$this->assertSame($expected, $voter->vote($this->getToken($roles), null, $attributes));
45+
}
46+
47+
public function getVoteWithEmptyHierarchyTests()
48+
{
49+
return parent::getVoteTests();
50+
}
3651
}

0 commit comments

Comments
 (0)