summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/tests/access.php
diff options
context:
space:
mode:
authorblizzz <blizzz@owncloud.com>2014-08-18 19:24:41 +0200
committerblizzz <blizzz@owncloud.com>2014-08-18 19:24:41 +0200
commit8f7676c762ce4a6d2db852693060cd672b05121b (patch)
tree0ccc3c1a9681fd627d8bcdecfa85082266f9e88b /apps/user_ldap/tests/access.php
parenta820df71ee5832c5090a20589b2365904402a037 (diff)
parent97fd39e983645bf743f8abd5c05bfe619f859690 (diff)
downloadnextcloud-server-8f7676c762ce4a6d2db852693060cd672b05121b.tar.gz
nextcloud-server-8f7676c762ce4a6d2db852693060cd672b05121b.zip
Merge pull request #10340 from owncloud/fix-9887
better check whether string resembles a DN, fixes #9887
Diffstat (limited to 'apps/user_ldap/tests/access.php')
-rw-r--r--apps/user_ldap/tests/access.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/apps/user_ldap/tests/access.php b/apps/user_ldap/tests/access.php
index e77aad769d4..f436784675d 100644
--- a/apps/user_ldap/tests/access.php
+++ b/apps/user_ldap/tests/access.php
@@ -156,4 +156,61 @@ class Test_Access extends \PHPUnit_Framework_TestCase {
$this->assertSame($expected, $access->getDomainDNFromDN($inputDN));
}
+
+ private function getResemblesDNInputData() {
+ return $cases = array(
+ array(
+ 'input' => 'foo=bar,bar=foo,dc=foobar',
+ 'interResult' => array(
+ 'count' => 3,
+ 0 => 'foo=bar',
+ 1 => 'bar=foo',
+ 2 => 'dc=foobar'
+ ),
+ 'expectedResult' => true
+ ),
+ array(
+ 'input' => 'foobarbarfoodcfoobar',
+ 'interResult' => false,
+ 'expectedResult' => false
+ )
+ );
+ }
+
+ public function testStringResemblesDN() {
+ list($lw, $con, $um) = $this->getConnecterAndLdapMock();
+ $access = new Access($con, $lw, $um);
+
+ $cases = $this->getResemblesDNInputData();
+
+ $lw->expects($this->exactly(2))
+ ->method('explodeDN')
+ ->will($this->returnCallback(function ($dn) use ($cases) {
+ foreach($cases as $case) {
+ if($dn === $case['input']) {
+ return $case['interResult'];
+ }
+ }
+ }));
+
+ foreach($cases as $case) {
+ $this->assertSame($case['expectedResult'], $access->stringResemblesDN($case['input']));
+ }
+ }
+
+ public function testStringResemblesDNLDAPmod() {
+ list($lw, $con, $um) = $this->getConnecterAndLdapMock();
+ $lw = new \OCA\user_ldap\lib\LDAP();
+ $access = new Access($con, $lw, $um);
+
+ if(!function_exists('ldap_explode_dn')) {
+ $this->markTestSkipped('LDAP Module not available');
+ }
+
+ $cases = $this->getResemblesDNInputData();
+
+ foreach($cases as $case) {
+ $this->assertSame($case['expectedResult'], $access->stringResemblesDN($case['input']));
+ }
+ }
}