From 9f3ea9116efcb559b7c8f6899d22c22b8a985235 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 28 Sep 2015 18:38:57 +0200 Subject: memberOf resembles a DN as well and is actively used Conflicts: apps/user_ldap/tests/access.php --- apps/user_ldap/lib/access.php | 4 +++- apps/user_ldap/tests/access.php | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index 483ca232277..81b09740f87 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -215,7 +215,9 @@ class Access extends LDAPUtility implements user\IUserTools { $resemblingAttributes = array( 'dn', 'uniquemember', - 'member' + 'member', + // memberOf is an "operational" attribute, without a definition in any RFC + 'memberof' ); return in_array($attr, $resemblingAttributes); } diff --git a/apps/user_ldap/tests/access.php b/apps/user_ldap/tests/access.php index 5c535720fec..74615ce287c 100644 --- a/apps/user_ldap/tests/access.php +++ b/apps/user_ldap/tests/access.php @@ -270,4 +270,38 @@ class Test_Access extends \Test\TestCase { $access->batchApplyUserAttributes($data); } + + public function dNAttributeProvider() { + // corresponds to Access::resemblesDN() + return array( + 'dn' => array('dn'), + 'uniqueMember' => array('uniquemember'), + 'member' => array('member'), + 'memberOf' => array('memberof') + ); + } + + /** + * @dataProvider dNAttributeProvider + */ + public function testSanitizeDN($attribute) { + list($lw, $con, $um) = $this->getConnecterAndLdapMock(); + + + $dnFromServer = 'cn=Mixed Cases,ou=Are Sufficient To,ou=Test,dc=example,dc=org'; + + $lw->expects($this->any()) + ->method('isResource') + ->will($this->returnValue(true)); + + $lw->expects($this->any()) + ->method('getAttributes') + ->will($this->returnValue(array( + $attribute => array('count' => 1, $dnFromServer) + ))); + + $access = new Access($con, $lw, $um); + $values = $access->readAttribute('uid=whoever,dc=example,dc=org', $attribute); + $this->assertSame($values[0], strtolower($dnFromServer)); + } } -- cgit v1.2.3 From 3bad2ac1e5961a453099714c10c46681c354234f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Wed, 28 Oct 2015 09:24:19 +0100 Subject: fixing typo --- apps/user_ldap/tests/access.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/user_ldap/tests/access.php b/apps/user_ldap/tests/access.php index 74615ce287c..c7246dcb035 100644 --- a/apps/user_ldap/tests/access.php +++ b/apps/user_ldap/tests/access.php @@ -285,8 +285,7 @@ class Test_Access extends \Test\TestCase { * @dataProvider dNAttributeProvider */ public function testSanitizeDN($attribute) { - list($lw, $con, $um) = $this->getConnecterAndLdapMock(); - + list($lw, $con, $um) = $this->getConnectorAndLdapMock(); $dnFromServer = 'cn=Mixed Cases,ou=Are Sufficient To,ou=Test,dc=example,dc=org'; -- cgit v1.2.3