diff options
author | Tobias Schultze <webmaster@tubo-world.de> | 2015-09-29 16:08:28 +0200 |
---|---|---|
committer | Tobias Schultze <webmaster@tubo-world.de> | 2015-09-29 16:08:28 +0200 |
commit | 493704bf17328063a6e566d912e6e063d4c60f8b (patch) | |
tree | 16e3cfaffcb041445478540434fd4e5be0b3eccc /Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php | |
parent | 16223cbf326eee2a9fff59f765c218ff028e9330 (diff) | |
parent | 889a989997c4b038fb4e354e57e35ede82370581 (diff) | |
download | symfony-security-493704bf17328063a6e566d912e6e063d4c60f8b.zip symfony-security-493704bf17328063a6e566d912e6e063d4c60f8b.tar.gz symfony-security-493704bf17328063a6e566d912e6e063d4c60f8b.tar.bz2 |
Merge branch '2.8'
Conflicts:
composer.json
src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php
src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml
src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml
src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php
src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php
src/Symfony/Component/ClassLoader/DebugClassLoader.php
src/Symfony/Component/ClassLoader/UniversalClassLoader.php
src/Symfony/Component/Console/Input/StringInput.php
src/Symfony/Component/Debug/DebugClassLoader.php
src/Symfony/Component/DependencyInjection/Container.php
src/Symfony/Component/DependencyInjection/ContainerBuilder.php
src/Symfony/Component/DependencyInjection/ContainerInterface.php
src/Symfony/Component/DependencyInjection/Definition.php
src/Symfony/Component/DependencyInjection/DefinitionDecorator.php
src/Symfony/Component/DependencyInjection/Scope.php
src/Symfony/Component/DependencyInjection/ScopeInterface.php
src/Symfony/Component/DomCrawler/composer.json
src/Symfony/Component/EventDispatcher/Event.php
src/Symfony/Component/HttpKernel/Kernel.php
src/Symfony/Component/HttpKernel/KernelInterface.php
src/Symfony/Component/HttpKernel/Log/LoggerInterface.php
src/Symfony/Component/HttpKernel/Log/NullLogger.php
src/Symfony/Component/Security/Core/composer.json
src/Symfony/Component/Security/Resources/translations/security.tr.xlf
src/Symfony/Component/Security/composer.json
src/Symfony/Component/Translation/Translator.php
Diffstat (limited to 'Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php')
-rw-r--r-- | Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php b/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php new file mode 100644 index 0000000..f1b5c03 --- /dev/null +++ b/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php @@ -0,0 +1,61 @@ +<?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\Authentication\Provider; + +use Symfony\Component\Security\Core\Authentication\Provider\LdapBindAuthenticationProvider; +use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; +use Symfony\Component\Security\Core\User\User; +use Symfony\Component\Ldap\Exception\ConnectionException; + +class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException + * @expectedExceptionMessage The presented password is invalid. + */ + public function testBindFailureShouldThrowAnException() + { + $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $ldap + ->expects($this->once()) + ->method('bind') + ->will($this->throwException(new ConnectionException())) + ; + $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + + $provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap); + $reflection = new \ReflectionMethod($provider, 'checkAuthentication'); + $reflection->setAccessible(true); + + $reflection->invoke($provider, new User('foo', null), new UsernamePasswordToken('foo', '', 'key')); + } + + public function testRetrieveUser() + { + $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + $userProvider + ->expects($this->once()) + ->method('loadUserByUsername') + ->with('foo') + ; + $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + + $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + + $provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap); + $reflection = new \ReflectionMethod($provider, 'retrieveUser'); + $reflection->setAccessible(true); + + $reflection->invoke($provider, 'foo', new UsernamePasswordToken('foo', 'bar', 'key')); + } +} |