caches the displayname after an LDAP plugin set it
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
e432ead04d
commit
a1f2dbe29c
|
@ -506,7 +506,9 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
|
||||||
*/
|
*/
|
||||||
public function setDisplayName($uid, $displayName) {
|
public function setDisplayName($uid, $displayName) {
|
||||||
if ($this->userPluginManager->implementsActions(Backend::SET_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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1391,16 +1391,38 @@ class User_LDAPTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetDisplayNameWithPlugin() {
|
public function testSetDisplayNameWithPlugin() {
|
||||||
|
$newDisplayName = 'J. Baker';
|
||||||
$this->pluginManager->expects($this->once())
|
$this->pluginManager->expects($this->once())
|
||||||
->method('implementsActions')
|
->method('implementsActions')
|
||||||
->with(Backend::SET_DISPLAYNAME)
|
->with(Backend::SET_DISPLAYNAME)
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
$this->pluginManager->expects($this->once())
|
$this->pluginManager->expects($this->once())
|
||||||
->method('setDisplayName')
|
->method('setDisplayName')
|
||||||
->with('uid','displayName')
|
->with('uid', $newDisplayName)
|
||||||
->willReturn('result');
|
->willReturn($newDisplayName);
|
||||||
|
$this->access->expects($this->once())
|
||||||
|
->method('cacheUserDisplayName');
|
||||||
|
|
||||||
$this->assertEquals($this->backend->setDisplayName('uid', 'displayName'),'result');
|
$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->backend->setDisplayName('uid', $newDisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetDisplayNameFailing() {
|
public function testSetDisplayNameFailing() {
|
||||||
|
@ -1408,6 +1430,8 @@ class User_LDAPTest extends TestCase {
|
||||||
->method('implementsActions')
|
->method('implementsActions')
|
||||||
->with(Backend::SET_DISPLAYNAME)
|
->with(Backend::SET_DISPLAYNAME)
|
||||||
->willReturn(false);
|
->willReturn(false);
|
||||||
|
$this->access->expects($this->never())
|
||||||
|
->method('cacheUserDisplayName');
|
||||||
|
|
||||||
$this->assertFalse($this->backend->setDisplayName('uid', 'displayName'));
|
$this->assertFalse($this->backend->setDisplayName('uid', 'displayName'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue