]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use DI for DeletedUsersIndex and fix tests
authorCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 25 May 2023 10:18:28 +0000 (12:18 +0200)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 25 May 2023 10:18:28 +0000 (12:18 +0200)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/user_ldap/lib/User_LDAP.php
apps/user_ldap/lib/User_Proxy.php
apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php
apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php
apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php
apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php
apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserCleanUp.php
apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php
apps/user_ldap/tests/User_LDAPTest.php

index 61abb1627f95c943d3f9c30a6895b70f7478ed91..fcd5a009e413e86be2d380294658db3583dda4a4 100644 (file)
@@ -56,33 +56,27 @@ use OCP\UserInterface;
 use Psr\Log\LoggerInterface;
 
 class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, IUserLDAP, ICountUsersBackend, ICountMappedUsersBackend, IProvideEnabledStateBackend {
-       /** @var \OCP\IConfig */
-       protected $ocConfig;
-
-       /** @var INotificationManager */
-       protected $notificationManager;
-
-       /** @var UserPluginManager */
-       protected $userPluginManager;
-
-       /** @var LoggerInterface */
-       protected $logger;
-
+       protected IConfig $ocConfig;
+       protected INotificationManager $notificationManager;
+       protected UserPluginManager $userPluginManager;
+       protected LoggerInterface $logger;
        protected DeletedUsersIndex $deletedUsersIndex;
 
-       /**
-        * @param Access $access
-        * @param \OCP\IConfig $ocConfig
-        * @param \OCP\Notification\IManager $notificationManager
-        * @param IUserSession $userSession
-        */
-       public function __construct(Access $access, IConfig $ocConfig, INotificationManager $notificationManager, IUserSession $userSession, UserPluginManager $userPluginManager) {
+       public function __construct(
+               Access $access,
+               IConfig $ocConfig,
+               INotificationManager $notificationManager,
+               IUserSession $userSession,
+               UserPluginManager $userPluginManager,
+               LoggerInterface $logger,
+               DeletedUsersIndex $deletedUsersIndex,
+       ) {
                parent::__construct($access);
                $this->ocConfig = $ocConfig;
                $this->notificationManager = $notificationManager;
                $this->userPluginManager = $userPluginManager;
-               $this->logger = \OC::$server->get(LoggerInterface::class);
-               $this->deletedUsersIndex = \OC::$server->get(DeletedUsersIndex::class);
+               $this->logger = $logger;
+               $this->deletedUsersIndex = $deletedUsersIndex;
        }
 
        /**
index 59f72c2c2f3b9371540775d6d12237e39752653f..c95329cebed60ce7b49584fecb5ee8d78f83b9f3 100644 (file)
@@ -31,6 +31,7 @@
  */
 namespace OCA\User_LDAP;
 
+use OCA\User_LDAP\User\DeletedUsersIndex;
 use OCA\User_LDAP\User\User;
 use OCP\IConfig;
 use OCP\IUserBackend;
@@ -40,6 +41,7 @@ use OCP\UserInterface;
 use OCP\User\Backend\ICountMappedUsersBackend;
 use OCP\User\Backend\ICountUsersBackend;
 use OCP\User\Backend\IProvideEnabledStateBackend;
+use Psr\Log\LoggerInterface;
 
 class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP, ICountUsersBackend, ICountMappedUsersBackend, IProvideEnabledStateBackend {
        /** @var User_LDAP[] */
@@ -52,6 +54,8 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP
        private INotificationManager $notificationManager;
        private IUserSession $userSession;
        private UserPluginManager $userPluginManager;
+       private LoggerInterface $logger;
+       private DeletedUsersIndex $deletedUsersIndex;
 
        public function __construct(
                Helper $helper,
@@ -60,7 +64,9 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP
                IConfig $ocConfig,
                INotificationManager $notificationManager,
                IUserSession $userSession,
-               UserPluginManager $userPluginManager
+               UserPluginManager $userPluginManager,
+               LoggerInterface $logger,
+               DeletedUsersIndex $deletedUsersIndex,
        ) {
                parent::__construct($ldap, $accessFactory);
                $this->helper = $helper;
@@ -68,6 +74,8 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP
                $this->notificationManager = $notificationManager;
                $this->userSession = $userSession;
                $this->userPluginManager = $userPluginManager;
+               $this->logger = $logger;
+               $this->deletedUsersIndex = $deletedUsersIndex;
        }
 
        protected function setup(): void {
@@ -77,8 +85,15 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP
 
                $serverConfigPrefixes = $this->helper->getServerConfigurationPrefixes(true);
                foreach ($serverConfigPrefixes as $configPrefix) {
-                       $this->backends[$configPrefix] =
-                               new User_LDAP($this->getAccess($configPrefix), $this->ocConfig, $this->notificationManager, $this->userSession, $this->userPluginManager);
+                       $this->backends[$configPrefix] = new User_LDAP(
+                               $this->getAccess($configPrefix),
+                               $this->ocConfig,
+                               $this->notificationManager,
+                               $this->userSession,
+                               $this->userPluginManager,
+                               $this->logger,
+                               $this->deletedUsersIndex,
+                       );
 
                        if (is_null($this->refBackend)) {
                                $this->refBackend = &$this->backends[$configPrefix];
index eb70c774e2573a5ba395d3ceffd2d5f1e31a25d3..a742c0b80764bd7bf1fe7f4fbce3671b9ffbdd46 100644 (file)
@@ -28,8 +28,10 @@ use OCA\User_LDAP\GroupPluginManager;
 use OCA\User_LDAP\Mapping\GroupMapping;
 use OCA\User_LDAP\Mapping\UserMapping;
 use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
+use OCA\User_LDAP\User\DeletedUsersIndex;
 use OCA\User_LDAP\User_LDAP;
 use OCA\User_LDAP\UserPluginManager;
+use Psr\Log\LoggerInterface;
 
 require_once __DIR__ . '/../Bootstrap.php';
 
@@ -51,7 +53,7 @@ class IntegrationTestAttributeDetection extends AbstractIntegrationTest {
                $groupMapper->clear();
                $this->access->setGroupMapper($groupMapper);
 
-               $userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->query(UserPluginManager::class));
+               $userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class));
                $userManager = \OC::$server->getUserManager();
                $userManager->clearBackends();
                $userManager->registerBackend($userBackend);
index 36c8ab4c0d30721d5bc564f3321097f2c4c13549..7b8f9fda754d03e3111df6faae0bd2066948cf60 100644 (file)
@@ -26,8 +26,10 @@ namespace OCA\User_LDAP\Tests\Integration\Lib;
 
 use OCA\User_LDAP\Mapping\UserMapping;
 use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
+use OCA\User_LDAP\User\DeletedUsersIndex;
 use OCA\User_LDAP\User_LDAP;
 use OCA\User_LDAP\UserPluginManager;
+use Psr\Log\LoggerInterface;
 
 require_once __DIR__ . '/../Bootstrap.php';
 
@@ -49,7 +51,7 @@ class IntegrationTestFetchUsersByLoginName extends AbstractIntegrationTest {
                $this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
                $this->mapping->clear();
                $this->access->setUserMapper($this->mapping);
-               $this->backend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->query(UserPluginManager::class));
+               $this->backend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class));
        }
 
        /**
index b941fa6fc669b6da777b9a2cb3c3b7cb1aa47782..6b272d3ad3ce53fb80faff71bb5ba3997501e4eb 100644 (file)
@@ -27,8 +27,10 @@ namespace OCA\User_LDAP\Tests\Integration\Lib;
 
 use OCA\User_LDAP\Mapping\UserMapping;
 use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
+use OCA\User_LDAP\User\DeletedUsersIndex;
 use OCA\User_LDAP\User_LDAP;
 use OCA\User_LDAP\UserPluginManager;
+use Psr\Log\LoggerInterface;
 
 require_once __DIR__ . '/../Bootstrap.php';
 
@@ -50,7 +52,7 @@ class IntegrationTestPaging extends AbstractIntegrationTest {
                require(__DIR__ . '/../setup-scripts/createExplicitUsers.php');
                parent::init();
 
-               $this->backend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->query(UserPluginManager::class));
+               $this->backend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class));
        }
 
        public function initConnection() {
index ec1cebbe08721797ac8eb7e618ec18d1c11e380a..c5b7f73bbcc0d3b5792411dec70253a794fb325c 100644 (file)
@@ -30,6 +30,7 @@ namespace OCA\User_LDAP\Tests\Integration\Lib\User;
 use OCA\User_LDAP\FilesystemHelper;
 use OCA\User_LDAP\Mapping\UserMapping;
 use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
+use OCA\User_LDAP\User\DeletedUsersIndex;
 use OCA\User_LDAP\User\Manager;
 use OCA\User_LDAP\User\User;
 use OCA\User_LDAP\User_LDAP;
@@ -53,7 +54,7 @@ class IntegrationTestUserAvatar extends AbstractIntegrationTest {
                $this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
                $this->mapping->clear();
                $this->access->setUserMapper($this->mapping);
-               $userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->query(UserPluginManager::class));
+               $userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class));
                \OC_User::useBackend($userBackend);
        }
 
index 5da672d8a553ce0caeace682c9c2ced3b3b1c14f..623d08d565da14aa80b29f4c36a97fef6e16f306 100644 (file)
@@ -26,8 +26,10 @@ namespace OCA\User_LDAP\Tests\Integration\Lib\User;
 use OCA\User_LDAP\Jobs\CleanUp;
 use OCA\User_LDAP\Mapping\UserMapping;
 use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
+use OCA\User_LDAP\User\DeletedUsersIndex;
 use OCA\User_LDAP\User_LDAP;
 use OCA\User_LDAP\UserPluginManager;
+use Psr\Log\LoggerInterface;
 
 require_once __DIR__ . '/../../Bootstrap.php';
 
@@ -46,7 +48,7 @@ class IntegrationTestUserCleanUp extends AbstractIntegrationTest {
                $this->mapping->clear();
                $this->access->setUserMapper($this->mapping);
 
-               $userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->query(UserPluginManager::class));
+               $userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class));
                \OC_User::useBackend($userBackend);
        }
 
index 7353c5bef30b03bf9970a97935d8e56c27790382..6c12c32744c6e6686c511dabcb7662cf2c0fbc79 100644 (file)
@@ -26,8 +26,10 @@ namespace OCA\User_LDAP\Tests\Integration\Lib\User;
 
 use OCA\User_LDAP\Mapping\UserMapping;
 use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
+use OCA\User_LDAP\User\DeletedUsersIndex;
 use OCA\User_LDAP\User_LDAP;
 use OCA\User_LDAP\UserPluginManager;
+use Psr\Log\LoggerInterface;
 
 require_once __DIR__ . '/../../Bootstrap.php';
 
@@ -45,7 +47,7 @@ class IntegrationTestUserDisplayName extends AbstractIntegrationTest {
                $this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
                $this->mapping->clear();
                $this->access->setUserMapper($this->mapping);
-               $userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->query(UserPluginManager::class));
+               $userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class));
                \OC_User::useBackend($userBackend);
        }
 
index b00c93e79f0c81ddff0a2dd419f60590d6a9f798..d04282e1dc5777cbfe955b367bbb89238c8548a3 100644 (file)
@@ -37,6 +37,7 @@ use OCA\User_LDAP\Access;
 use OCA\User_LDAP\Connection;
 use OCA\User_LDAP\Mapping\AbstractMapping;
 use OCA\User_LDAP\Mapping\UserMapping;
+use OCA\User_LDAP\User\DeletedUsersIndex;
 use OCA\User_LDAP\User\Manager;
 use OCA\User_LDAP\User\OfflineUser;
 use OCA\User_LDAP\User\User;
@@ -48,6 +49,8 @@ use OCP\IConfig;
 use OCP\IUser;
 use OCP\Notification\IManager as INotificationManager;
 use Test\TestCase;
+use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
 
 /**
  * Class Test_User_Ldap_Direct
@@ -59,22 +62,26 @@ use Test\TestCase;
 class User_LDAPTest extends TestCase {
        /** @var User_LDAP */
        protected $backend;
-       /** @var Access|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var Access|MockObject */
        protected $access;
-       /** @var  OfflineUser|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var  OfflineUser|MockObject */
        protected $offlineUser;
-       /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var IConfig|MockObject */
        protected $config;
-       /** @var INotificationManager|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var INotificationManager|MockObject */
        protected $notificationManager;
-       /** @var Session|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var Session|MockObject */
        protected $session;
-       /** @var UserPluginManager|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var UserPluginManager|MockObject */
        protected $pluginManager;
-       /** @var Connection|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var Connection|MockObject */
        protected $connection;
-       /** @var Manager|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var Manager|MockObject */
        protected $userManager;
+       /** @var LoggerInterface|MockObject */
+       protected $logger;
+       /** @var DeletedUsersIndex|MockObject */
+       protected $deletedUsersIndex;
 
        protected function setUp(): void {
                parent::setUp();
@@ -95,12 +102,18 @@ class User_LDAPTest extends TestCase {
                $this->session = $this->createMock(Session::class);
                $this->pluginManager = $this->createMock(UserPluginManager::class);
 
+               $this->logger = $this->createMock(LoggerInterface::class);
+
+               $this->deletedUsersIndex = $this->createMock(DeletedUsersIndex::class);
+
                $this->backend = new User_LDAP(
                        $this->access,
                        $this->config,
                        $this->notificationManager,
                        $this->session,
-                       $this->pluginManager
+                       $this->pluginManager,
+                       $this->logger,
+                       $this->deletedUsersIndex,
                );
        }
 
@@ -109,21 +122,21 @@ class User_LDAPTest extends TestCase {
                           ->method('username2dn')
                           ->willReturnCallback(function ($uid) {
                                switch ($uid) {
-                                               case 'gunslinger':
-                                                       return 'dnOfRoland,dc=test';
-                                                       break;
-                                               case 'formerUser':
-                                                       return 'dnOfFormerUser,dc=test';
-                                                       break;
-                                               case 'newyorker':
-                                                       return 'dnOfNewYorker,dc=test';
-                                                       break;
-                                               case 'ladyofshadows':
-                                                       return 'dnOfLadyOfShadows,dc=test';
-                                                       break;
-                                               default:
-                                                       return false;
-                                       }
+                                       case 'gunslinger':
+                                               return 'dnOfRoland,dc=test';
+                                               break;
+                                       case 'formerUser':
+                                               return 'dnOfFormerUser,dc=test';
+                                               break;
+                                       case 'newyorker':
+                                               return 'dnOfNewYorker,dc=test';
+                                               break;
+                                       case 'ladyofshadows':
+                                               return 'dnOfLadyOfShadows,dc=test';
+                                               break;
+                                       default:
+                                               return false;
+                               }
                           });
 
                $this->access->method('fetchUsersByLoginName')
@@ -199,7 +212,7 @@ class User_LDAPTest extends TestCase {
                        ->method('get')
                        ->willReturn($user);
 
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
 
                \OC_User::useBackend($backend);
 
@@ -209,7 +222,7 @@ class User_LDAPTest extends TestCase {
 
        public function testCheckPasswordWrongPassword() {
                $this->prepareAccessForCheckPassword();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $result = $backend->checkPassword('roland', 'wrong');
@@ -218,7 +231,7 @@ class User_LDAPTest extends TestCase {
 
        public function testCheckPasswordWrongUser() {
                $this->prepareAccessForCheckPassword();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $result = $backend->checkPassword('mallory', 'evil');
@@ -233,7 +246,7 @@ class User_LDAPTest extends TestCase {
                        ->method('get')
                        ->willReturn(null);
 
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $result = $backend->checkPassword('roland', 'dt19');
@@ -251,7 +264,7 @@ class User_LDAPTest extends TestCase {
                        ->method('get')
                        ->willReturn($user);
 
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $user = \OC::$server->getUserManager()->checkPassword('roland', 'dt19');
@@ -264,7 +277,7 @@ class User_LDAPTest extends TestCase {
 
        public function testCheckPasswordPublicAPIWrongPassword() {
                $this->prepareAccessForCheckPassword();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $user = \OC::$server->getUserManager()->checkPassword('roland', 'wrong');
@@ -277,7 +290,7 @@ class User_LDAPTest extends TestCase {
 
        public function testCheckPasswordPublicAPIWrongUser() {
                $this->prepareAccessForCheckPassword();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $user = \OC::$server->getUserManager()->checkPassword('mallory', 'evil');
@@ -289,7 +302,7 @@ class User_LDAPTest extends TestCase {
        }
 
        public function testDeleteUserCancel() {
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $result = $backend->deleteUser('notme');
                $this->assertFalse($result);
        }
@@ -309,10 +322,10 @@ class User_LDAPTest extends TestCase {
                        ->method('getConnectionResource')
                        ->willReturn('this is an ldap link');
 
-               $this->config->expects($this->any())
-                       ->method('getUserValue')
-                       ->with($uid, 'user_ldap', 'isDeleted')
-                       ->willReturn('1');
+               $this->deletedUsersIndex->expects($this->once())
+               ->method('isUserMarked')
+               ->with($uid)
+               ->willReturn(true);
 
                $offlineUser = $this->createMock(OfflineUser::class);
                $offlineUser->expects($this->once())
@@ -322,7 +335,7 @@ class User_LDAPTest extends TestCase {
                        ->method('get')
                        ->willReturn($offlineUser);
 
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
 
                $result = $backend->deleteUser($uid);
                $this->assertTrue($result);
@@ -339,10 +352,10 @@ class User_LDAPTest extends TestCase {
                        ->with('uid')
                        ->willReturn(true);
 
-               $this->config->expects($this->once())
-                       ->method('getUserValue')
-                       ->with('uid', 'user_ldap', 'isDeleted', 0)
-                       ->willReturn(1);
+               $this->deletedUsersIndex->expects($this->once())
+               ->method('isUserMarked')
+               ->with('uid')
+               ->willReturn(true);
 
                $mapper = $this->createMock(UserMapping::class);
                $mapper->expects($this->once())
@@ -388,7 +401,7 @@ class User_LDAPTest extends TestCase {
                                } else {
                                        $result = [];
                                        foreach ($users as $user) {
-                                               if (stripos($user,  $search) !== false) {
+                                               if (stripos($user, $search) !== false) {
                                                        $result[] = $user;
                                                }
                                        }
@@ -411,7 +424,7 @@ class User_LDAPTest extends TestCase {
 
        public function testGetUsersNoParam() {
                $this->prepareAccessForGetUsers();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
 
                $result = $backend->getUsers();
                $this->assertEquals(3, count($result));
@@ -419,7 +432,7 @@ class User_LDAPTest extends TestCase {
 
        public function testGetUsersLimitOffset() {
                $this->prepareAccessForGetUsers();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
 
                $result = $backend->getUsers('', 1, 2);
                $this->assertEquals(1, count($result));
@@ -427,7 +440,7 @@ class User_LDAPTest extends TestCase {
 
        public function testGetUsersLimitOffset2() {
                $this->prepareAccessForGetUsers();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
 
                $result = $backend->getUsers('', 2, 1);
                $this->assertEquals(2, count($result));
@@ -435,7 +448,7 @@ class User_LDAPTest extends TestCase {
 
        public function testGetUsersSearchWithResult() {
                $this->prepareAccessForGetUsers();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
 
                $result = $backend->getUsers('yo');
                $this->assertEquals(2, count($result));
@@ -443,7 +456,7 @@ class User_LDAPTest extends TestCase {
 
        public function testGetUsersSearchEmptyResult() {
                $this->prepareAccessForGetUsers();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
 
                $result = $backend->getUsers('nix');
                $this->assertEquals(0, count($result));
@@ -459,7 +472,7 @@ class User_LDAPTest extends TestCase {
 
        public function testGetUsersViaAPINoParam() {
                $this->prepareAccessForGetUsers();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $result = $this->getUsers();
@@ -468,7 +481,7 @@ class User_LDAPTest extends TestCase {
 
        public function testGetUsersViaAPILimitOffset() {
                $this->prepareAccessForGetUsers();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $result = $this->getUsers('', 1, 2);
@@ -477,7 +490,7 @@ class User_LDAPTest extends TestCase {
 
        public function testGetUsersViaAPILimitOffset2() {
                $this->prepareAccessForGetUsers();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $result = $this->getUsers('', 2, 1);
@@ -486,7 +499,7 @@ class User_LDAPTest extends TestCase {
 
        public function testGetUsersViaAPISearchWithResult() {
                $this->prepareAccessForGetUsers();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $result = $this->getUsers('yo');
@@ -495,7 +508,7 @@ class User_LDAPTest extends TestCase {
 
        public function testGetUsersViaAPISearchEmptyResult() {
                $this->prepareAccessForGetUsers();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $result = $this->getUsers('nix');
@@ -503,7 +516,7 @@ class User_LDAPTest extends TestCase {
        }
 
        public function testUserExists() {
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $this->prepareMockForUserExists();
 
                $user = $this->createMock(User::class);
@@ -522,7 +535,7 @@ class User_LDAPTest extends TestCase {
        }
 
        public function testUserExistsForDeleted() {
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $this->prepareMockForUserExists();
 
                $mapper = $this->createMock(UserMapping::class);
@@ -546,7 +559,7 @@ class User_LDAPTest extends TestCase {
        }
 
        public function testUserExistsForNeverExisting() {
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $this->prepareMockForUserExists();
 
                $this->access->expects($this->any())
@@ -565,7 +578,7 @@ class User_LDAPTest extends TestCase {
        }
 
        public function testUserExistsPublicAPI() {
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $this->prepareMockForUserExists();
                \OC_User::useBackend($backend);
 
@@ -595,7 +608,7 @@ class User_LDAPTest extends TestCase {
        }
 
        public function testDeleteUserExisting() {
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
 
                //we do not support deleting existing users at all
                $result = $backend->deleteUser('gunslinger');
@@ -603,7 +616,7 @@ class User_LDAPTest extends TestCase {
        }
 
        public function testGetHomeAbsolutePath() {
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $this->prepareMockForUserExists();
 
                $this->connection->expects($this->any())
@@ -652,7 +665,7 @@ class User_LDAPTest extends TestCase {
        }
 
        public function testGetHomeRelative() {
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $this->prepareMockForUserExists();
 
                $dataDir = \OC::$server->getConfig()->getSystemValue(
@@ -706,7 +719,7 @@ class User_LDAPTest extends TestCase {
        public function testGetHomeNoPath() {
                $this->expectException(\Exception::class);
 
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $this->prepareMockForUserExists();
 
                $this->connection->expects($this->any())
@@ -754,7 +767,7 @@ class User_LDAPTest extends TestCase {
        public function testGetHomeDeletedUser() {
                $uid = 'newyorker';
 
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $this->prepareMockForUserExists();
 
                $this->connection->expects($this->any())
@@ -810,7 +823,7 @@ class User_LDAPTest extends TestCase {
                        });
 
                /** @noinspection PhpUnhandledExceptionInspection */
-               $this->assertEquals($this->backend->getHome('uid'),'result');
+               $this->assertEquals($this->backend->getHome('uid'), 'result');
        }
 
        private function prepareAccessForGetDisplayName() {
@@ -829,16 +842,16 @@ class User_LDAPTest extends TestCase {
                           ->method('readAttribute')
                           ->willReturnCallback(function ($dn, $attr) {
                                switch ($dn) {
-                                               case 'dnOfRoland,dc=test':
-                                                       if ($attr === 'displayname') {
-                                                               return ['Roland Deschain'];
-                                                       }
-                                                       return [];
-                                                       break;
-
-                                               default:
-                                                       return false;
-                                  }
+                                       case 'dnOfRoland,dc=test':
+                                               if ($attr === 'displayname') {
+                                                       return ['Roland Deschain'];
+                                               }
+                                               return [];
+                                               break;
+
+                                       default:
+                                               return false;
+                               }
                           });
                $this->access->method('fetchUsersByLoginName')
                        ->willReturn([]);
@@ -846,7 +859,7 @@ class User_LDAPTest extends TestCase {
 
        public function testGetDisplayName() {
                $this->prepareAccessForGetDisplayName();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $this->prepareMockForUserExists();
 
                $this->connection->expects($this->any())
@@ -927,7 +940,7 @@ class User_LDAPTest extends TestCase {
                                }
                        });
                $this->prepareAccessForGetDisplayName();
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $this->prepareMockForUserExists();
 
                $this->connection->expects($this->any())
@@ -998,7 +1011,7 @@ class User_LDAPTest extends TestCase {
                        ->with('uid')
                        ->willReturn('result');
 
-               $this->assertEquals($this->backend->getDisplayName('uid'),'result');
+               $this->assertEquals($this->backend->getDisplayName('uid'), 'result');
        }
 
        //no test for getDisplayNames, because it just invokes getUsers and
@@ -1009,7 +1022,7 @@ class User_LDAPTest extends TestCase {
                           ->method('countUsers')
                           ->willReturn(5);
 
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
 
                $result = $backend->countUsers();
                $this->assertEquals(5, $result);
@@ -1020,7 +1033,7 @@ class User_LDAPTest extends TestCase {
                           ->method('countUsers')
                           ->willReturn(false);
 
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
 
                $result = $backend->countUsers();
                $this->assertFalse($result);
@@ -1035,7 +1048,7 @@ class User_LDAPTest extends TestCase {
                        ->method('countUsers')
                        ->willReturn(42);
 
-               $this->assertEquals($this->backend->countUsers(),42);
+               $this->assertEquals($this->backend->countUsers(), 42);
        }
 
        public function testLoginName2UserNameSuccess() {
@@ -1064,7 +1077,7 @@ class User_LDAPTest extends TestCase {
                        ->method('writeToCache')
                        ->with($this->equalTo('loginName2UserName-'.$loginName), $this->equalTo($username));
 
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $user = $this->createMock(User::class);
                $user->expects($this->any())
                        ->method('getUsername')
@@ -1109,7 +1122,7 @@ class User_LDAPTest extends TestCase {
                        ->method('getAttributes')
                        ->willReturn(['dn', 'uid', 'mail', 'displayname']);
 
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $name = $backend->loginName2UserName($loginName);
                $this->assertSame(false, $name);
 
@@ -1146,7 +1159,7 @@ class User_LDAPTest extends TestCase {
                        ->method('getAttributes')
                        ->willReturn(['dn', 'uid', 'mail', 'displayname']);
 
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $name = $backend->loginName2UserName($loginName);
                $this->assertSame(false, $name);
 
@@ -1223,7 +1236,7 @@ class User_LDAPTest extends TestCase {
                $this->userManager->expects($this->atLeastOnce())
                        ->method('get')
                        ->willReturn($this->createMock(User::class));
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $this->assertTrue(\OC_User::setPassword('roland', 'dt'));
@@ -1236,7 +1249,7 @@ class User_LDAPTest extends TestCase {
                        ->method('get')
                        ->willReturn($this->createMock(User::class));
 
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                $this->userManager->expects($this->any())
                        ->method('get')
                        ->willReturn($this->createMock(User::class));
@@ -1252,7 +1265,7 @@ class User_LDAPTest extends TestCase {
                        ->willReturn($this->createMock(User::class));
 
                $this->prepareAccessForSetPassword(false);
-               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
+               $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex);
                \OC_User::useBackend($backend);
 
                $this->assertFalse(\OC_User::setPassword('roland', 'dt12234$'));
@@ -1295,11 +1308,11 @@ class User_LDAPTest extends TestCase {
                        ->willReturn(true);
                $this->pluginManager->expects($this->once())
                        ->method('setPassword')
-                       ->with('uid','password')
+                       ->with('uid', 'password')
                        ->willReturn('result');
 
                /** @noinspection PhpUnhandledExceptionInspection */
-               $this->assertEquals($this->backend->setPassword('uid', 'password'),'result');
+               $this->assertEquals($this->backend->setPassword('uid', 'password'), 'result');
        }
 
        public function avatarDataProvider() {
@@ -1340,7 +1353,7 @@ class User_LDAPTest extends TestCase {
                        ->with('uid')
                        ->willReturn('result');
 
-               $this->assertEquals($this->backend->canChangeAvatar('uid'),'result');
+               $this->assertEquals($this->backend->canChangeAvatar('uid'), 'result');
        }
 
        public function testSetDisplayNameWithPlugin() {
@@ -1413,7 +1426,7 @@ class User_LDAPTest extends TestCase {
                        ->method('getUserMapper')
                        ->willReturn($this->createMock(UserMapping::class));
 
-               $this->assertEquals($this->backend->createUser($uid, $pwd),true);
+               $this->assertEquals($this->backend->createUser($uid, $pwd), true);
        }
 
        public function testCreateUserFailing() {