Merge branch '2.3' into 2.5

* 2.3:
  [SecurityBundle] Firewall providers building - code cleaning
  [Filesystem] symlink use RealPath instead LinkTarget
  Fixed the AuthenticationProviderInterface alignment
  Fixed the proxy-manager version constraint

Conflicts:
	composer.json
	src/Symfony/Bridge/ProxyManager/composer.json
This commit is contained in:
Nicolas Grekas 2014-12-12 16:58:22 +01:00
commit 76c35089c5
7 changed files with 84 additions and 30 deletions

View File

@ -72,7 +72,7 @@
"monolog/monolog": "~1.3",
"propel/propel1": "~1.6",
"ircmaxell/password-compat": "~1.0",
"ocramius/proxy-manager": ">=0.3.1,<0.6-dev",
"ocramius/proxy-manager": "~0.3.1",
"egulias/email-validator": "~1.2"
},
"autoload": {

View File

@ -18,7 +18,7 @@
"require": {
"php": ">=5.3.3",
"symfony/dependency-injection": "~2.3",
"ocramius/proxy-manager": ">=0.3.1,<0.6-dev"
"ocramius/proxy-manager": "~0.3.1"
},
"require-dev": {
"symfony/config": "~2.3"

View File

@ -511,6 +511,7 @@ class SecurityExtension extends Extension
{
$name = $this->getUserProviderId(strtolower($name));
// Doctrine Entity and In-memory DAO provider are managed by factories
foreach ($this->userProviderFactories as $factory) {
$key = str_replace('-', '_', $factory->getKey());
@ -537,37 +538,12 @@ class SecurityExtension extends Extension
$container
->setDefinition($name, new DefinitionDecorator('security.user.provider.chain'))
->addArgument($providers)
;
->addArgument($providers);
return $name;
}
// Doctrine Entity DAO provider
if (isset($provider['entity'])) {
$container
->setDefinition($name, new DefinitionDecorator('security.user.provider.entity'))
->addArgument($provider['entity']['class'])
->addArgument($provider['entity']['property'])
;
return $name;
}
// In-memory DAO provider
$definition = $container->setDefinition($name, new DefinitionDecorator('security.user.provider.in_memory'));
foreach ($provider['users'] as $username => $user) {
$userId = $name.'_'.$username;
$container
->setDefinition($userId, new DefinitionDecorator('security.user.provider.in_memory.user'))
->setArguments(array($username, (string) $user['password'], $user['roles']))
;
$definition->addMethodCall('createUser', array(new Reference($userId)));
}
return $name;
throw new InvalidConfigurationException(sprintf('Unable to create definition for "%s" user provider', $name));
}
private function getUserProviderId($name)

View File

@ -0,0 +1,25 @@
<?php
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class DummyProvider implements UserProviderFactoryInterface
{
public function create(ContainerBuilder $container, $id, $config)
{
}
public function getKey()
{
return 'foo';
}
public function addConfiguration(NodeDefinition $node)
{
}
}

View File

@ -13,6 +13,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\DummyProvider;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class SecurityExtensionTest extends \PHPUnit_Framework_TestCase
@ -66,6 +67,33 @@ class SecurityExtensionTest extends \PHPUnit_Framework_TestCase
$container->compile();
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage Unable to create definition for "security.user.provider.concrete.my_foo" user provider
*/
public function testFirewallWithInvalidUserProvider()
{
$container = $this->getRawContainer();
$extension = $container->getExtension('security');
$extension->addUserProviderFactory(new DummyProvider());
$container->loadFromExtension('security', array(
'providers' => array(
'my_foo' => array('foo' => []),
),
'firewalls' => array(
'some_firewall' => array(
'pattern' => '/.*',
'http_basic' => [],
),
),
));
$container->compile();
}
protected function getRawContainer()
{
$container = new ContainerBuilder();

View File

@ -408,7 +408,7 @@ class Filesystem
}
} else {
if (is_link($file)) {
$this->symlink($file->getLinkTarget(), $target);
$this->symlink($file->getRealPath(), $target);
} elseif (is_dir($file)) {
$this->mkdir($target);
} elseif (is_file($file)) {

View File

@ -853,6 +853,31 @@ class FilesystemTest extends FilesystemTestCase
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
}
public function testMirrorCopiesRelativeLinkedContents()
{
$this->markAsSkippedIfSymlinkIsMissing();
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
$oldPath = getcwd();
mkdir($sourcePath.'nested/', 0777, true);
file_put_contents($sourcePath.'/nested/file1.txt', 'FILE1');
// Note: Create relative symlink
chdir($sourcePath);
symlink('nested', 'link1');
chdir($oldPath);
$targetPath = $this->workspace.DIRECTORY_SEPARATOR.'target'.DIRECTORY_SEPARATOR;
$this->filesystem->mirror($sourcePath, $targetPath);
$this->assertTrue(is_dir($targetPath));
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.DIRECTORY_SEPARATOR.'link1/file1.txt');
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
$this->assertEquals($sourcePath.'nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1'));
}
/**
* @dataProvider providePathsForIsAbsolutePath
*/