summaryrefslogtreecommitdiff
path: root/tests/units/Auth
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-10-11 14:44:16 -0400
committerFrederic Guillot <fred@kanboard.net>2015-10-11 14:44:16 -0400
commitdc0749ecce232a5a68d83fbde965ee4ee8e36d00 (patch)
tree9d9b3aa1ef09470553f1469f409803297e138b80 /tests/units/Auth
parentcf6d4d1c0a04b5816865818b9b6ab121071b870f (diff)
Improve LDAP auth
Diffstat (limited to 'tests/units/Auth')
-rw-r--r--tests/units/Auth/LdapTest.php33
1 files changed, 26 insertions, 7 deletions
diff --git a/tests/units/Auth/LdapTest.php b/tests/units/Auth/LdapTest.php
index a52b8cf8..6edd42fc 100644
--- a/tests/units/Auth/LdapTest.php
+++ b/tests/units/Auth/LdapTest.php
@@ -116,7 +116,16 @@ class LdapTest extends \Base
public function testBindAnonymous()
{
- $ldap = new Ldap($this->container);
+ $ldap = $this
+ ->getMockBuilder('\Auth\Ldap')
+ ->setConstructorArgs(array($this->container))
+ ->setMethods(array('getLdapBindType'))
+ ->getMock();
+
+ $ldap
+ ->expects($this->any())
+ ->method('getLdapBindType')
+ ->will($this->returnValue('anonymous'));
self::$functions
->expects($this->once())
@@ -128,7 +137,7 @@ class LdapTest extends \Base
)
->will($this->returnValue(true));
- $this->assertTrue($ldap->bind('my_ldap_connection', 'my_user', 'my_password', 'anonymous'));
+ $this->assertTrue($ldap->bind('my_ldap_connection', 'my_user', 'my_password'));
}
public function testBindUser()
@@ -136,14 +145,19 @@ class LdapTest extends \Base
$ldap = $this
->getMockBuilder('\Auth\Ldap')
->setConstructorArgs(array($this->container))
- ->setMethods(array('getLdapUserPattern'))
+ ->setMethods(array('getLdapUsername', 'getLdapBindType'))
->getMock();
$ldap
->expects($this->once())
- ->method('getLdapUserPattern')
+ ->method('getLdapUsername')
->will($this->returnValue('uid=my_user'));
+ $ldap
+ ->expects($this->any())
+ ->method('getLdapBindType')
+ ->will($this->returnValue('user'));
+
self::$functions
->expects($this->once())
->method('ldap_bind')
@@ -154,7 +168,7 @@ class LdapTest extends \Base
)
->will($this->returnValue(true));
- $this->assertTrue($ldap->bind('my_ldap_connection', 'my_user', 'my_password', 'user'));
+ $this->assertTrue($ldap->bind('my_ldap_connection', 'my_user', 'my_password'));
}
public function testBindProxy()
@@ -162,7 +176,7 @@ class LdapTest extends \Base
$ldap = $this
->getMockBuilder('\Auth\Ldap')
->setConstructorArgs(array($this->container))
- ->setMethods(array('getLdapUsername', 'getLdapPassword'))
+ ->setMethods(array('getLdapUsername', 'getLdapPassword', 'getLdapBindType'))
->getMock();
$ldap
@@ -175,6 +189,11 @@ class LdapTest extends \Base
->method('getLdapPassword')
->will($this->returnValue('something'));
+ $ldap
+ ->expects($this->any())
+ ->method('getLdapBindType')
+ ->will($this->returnValue('proxy'));
+
self::$functions
->expects($this->once())
->method('ldap_bind')
@@ -185,7 +204,7 @@ class LdapTest extends \Base
)
->will($this->returnValue(true));
- $this->assertTrue($ldap->bind('my_ldap_connection', 'my_user', 'my_password', 'proxy'));
+ $this->assertTrue($ldap->bind('my_ldap_connection', 'my_user', 'my_password'));
}
public function testSearchSuccess()