[Pkg-owncloud-commits] [owncloud] 04/27: lowercase configured displayname attribute so isset works - all attribute names coming from ldap are lowercased for easy comparison

David Prévot taffit at moszumanska.debian.org
Wed Oct 28 17:03:04 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v8.1.4RC2
in repository owncloud.

commit 7ccd52db253ad6909092e87e89a17d8c078e01f4
Author: Arthur Schiwon <blizzz at owncloud.com>
Date:   Thu Oct 1 17:54:40 2015 +0200

    lowercase configured displayname attribute so isset works - all attribute names coming from ldap are lowercased for easy comparison
---
 apps/user_ldap/lib/access.php   |  6 ++++--
 apps/user_ldap/tests/access.php | 16 +++++++++++++---
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index 4890563..c1c6a8f 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -679,12 +679,14 @@ class Access extends LDAPUtility implements user\IUserTools {
 	 * @param array $ldapRecords
 	 */
 	public function batchApplyUserAttributes(array $ldapRecords){
+		$displayNameAttribute = strtolower($this->connection->ldapUserDisplayName);
 		foreach($ldapRecords as $userRecord) {
-			if(!isset($userRecord[$this->connection->ldapUserDisplayName])) {
+			if(!isset($userRecord[$displayNameAttribute])) {
 				// displayName is obligatory
 				continue;
 			}
-			$ocName  = $this->dn2ocname($userRecord['dn'], $userRecord[$this->connection->ldapUserDisplayName]);
+
+			$ocName  = $this->dn2ocname($userRecord['dn'], $userRecord[$displayNameAttribute]);
 			if(!$ocName) {
 				// no user name, skip.
 				continue;
diff --git a/apps/user_ldap/tests/access.php b/apps/user_ldap/tests/access.php
index 5bf1a65..5c53572 100644
--- a/apps/user_ldap/tests/access.php
+++ b/apps/user_ldap/tests/access.php
@@ -230,24 +230,34 @@ class Test_Access extends \Test\TestCase {
 		$mapperMock = $this->getMockBuilder('\OCA\User_LDAP\Mapping\UserMapping')
 			->disableOriginalConstructor()
 			->getMock();
+
+		$mapperMock->expects($this->any())
+			->method('getNameByDN')
+			->will($this->returnValue('a_username'));
+
 		$userMock = $this->getMockBuilder('\OCA\user_ldap\lib\user\User')
 			->disableOriginalConstructor()
 			->getMock();
 
+		$access->connection->expects($this->any())
+			->method('__get')
+			->will($this->returnValue('displayName'));
+
 		$access->setUserMapper($mapperMock);
 
+		$displayNameAttribute = strtolower($access->connection->ldapUserDisplayName);
 		$data = array(
 			array(
 				'dn' => 'foobar',
-				$con->ldapUserDisplayName => 'barfoo'
+				$displayNameAttribute => 'barfoo'
 			),
 			array(
 				'dn' => 'foo',
-				$con->ldapUserDisplayName => 'bar'
+				$displayNameAttribute => 'bar'
 			),
 			array(
 				'dn' => 'raboof',
-				$con->ldapUserDisplayName => 'oofrab'
+				$displayNameAttribute => 'oofrab'
 			)
 		);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list