]> source.dussan.org Git - nextcloud-server.git/commitdiff
invalidates user when plugin reported deletion success
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Wed, 26 Jun 2019 12:18:28 +0000 (14:18 +0200)
committerBackportbot <backportbot-noreply@rullzer.com>
Thu, 27 Jun 2019 10:22:32 +0000 (10:22 +0000)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
apps/user_ldap/lib/User_LDAP.php
apps/user_ldap/tests/User_LDAPTest.php

index 8e5a4fe8e369aca5553d90d58c3d5c2727f651f4..60ade85a0e4bf8e8c5565189f047fc76f35e3ba5 100644 (file)
@@ -384,18 +384,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);
index e4f7bb8b6d29c5776a8182c1fc46677384a325b3..b89d6816c5a6d8c7946381535b4c1346138f7499 100644 (file)
@@ -342,9 +342,27 @@ class User_LDAPTest extends TestCase {
                $this->pluginManager->expects($this->once())
                        ->method('deleteUser')
                        ->with('uid')
-                       ->willReturn('result');
+                       ->willReturn(true);
+
+               $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($this->backend->deleteUser('uid'),'result');
+               $this->assertEquals(true, $this->backend->deleteUser('uid'));
        }
 
        /**