diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index 68945600da9d3..b629f2f9452c2 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -45,9 +45,7 @@ use OCA\User_LDAP\User\DeletedUsersIndex; use OCA\User_LDAP\User\OfflineUser; use OCA\User_LDAP\User\User; -use OCP\IConfig; use OCP\IUserBackend; -use OCP\IUserSession; use OCP\Notification\IManager as INotificationManager; use OCP\User\Backend\ICountMappedUsersBackend; use OCP\User\Backend\ICountUsersBackend; @@ -56,7 +54,6 @@ use Psr\Log\LoggerInterface; class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, IUserLDAP, ICountUsersBackend, ICountMappedUsersBackend, IProvideEnabledStateBackend { - protected IConfig $ocConfig; protected INotificationManager $notificationManager; protected UserPluginManager $userPluginManager; protected LoggerInterface $logger; @@ -64,15 +61,12 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I 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 = $logger; diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php index 7b927100fe5db..8ad3290cf48f5 100644 --- a/apps/user_ldap/lib/User_Proxy.php +++ b/apps/user_ldap/lib/User_Proxy.php @@ -34,9 +34,7 @@ use OCA\User_LDAP\User\DeletedUsersIndex; use OCA\User_LDAP\User\OfflineUser; use OCA\User_LDAP\User\User; -use OCP\IConfig; use OCP\IUserBackend; -use OCP\IUserSession; use OCP\Notification\IManager as INotificationManager; use OCP\User\Backend\ICountMappedUsersBackend; use OCP\User\Backend\ICountUsersBackend; @@ -51,9 +49,7 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP private bool $isSetUp = false; private Helper $helper; - private IConfig $ocConfig; private INotificationManager $notificationManager; - private IUserSession $userSession; private UserPluginManager $userPluginManager; private LoggerInterface $logger; private DeletedUsersIndex $deletedUsersIndex; @@ -62,18 +58,14 @@ public function __construct( Helper $helper, ILDAPWrapper $ldap, AccessFactory $accessFactory, - IConfig $ocConfig, INotificationManager $notificationManager, - IUserSession $userSession, UserPluginManager $userPluginManager, LoggerInterface $logger, DeletedUsersIndex $deletedUsersIndex, ) { parent::__construct($ldap, $accessFactory); $this->helper = $helper; - $this->ocConfig = $ocConfig; $this->notificationManager = $notificationManager; - $this->userSession = $userSession; $this->userPluginManager = $userPluginManager; $this->logger = $logger; $this->deletedUsersIndex = $deletedUsersIndex; @@ -88,9 +80,7 @@ protected function setup(): void { foreach ($serverConfigPrefixes as $configPrefix) { $this->backends[$configPrefix] = new User_LDAP( $this->getAccess($configPrefix), - $this->ocConfig, $this->notificationManager, - $this->userSession, $this->userPluginManager, $this->logger, $this->deletedUsersIndex, diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php index e77b3aec6b041..5898fd0c4fabb 100644 --- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php +++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php @@ -54,7 +54,7 @@ public function init() { $groupMapper->clear(); $this->access->setGroupMapper($groupMapper); - $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)); + $userBackend = new User_LDAP($this->access, \OC::$server->getNotificationManager(), \OC::$server->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class)); $userManager = \OC::$server->getUserManager(); $userManager->clearBackends(); $userManager->registerBackend($userBackend); diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php index 7b8f9fda754d0..c122f4f1d2741 100644 --- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php +++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php @@ -51,7 +51,7 @@ public function init() { $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->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class)); + $this->backend = new User_LDAP($this->access, \OC::$server->getNotificationManager(), \OC::$server->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class)); } /** diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php index 6b272d3ad3ce5..8a52cf922c054 100644 --- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php +++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php @@ -52,7 +52,7 @@ public function init() { 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->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class)); + $this->backend = new User_LDAP($this->access, \OC::$server->getNotificationManager(), \OC::$server->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class)); } public function initConnection() { diff --git a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php index c5b7f73bbcc0d..3c3150bd0dd6b 100644 --- a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php +++ b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php @@ -54,7 +54,7 @@ public function init() { $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->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class)); + $userBackend = new User_LDAP($this->access, \OC::$server->getNotificationManager(), \OC::$server->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class)); \OC_User::useBackend($userBackend); } diff --git a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserCleanUp.php b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserCleanUp.php index 623d08d565da1..644e60c511ba9 100644 --- a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserCleanUp.php +++ b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserCleanUp.php @@ -48,7 +48,7 @@ public function init() { $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->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class)); + $userBackend = new User_LDAP($this->access, \OC::$server->getNotificationManager(), \OC::$server->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class)); \OC_User::useBackend($userBackend); } diff --git a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php index 666211fc89861..143001dfcbaea 100644 --- a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php +++ b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php @@ -47,7 +47,7 @@ public function init() { $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->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class)); + $userBackend = new User_LDAP($this->access, \OC::$server->getNotificationManager(), \OC::$server->get(UserPluginManager::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DeletedUsersIndex::class)); \OC_User::useBackend($userBackend); } diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index 35c692d634fb8..bc6b72e1778b7 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -32,7 +32,6 @@ namespace OCA\User_LDAP\Tests; use OC\User\Backend; -use OC\User\Session; use OCA\User_LDAP\Access; use OCA\User_LDAP\Connection; use OCA\User_LDAP\Mapping\AbstractMapping; @@ -45,7 +44,6 @@ use OCA\User_LDAP\User_LDAP as UserLDAP; use OCA\User_LDAP\UserPluginManager; use OCP\HintException; -use OCP\IConfig; use OCP\IUser; use OCP\Notification\IManager as INotificationManager; use PHPUnit\Framework\MockObject\MockObject; @@ -66,12 +64,8 @@ class User_LDAPTest extends TestCase { protected $access; /** @var OfflineUser|MockObject */ protected $offlineUser; - /** @var IConfig|MockObject */ - protected $config; /** @var INotificationManager|MockObject */ protected $notificationManager; - /** @var Session|MockObject */ - protected $session; /** @var UserPluginManager|MockObject */ protected $pluginManager; /** @var Connection|MockObject */ @@ -96,10 +90,7 @@ protected function setUp(): void { $this->access->connection = $this->connection; $this->access->userManager = $this->userManager; - $this->config = $this->createMock(IConfig::class); $this->notificationManager = $this->createMock(INotificationManager::class); - // Cannot use IUserSession because of private listen() methods - $this->session = $this->createMock(Session::class); $this->pluginManager = $this->createMock(UserPluginManager::class); $this->logger = $this->createMock(LoggerInterface::class); @@ -108,9 +99,7 @@ protected function setUp(): void { $this->backend = new User_LDAP( $this->access, - $this->config, $this->notificationManager, - $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex, @@ -212,7 +201,7 @@ public function testCheckPasswordUidReturn() { ->method('get') ->willReturn($user); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); @@ -222,7 +211,7 @@ public function testCheckPasswordUidReturn() { public function testCheckPasswordWrongPassword() { $this->prepareAccessForCheckPassword(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $result = $backend->checkPassword('roland', 'wrong'); @@ -231,7 +220,7 @@ public function testCheckPasswordWrongPassword() { public function testCheckPasswordWrongUser() { $this->prepareAccessForCheckPassword(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $result = $backend->checkPassword('mallory', 'evil'); @@ -246,7 +235,7 @@ public function testCheckPasswordNoDisplayName() { ->method('get') ->willReturn(null); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $result = $backend->checkPassword('roland', 'dt19'); @@ -264,7 +253,7 @@ public function testCheckPasswordPublicAPI() { ->method('get') ->willReturn($user); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $user = \OC::$server->getUserManager()->checkPassword('roland', 'dt19'); @@ -277,7 +266,7 @@ public function testCheckPasswordPublicAPI() { public function testCheckPasswordPublicAPIWrongPassword() { $this->prepareAccessForCheckPassword(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $user = \OC::$server->getUserManager()->checkPassword('roland', 'wrong'); @@ -290,7 +279,7 @@ public function testCheckPasswordPublicAPIWrongPassword() { public function testCheckPasswordPublicAPIWrongUser() { $this->prepareAccessForCheckPassword(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $user = \OC::$server->getUserManager()->checkPassword('mallory', 'evil'); @@ -302,7 +291,7 @@ public function testCheckPasswordPublicAPIWrongUser() { } public function testDeleteUserCancel() { - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $result = $backend->deleteUser('notme'); $this->assertFalse($result); } @@ -335,7 +324,7 @@ public function testDeleteUserSuccess() { ->method('get') ->willReturn($offlineUser); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $result = $backend->deleteUser($uid); $this->assertTrue($result); @@ -424,7 +413,7 @@ private function prepareAccessForGetUsers() { public function testGetUsersNoParam() { $this->prepareAccessForGetUsers(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $result = $backend->getUsers(); $this->assertEquals(3, count($result)); @@ -432,7 +421,7 @@ public function testGetUsersNoParam() { public function testGetUsersLimitOffset() { $this->prepareAccessForGetUsers(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $result = $backend->getUsers('', 1, 2); $this->assertEquals(1, count($result)); @@ -440,7 +429,7 @@ public function testGetUsersLimitOffset() { public function testGetUsersLimitOffset2() { $this->prepareAccessForGetUsers(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $result = $backend->getUsers('', 2, 1); $this->assertEquals(2, count($result)); @@ -448,7 +437,7 @@ public function testGetUsersLimitOffset2() { public function testGetUsersSearchWithResult() { $this->prepareAccessForGetUsers(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $result = $backend->getUsers('yo'); $this->assertEquals(2, count($result)); @@ -456,7 +445,7 @@ public function testGetUsersSearchWithResult() { public function testGetUsersSearchEmptyResult() { $this->prepareAccessForGetUsers(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $result = $backend->getUsers('nix'); $this->assertEquals(0, count($result)); @@ -472,7 +461,7 @@ private function getUsers($search = '', $limit = null, $offset = null) { public function testGetUsersViaAPINoParam() { $this->prepareAccessForGetUsers(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $result = $this->getUsers(); @@ -481,7 +470,7 @@ public function testGetUsersViaAPINoParam() { public function testGetUsersViaAPILimitOffset() { $this->prepareAccessForGetUsers(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $result = $this->getUsers('', 1, 2); @@ -490,7 +479,7 @@ public function testGetUsersViaAPILimitOffset() { public function testGetUsersViaAPILimitOffset2() { $this->prepareAccessForGetUsers(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $result = $this->getUsers('', 2, 1); @@ -499,7 +488,7 @@ public function testGetUsersViaAPILimitOffset2() { public function testGetUsersViaAPISearchWithResult() { $this->prepareAccessForGetUsers(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $result = $this->getUsers('yo'); @@ -508,7 +497,7 @@ public function testGetUsersViaAPISearchWithResult() { public function testGetUsersViaAPISearchEmptyResult() { $this->prepareAccessForGetUsers(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $result = $this->getUsers('nix'); @@ -516,7 +505,7 @@ public function testGetUsersViaAPISearchEmptyResult() { } public function testUserExists() { - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $this->prepareMockForUserExists(); $user = $this->createMock(User::class); @@ -535,7 +524,7 @@ public function testUserExists() { } public function testUserExistsForDeleted() { - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $this->prepareMockForUserExists(); $mapper = $this->createMock(UserMapping::class); @@ -559,7 +548,7 @@ public function testUserExistsForDeleted() { } public function testUserExistsForNeverExisting() { - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $this->prepareMockForUserExists(); $this->access->expects($this->any()) @@ -578,7 +567,7 @@ public function testUserExistsForNeverExisting() { } public function testUserExistsPublicAPI() { - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $this->prepareMockForUserExists(); \OC_User::useBackend($backend); @@ -608,7 +597,7 @@ public function testUserExistsPublicAPI() { } public function testDeleteUserExisting() { - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); //we do not support deleting existing users at all $result = $backend->deleteUser('gunslinger'); @@ -616,7 +605,7 @@ public function testDeleteUserExisting() { } public function testGetHomeAbsolutePath() { - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $this->prepareMockForUserExists(); $this->connection->expects($this->any()) @@ -665,7 +654,7 @@ public function testGetHomeAbsolutePath() { } public function testGetHomeRelative() { - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $this->prepareMockForUserExists(); $dataDir = \OC::$server->getConfig()->getSystemValue( @@ -719,7 +708,7 @@ public function testGetHomeRelative() { public function testGetHomeNoPath() { $this->expectException(\Exception::class); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $this->prepareMockForUserExists(); $this->connection->expects($this->any()) @@ -767,7 +756,7 @@ public function testGetHomeNoPath() { public function testGetHomeDeletedUser() { $uid = 'newyorker'; - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $this->prepareMockForUserExists(); $this->connection->expects($this->any()) @@ -789,10 +778,6 @@ public function testGetHomeDeletedUser() { ->method('getUserMapper') ->willReturn($userMapper); - $this->config->expects($this->any()) - ->method('getUserValue') - ->willReturn(true); - $offlineUser = $this->createMock(OfflineUser::class); $offlineUser->expects($this->atLeastOnce()) ->method('getHomePath') @@ -859,7 +844,7 @@ private function prepareAccessForGetDisplayName() { public function testGetDisplayName() { $this->prepareAccessForGetDisplayName(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $this->prepareMockForUserExists(); $this->connection->expects($this->any()) @@ -940,7 +925,7 @@ public function testGetDisplayNamePublicAPI() { } }); $this->prepareAccessForGetDisplayName(); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $this->prepareMockForUserExists(); $this->connection->expects($this->any()) @@ -1022,7 +1007,7 @@ public function testCountUsers() { ->method('countUsers') ->willReturn(5); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $result = $backend->countUsers(); $this->assertEquals(5, $result); @@ -1033,7 +1018,7 @@ public function testCountUsersFailing() { ->method('countUsers') ->willReturn(false); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $result = $backend->countUsers(); $this->assertFalse($result); @@ -1077,7 +1062,7 @@ public function testLoginName2UserNameSuccess() { ->method('writeToCache') ->with($this->equalTo('loginName2UserName-'.$loginName), $this->equalTo($username)); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $user = $this->createMock(User::class); $user->expects($this->any()) ->method('getUsername') @@ -1122,7 +1107,7 @@ public function testLoginName2UserNameNoUsersOnLDAP() { ->method('getAttributes') ->willReturn(['dn', 'uid', 'mail', 'displayname']); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $name = $backend->loginName2UserName($loginName); $this->assertSame(false, $name); @@ -1159,7 +1144,7 @@ public function testLoginName2UserNameOfflineUser() { ->method('getAttributes') ->willReturn(['dn', 'uid', 'mail', 'displayname']); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $name = $backend->loginName2UserName($loginName); $this->assertSame(false, $name); @@ -1236,7 +1221,7 @@ public function testSetPasswordInvalid() { $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, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $this->assertTrue(\OC_User::setPassword('roland', 'dt')); @@ -1249,7 +1234,7 @@ public function testSetPasswordValid() { ->method('get') ->willReturn($this->createMock(User::class)); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); $this->userManager->expects($this->any()) ->method('get') ->willReturn($this->createMock(User::class)); @@ -1265,7 +1250,7 @@ public function testSetPasswordValidDisabled() { ->willReturn($this->createMock(User::class)); $this->prepareAccessForSetPassword(false); - $backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager, $this->logger, $this->deletedUsersIndex); + $backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); \OC_User::useBackend($backend); $this->assertFalse(\OC_User::setPassword('roland', 'dt12234$')); diff --git a/apps/user_ldap/tests/User_ProxyTest.php b/apps/user_ldap/tests/User_ProxyTest.php index a557eb4bc6f31..05e7d3efc615f 100644 --- a/apps/user_ldap/tests/User_ProxyTest.php +++ b/apps/user_ldap/tests/User_ProxyTest.php @@ -34,8 +34,6 @@ use OCA\User_LDAP\User\DeletedUsersIndex; use OCA\User_LDAP\User_Proxy; use OCA\User_LDAP\UserPluginManager; -use OCP\IConfig; -use OCP\IUserSession; use OCP\Notification\IManager as INotificationManager; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; @@ -48,12 +46,8 @@ class User_ProxyTest extends TestCase { private $ldapWrapper; /** @var AccessFactory|MockObject */ private $accessFactory; - /** @var IConfig|MockObject */ - private $config; /** @var INotificationManager|MockObject */ private $notificationManager; - /** @var IUserSession|MockObject */ - private $userSession; /** @var User_Proxy|MockObject */ private $proxy; /** @var UserPluginManager|MockObject */ @@ -69,9 +63,7 @@ protected function setUp(): void { $this->helper = $this->createMock(Helper::class); $this->ldapWrapper = $this->createMock(ILDAPWrapper::class); $this->accessFactory = $this->createMock(AccessFactory::class); - $this->config = $this->createMock(IConfig::class); $this->notificationManager = $this->createMock(INotificationManager::class); - $this->userSession = $this->createMock(IUserSession::class); $this->userPluginManager = $this->createMock(UserPluginManager::class); $this->logger = $this->createMock(LoggerInterface::class); $this->deletedUsersIndex = $this->createMock(DeletedUsersIndex::class); @@ -80,9 +72,7 @@ protected function setUp(): void { $this->helper, $this->ldapWrapper, $this->accessFactory, - $this->config, $this->notificationManager, - $this->userSession, $this->userPluginManager, $this->logger, $this->deletedUsersIndex,