diff options
author | Nicolas Grekas <nicolas.grekas@gmail.com> | 2016-06-03 13:14:11 +0200 |
---|---|---|
committer | Nicolas Grekas <nicolas.grekas@gmail.com> | 2016-06-03 13:14:11 +0200 |
commit | 1317cb34f89cbaeba6c7325bf8e7c0935797e6dc (patch) | |
tree | c2df1eb5415797bd0c3fa63d893cbd55ec533dfd | |
parent | 421e01d2175d255f693d63fae3a53e704f963510 (diff) | |
parent | 3f02527e0892c745e2dfed23e790bade7b058084 (diff) | |
download | symfony-security-1317cb34f89cbaeba6c7325bf8e7c0935797e6dc.zip symfony-security-1317cb34f89cbaeba6c7325bf8e7c0935797e6dc.tar.gz symfony-security-1317cb34f89cbaeba6c7325bf8e7c0935797e6dc.tar.bz2 |
Merge branch '3.1'
* 3.1:
[travis] Don't use parallel on HHVM
[HttpKernel] Fix RequestDataCollector starting the session
[appveyor] Ignore STATUS_HEAP_CORRUPTION errors on Windows
[FrameworkBundle] Skip redis cache pools test on failed connection
Fixed forwarded request data in templates
[Security] Fix DebugAccessDecisionManager when object is not a scalar
Skip some tests on HHVM due to a PHPunit bug
Use the Trusty Travis infrastructure for HHVM builds
LdapUserProvider: add missing argument type doc
Fixed issue with missing argument in the abstract service definition for the ldap user provider
Add 3.1 to PR template branch row, remove 2.3
Improve memory efficiency
[Console] Fix BC break introduced by #18101
document method name changes in Voter class
add missing hint for vote() argument type
[#18838] add a test to avoid regressions
bumped Symfony version to 3.1.1
updated VERSION for 3.1.0
updated CHANGELOG for 3.1.0
Conflicts:
src/Symfony/Component/HttpKernel/Kernel.php
-rw-r--r-- | Core/Authorization/DebugAccessDecisionManager.php | 9 | ||||
-rw-r--r-- | Core/Tests/Authorization/DebugAccessDecisionManagerTest.php | 43 | ||||
-rw-r--r-- | Core/User/LdapUserProvider.php | 1 |
3 files changed, 52 insertions, 1 deletions
diff --git a/Core/Authorization/DebugAccessDecisionManager.php b/Core/Authorization/DebugAccessDecisionManager.php index 7c0cfc9..540d998 100644 --- a/Core/Authorization/DebugAccessDecisionManager.php +++ b/Core/Authorization/DebugAccessDecisionManager.php @@ -103,7 +103,14 @@ class DebugAccessDecisionManager implements AccessDecisionManagerInterface } if (!is_object($object)) { - return sprintf('%s (%s)', gettype($object), $object); + if (is_bool($object)) { + return sprintf('%s (%s)', gettype($object), $object ? 'true' : 'false'); + } + if (is_scalar($object)) { + return sprintf('%s (%s)', gettype($object), $object); + } + + return gettype($object); } $objectClass = class_exists('Doctrine\Common\Util\ClassUtils') ? ClassUtils::getClass($object) : get_class($object); diff --git a/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php b/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php new file mode 100644 index 0000000..f90f776 --- /dev/null +++ b/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php @@ -0,0 +1,43 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Core\Tests\Authorization; + +use Symfony\Component\Security\Core\Authorization\AccessDecisionManager; +use Symfony\Component\Security\Core\Authorization\DebugAccessDecisionManager; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + +class DebugAccessDecisionManagerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider provideObjectsAndLogs + */ + public function testDecideLog($expectedLog, $object) + { + $adm = new DebugAccessDecisionManager(new AccessDecisionManager()); + $adm->decide($this->getMock(TokenInterface::class), array('ATTRIBUTE_1'), $object); + + $this->assertSame($expectedLog, $adm->getDecisionLog()); + } + + public function provideObjectsAndLogs() + { + $object = new \stdClass(); + + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'NULL', 'result' => false)), null); + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'boolean (true)', 'result' => false)), true); + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'string (jolie string)', 'result' => false)), 'jolie string'); + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'integer (12345)', 'result' => false)), 12345); + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'resource', 'result' => false)), fopen(__FILE__, 'r')); + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'array', 'result' => false)), array()); + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => sprintf('stdClass (object hash: %s)', spl_object_hash($object)), 'result' => false)), $object); + } +} diff --git a/Core/User/LdapUserProvider.php b/Core/User/LdapUserProvider.php index e722c98..5eb7668 100644 --- a/Core/User/LdapUserProvider.php +++ b/Core/User/LdapUserProvider.php @@ -42,6 +42,7 @@ class LdapUserProvider implements UserProviderInterface * @param array $defaultRoles * @param string $uidKey * @param string $filter + * @param string $passwordAttribute */ public function __construct(LdapInterface $ldap, $baseDn, $searchDn = null, $searchPassword = null, array $defaultRoles = array(), $uidKey = 'sAMAccountName', $filter = '({uid_key}={username})', $passwordAttribute = null) { |