diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2019-06-19 08:08:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-19 08:08:17 +0200 |
commit | 18f48bba1cf332cc91952f4ceb486436a5f639e0 (patch) | |
tree | 4eb36f4f44bff38891861fde999f03013fa45d06 | |
parent | df6f8e4cc190b49bd288a9ceb37e567a1d0aa2cc (diff) | |
parent | c765c3cdfcabfae902a76dc5429711cf8bc4a019 (diff) | |
download | nextcloud-server-18f48bba1cf332cc91952f4ceb486436a5f639e0.tar.gz nextcloud-server-18f48bba1cf332cc91952f4ceb486436a5f639e0.zip |
[stable15] cache the displayname after an LDAP plugin set it (#16001)
[stable15] cache the displayname after an LDAP plugin set it
-rw-r--r-- | apps/user_ldap/lib/User_LDAP.php | 4 | ||||
-rw-r--r-- | apps/user_ldap/tests/User_LDAPTest.php | 30 |
2 files changed, 30 insertions, 4 deletions
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index e69eafecc86..8e5a4fe8e36 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -508,7 +508,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; } diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index f58c5f881f9..e4f7bb8b6d2 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -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')); } |