Skip to content

Commit 5e10107

Browse files
committed
Merge branch '6.4' into 7.1
* 6.4: fix tests [DependencyInjection] Add tests for repeating `#[Autoconfigure]` attributes [DependencyInjection] Fix handling of repeated `#[Autoconfigure]` attributes [SecurityBundle] Make security schema deterministic [Translations][Core] Fix security Italian translation. clean up PHP version checks Support the `unique_proxy_open` event
2 parents 29d1471 + 620be16 commit 5e10107

10 files changed

+233
-3
lines changed

Resources/config/schema/security-1.0.xsd

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<xsd:element name="memory" type="memory" />
9292
<xsd:element name="ldap" type="ldap" />
9393
<!-- allow factories to use dynamic elements -->
94-
<xsd:any processContents="lax" />
94+
<xsd:any processContents="lax" namespace="##other" />
9595
</xsd:choice>
9696
<xsd:attribute name="name" type="xsd:string" use="required" />
9797
<xsd:attribute name="id" type="xsd:string" />
@@ -150,7 +150,7 @@
150150
<xsd:element name="x509" type="x509" minOccurs="0" maxOccurs="1" />
151151
<xsd:element name="required-badge" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
152152
<!-- allow factories to use dynamic elements -->
153-
<xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
153+
<xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded" namespace="##other" />
154154
</xsd:choice>
155155
<xsd:attribute name="name" type="xsd:string" use="required" />
156156
<xsd:attribute name="pattern" type="xsd:string" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\Authenticator;
4+
5+
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
6+
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
7+
use Symfony\Component\DependencyInjection\ContainerBuilder;
8+
9+
class CustomAuthenticator implements AuthenticatorFactoryInterface
10+
{
11+
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): string
12+
{
13+
return 'security.authenticator.custom.'.$firewallName;
14+
}
15+
16+
public function getKey(): string
17+
{
18+
return 'custom';
19+
}
20+
21+
public function addConfiguration(NodeDefinition $builder): void
22+
{
23+
}
24+
25+
public function getPriority(): int
26+
{
27+
return 0;
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider;
4+
5+
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
6+
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
7+
use Symfony\Component\DependencyInjection\ContainerBuilder;
8+
9+
class CustomProvider implements UserProviderFactoryInterface
10+
{
11+
public function create(ContainerBuilder $container, string $id, array $config): void
12+
{
13+
}
14+
15+
public function getKey(): string
16+
{
17+
return 'custom';
18+
}
19+
20+
public function addConfiguration(NodeDefinition $builder): void
21+
{
22+
$builder
23+
->children()
24+
->scalarNode('foo')->defaultValue('bar')->end()
25+
->end()
26+
;
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:sec="http://symfony.com/schema/dic/security"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services
7+
https://symfony.com/schema/dic/services/services-1.0.xsd
8+
http://symfony.com/schema/dic/security
9+
https://symfony.com/schema/dic/security/security-1.0.xsd">
10+
11+
<sec:config>
12+
<sec:firewall name="main">
13+
<custom xmlns="http://example.com/schema" />
14+
</sec:firewall>
15+
</sec:config>
16+
17+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:sec="http://symfony.com/schema/dic/security"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services
7+
https://symfony.com/schema/dic/services/services-1.0.xsd
8+
http://symfony.com/schema/dic/security
9+
https://symfony.com/schema/dic/security/security-1.0.xsd">
10+
11+
<sec:config>
12+
<sec:firewall name="main">
13+
<sec:custom />
14+
</sec:firewall>
15+
</sec:config>
16+
17+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:sec="http://symfony.com/schema/dic/security"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services
7+
https://symfony.com/schema/dic/services/services-1.0.xsd
8+
http://symfony.com/schema/dic/security
9+
https://symfony.com/schema/dic/security/security-1.0.xsd">
10+
11+
<sec:config>
12+
<sec:provider name="foo">
13+
<custom xmlns="http://example.com/schema" />
14+
</sec:provider>
15+
16+
<sec:firewall name="main" provider="foo" />
17+
</sec:config>
18+
19+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:sec="http://symfony.com/schema/dic/security"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services
7+
https://symfony.com/schema/dic/services/services-1.0.xsd
8+
http://symfony.com/schema/dic/security
9+
https://symfony.com/schema/dic/security/security-1.0.xsd">
10+
11+
<sec:config>
12+
<sec:provider name="foo">
13+
<sec:custom />
14+
</sec:provider>
15+
16+
<sec:firewall name="main" provider="foo" />
17+
</sec:config>
18+
19+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\SecurityBundle\Tests\DependencyInjection;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
16+
use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\Authenticator\CustomAuthenticator;
17+
use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\CustomProvider;
18+
use Symfony\Component\Config\FileLocator;
19+
use Symfony\Component\DependencyInjection\ContainerBuilder;
20+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
21+
22+
class XmlCustomAuthenticatorTest extends TestCase
23+
{
24+
/**
25+
* @dataProvider provideXmlConfigurationFile
26+
*/
27+
public function testCustomProviderElement(string $configurationFile)
28+
{
29+
$container = new ContainerBuilder();
30+
$container->setParameter('kernel.debug', false);
31+
$container->register('cache.system', \stdClass::class);
32+
33+
$security = new SecurityExtension();
34+
$security->addAuthenticatorFactory(new CustomAuthenticator());
35+
$container->registerExtension($security);
36+
37+
(new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/xml')))->load($configurationFile);
38+
39+
$container->getCompilerPassConfig()->setRemovingPasses([]);
40+
$container->getCompilerPassConfig()->setAfterRemovingPasses([]);
41+
$container->compile();
42+
43+
$this->addToAssertionCount(1);
44+
}
45+
46+
public static function provideXmlConfigurationFile(): iterable
47+
{
48+
yield 'Custom authenticator element under SecurityBundle’s namespace' => ['custom_authenticator_under_security_namespace.xml'];
49+
yield 'Custom authenticator element under its own namespace' => ['custom_authenticator_under_own_namespace.xml'];
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\SecurityBundle\Tests\DependencyInjection;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
16+
use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\CustomProvider;
17+
use Symfony\Component\Config\FileLocator;
18+
use Symfony\Component\DependencyInjection\ContainerBuilder;
19+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
20+
21+
class XmlCustomProviderTest extends TestCase
22+
{
23+
/**
24+
* @dataProvider provideXmlConfigurationFile
25+
*/
26+
public function testCustomProviderElement(string $configurationFile)
27+
{
28+
$container = new ContainerBuilder();
29+
$container->setParameter('kernel.debug', false);
30+
$container->register('cache.system', \stdClass::class);
31+
32+
$security = new SecurityExtension();
33+
$security->addUserProviderFactory(new CustomProvider());
34+
$container->registerExtension($security);
35+
36+
(new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/xml')))->load($configurationFile);
37+
38+
$container->getCompilerPassConfig()->setRemovingPasses([]);
39+
$container->getCompilerPassConfig()->setAfterRemovingPasses([]);
40+
$container->compile();
41+
42+
$this->addToAssertionCount(1);
43+
}
44+
45+
public static function provideXmlConfigurationFile(): iterable
46+
{
47+
yield 'Custom provider element under SecurityBundle’s namespace' => ['custom_provider_under_security_namespace.xml'];
48+
yield 'Custom provider element under its own namespace' => ['custom_provider_under_own_namespace.xml'];
49+
}
50+
}

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"ext-xml": "*",
2222
"symfony/clock": "^6.4|^7.0",
2323
"symfony/config": "^6.4|^7.0",
24-
"symfony/dependency-injection": "^6.4|^7.0",
24+
"symfony/dependency-injection": "^6.4.11|^7.1.4",
2525
"symfony/event-dispatcher": "^6.4|^7.0",
2626
"symfony/http-kernel": "^6.4|^7.0",
2727
"symfony/http-foundation": "^6.4|^7.0",

0 commit comments

Comments
 (0)