From 9f480905454a04b34075012cd01d91441d1e37d0 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 26 Jun 2019 14:18:28 +0200 Subject: [PATCH] invalidates user when plugin reported deletion success Signed-off-by: Arthur Schiwon --- apps/user_ldap/lib/User_LDAP.php | 9 ++++++--- apps/user_ldap/tests/User_LDAPTest.php | 22 ++++++++++++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index ada07aa53a..a2b5c99a1c 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -382,18 +382,21 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn */ public function deleteUser($uid) { if ($this->userPluginManager->canDeleteUser()) { - return $this->userPluginManager->deleteUser($uid); + $status = $this->userPluginManager->deleteUser($uid); + if($status === false) { + return false; + } } $marked = $this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0); if((int)$marked === 0) { \OC::$server->getLogger()->notice( 'User '.$uid . ' is not marked as deleted, not cleaning up.', - array('app' => 'user_ldap')); + ['app' => 'user_ldap']); return false; } \OC::$server->getLogger()->info('Cleaning up after user ' . $uid, - array('app' => 'user_ldap')); + ['app' => 'user_ldap']); $this->access->getUserMapper()->unmap($uid); // we don't emit unassign signals here, since it is implicit to delete signals fired from core $this->access->userManager->invalidate($uid); diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index e4f7bb8b6d..b89d6816c5 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -342,9 +342,27 @@ class User_LDAPTest extends TestCase { $this->pluginManager->expects($this->once()) ->method('deleteUser') ->with('uid') - ->willReturn('result'); + ->willReturn(true); - $this->assertEquals($this->backend->deleteUser('uid'),'result'); + $this->config->expects($this->once()) + ->method('getUserValue') + ->with('uid', 'user_ldap', 'isDeleted', 0) + ->willReturn(1); + + $mapper = $this->createMock(UserMapping::class); + $mapper->expects($this->once()) + ->method('unmap') + ->with('uid'); + + $this->access->expects($this->atLeastOnce()) + ->method('getUserMapper') + ->willReturn($mapper); + + $this->userManager->expects($this->once()) + ->method('invalidate') + ->with('uid'); + + $this->assertEquals(true, $this->backend->deleteUser('uid')); } /**