21
21
*/
22
22
class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
23
23
{
24
+ /**
25
+ * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
26
+ * @expectedExceptionMessage The presented password must not be empty.
27
+ */
28
+ public function testEmptyPasswordShouldThrowAnException ()
29
+ {
30
+ $ userProvider = $ this ->getMock ('Symfony\Component\Security\Core\User\UserProviderInterface ' );
31
+ $ ldap = $ this ->getMock ('Symfony\Component\Ldap\LdapClientInterface ' );
32
+ $ userChecker = $ this ->getMock ('Symfony\Component\Security\Core\User\UserCheckerInterface ' );
33
+
34
+ $ provider = new LdapBindAuthenticationProvider ($ userProvider , $ userChecker , 'key ' , $ ldap );
35
+ $ reflection = new \ReflectionMethod ($ provider , 'checkAuthentication ' );
36
+ $ reflection ->setAccessible (true );
37
+
38
+ $ reflection ->invoke ($ provider , new User ('foo ' , null ), new UsernamePasswordToken ('foo ' , '' , 'key ' ));
39
+ }
40
+
24
41
/**
25
42
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
26
43
* @expectedExceptionMessage The presented password is invalid.
@@ -40,7 +57,7 @@ public function testBindFailureShouldThrowAnException()
40
57
$ reflection = new \ReflectionMethod ($ provider , 'checkAuthentication ' );
41
58
$ reflection ->setAccessible (true );
42
59
43
- $ reflection ->invoke ($ provider , new User ('foo ' , null ), new UsernamePasswordToken ('foo ' , '' , 'key ' ));
60
+ $ reflection ->invoke ($ provider , new User ('foo ' , null ), new UsernamePasswordToken ('foo ' , 'bar ' , 'key ' ));
44
61
}
45
62
46
63
public function testRetrieveUser ()
0 commit comments