]> source.dussan.org Git - nextcloud-server.git/commitdiff
caches the displayname after an LDAP plugin set it 15987/head
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Mon, 17 Jun 2019 22:20:09 +0000 (00:20 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Tue, 18 Jun 2019 10:42:03 +0000 (12:42 +0200)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
apps/user_ldap/lib/User_LDAP.php
apps/user_ldap/tests/User_LDAPTest.php

index cdbc2e9b35002645c7ec644ed13024ab72ca95bb..ada07aa53a9c3a3067af37bf1b28e846210759a4 100644 (file)
@@ -506,7 +506,9 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
         */
        public function setDisplayName($uid, $displayName) {
                if ($this->userPluginManager->implementsActions(Backend::SET_DISPLAYNAME)) {
-                       return $this->userPluginManager->setDisplayName($uid, $displayName);
+                       $this->userPluginManager->setDisplayName($uid, $displayName);
+                       $this->access->cacheUserDisplayName($uid, $displayName);
+                       return $displayName;
                }
                return false;
        }
index f58c5f881f941f799a200a3c406af6627e3c1c14..e4f7bb8b6d29c5776a8182c1fc46677384a325b3 100644 (file)
@@ -1391,16 +1391,38 @@ class User_LDAPTest extends TestCase {
        }
 
        public function testSetDisplayNameWithPlugin() {
+               $newDisplayName = 'J. Baker';
                $this->pluginManager->expects($this->once())
                        ->method('implementsActions')
                        ->with(Backend::SET_DISPLAYNAME)
                        ->willReturn(true);
                $this->pluginManager->expects($this->once())
                        ->method('setDisplayName')
-                       ->with('uid','displayName')
-                       ->willReturn('result');
+                       ->with('uid', $newDisplayName)
+                       ->willReturn($newDisplayName);
+               $this->access->expects($this->once())
+                       ->method('cacheUserDisplayName');
+
+               $this->assertEquals($newDisplayName, $this->backend->setDisplayName('uid', $newDisplayName));
+       }
+
+       /**
+        * @expectedException \OC\HintException
+        */
+       public function testSetDisplayNameErrorWithPlugin() {
+               $newDisplayName = 'J. Baker';
+               $this->pluginManager->expects($this->once())
+                       ->method('implementsActions')
+                       ->with(Backend::SET_DISPLAYNAME)
+                       ->willReturn(true);
+               $this->pluginManager->expects($this->once())
+                       ->method('setDisplayName')
+                       ->with('uid', $newDisplayName)
+                       ->willThrowException(new HintException('something happned'));
+               $this->access->expects($this->never())
+                       ->method('cacheUserDisplayName');
 
-               $this->assertEquals($this->backend->setDisplayName('uid', 'displayName'),'result');
+               $this->backend->setDisplayName('uid', $newDisplayName);
        }
 
        public function testSetDisplayNameFailing() {
@@ -1408,6 +1430,8 @@ class User_LDAPTest extends TestCase {
                        ->method('implementsActions')
                        ->with(Backend::SET_DISPLAYNAME)
                        ->willReturn(false);
+               $this->access->expects($this->never())
+                       ->method('cacheUserDisplayName');
 
                $this->assertFalse($this->backend->setDisplayName('uid', 'displayName'));
        }