aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/tests/Integration/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/tests/Integration/Lib')
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestAccessGroupsMatchFilter.php127
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php51
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestBackupServer.php124
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestBatchApplyUserAttributes.php81
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestConnect.php172
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestCountUsersByLoginName.php24
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php39
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php76
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestUserHome.php186
-rw-r--r--apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php73
-rw-r--r--apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserCleanUp.php45
-rw-r--r--apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php47
12 files changed, 116 insertions, 929 deletions
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestAccessGroupsMatchFilter.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestAccessGroupsMatchFilter.php
deleted file mode 100644
index 87c2e408424..00000000000
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestAccessGroupsMatchFilter.php
+++ /dev/null
@@ -1,127 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\User_LDAP\Tests\Integration\Lib;
-
-use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
-
-require_once __DIR__ . '/../Bootstrap.php';
-
-class IntegrationTestAccessGroupsMatchFilter extends AbstractIntegrationTest {
-
- /**
- * prepares the LDAP environment and sets up a test configuration for
- * the LDAP backend.
- */
- public function init() {
- require(__DIR__ . '/../setup-scripts/createExplicitUsers.php');
- require(__DIR__ . '/../setup-scripts/createExplicitGroups.php');
- require(__DIR__ . '/../setup-scripts/createExplicitGroupsDifferentOU.php');
- parent::init();
- }
-
- /**
- * tests whether the group filter works with one specific group, while the
- * input is the same.
- *
- * @return bool
- */
- protected function case1() {
- $this->connection->setConfiguration(['ldapGroupFilter' => 'cn=RedGroup']);
-
- $dns = ['cn=RedGroup,ou=Groups,' . $this->base];
- $result = $this->access->groupsMatchFilter($dns);
- return ($dns === $result);
- }
-
- /**
- * Tests whether a filter for limited groups is effective when more existing
- * groups were passed for validation.
- *
- * @return bool
- */
- protected function case2() {
- $this->connection->setConfiguration(['ldapGroupFilter' => '(|(cn=RedGroup)(cn=PurpleGroup))']);
-
- $dns = [
- 'cn=RedGroup,ou=Groups,' . $this->base,
- 'cn=BlueGroup,ou=Groups,' . $this->base,
- 'cn=PurpleGroup,ou=Groups,' . $this->base
- ];
- $result = $this->access->groupsMatchFilter($dns);
-
- $status =
- count($result) === 2
- && in_array('cn=RedGroup,ou=Groups,' . $this->base, $result)
- && in_array('cn=PurpleGroup,ou=Groups,' . $this->base, $result);
-
- return $status;
- }
-
- /**
- * Tests whether a filter for limited groups is effective when more existing
- * groups were passed for validation.
- *
- * @return bool
- */
- protected function case3() {
- $this->connection->setConfiguration(['ldapGroupFilter' => '(objectclass=groupOfNames)']);
-
- $dns = [
- 'cn=RedGroup,ou=Groups,' . $this->base,
- 'cn=PurpleGroup,ou=Groups,' . $this->base,
- 'cn=SquaredCircleGroup,ou=SpecialGroups,' . $this->base
- ];
- $result = $this->access->groupsMatchFilter($dns);
-
- $status =
- count($result) === 2
- && in_array('cn=RedGroup,ou=Groups,' . $this->base, $result)
- && in_array('cn=PurpleGroup,ou=Groups,' . $this->base, $result);
-
- return $status;
- }
-
- /**
- * sets up the LDAP configuration to be used for the test
- */
- protected function initConnection() {
- parent::initConnection();
- $this->connection->setConfiguration([
- 'ldapBaseGroups' => 'ou=Groups,' . $this->base,
- 'ldapUserFilter' => 'objectclass=inetOrgPerson',
- 'ldapUserDisplayName' => 'displayName',
- 'ldapGroupDisplayName' => 'cn',
- 'ldapLoginFilter' => 'uid=%uid',
- ]);
- }
-}
-
-/** @var string $host */
-/** @var int $port */
-/** @var string $adn */
-/** @var string $apwd */
-/** @var string $bdn */
-$test = new IntegrationTestAccessGroupsMatchFilter($host, $port, $adn, $apwd, $bdn);
-$test->init();
-$test->run();
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php
index 0238d68f59f..e1529384239 100644
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php
+++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php
@@ -1,34 +1,25 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Vinicius Cubas Brand <vinicius@eita.org.br>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
-namespace OCA\user_ldap\tests\Integration\Lib;
+namespace OCA\User_LDAP\Tests\Integration\Lib;
use OCA\User_LDAP\Group_LDAP;
+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 OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\IGroupManager;
+use OCP\IUserManager;
+use OCP\Server;
+use Psr\Log\LoggerInterface;
require_once __DIR__ . '/../Bootstrap.php';
@@ -42,28 +33,28 @@ class IntegrationTestAttributeDetection extends AbstractIntegrationTest {
$this->connection->setConfiguration(['ldapGroupFilter' => 'objectClass=groupOfNames']);
$this->connection->setConfiguration(['ldapGroupMemberAssocAttr' => 'member']);
- $userMapper = new UserMapping(\OC::$server->getDatabaseConnection());
+ $userMapper = new UserMapping(Server::get(IDBConnection::class));
$userMapper->clear();
$this->access->setUserMapper($userMapper);
- $groupMapper = new GroupMapping(\OC::$server->getDatabaseConnection());
+ $groupMapper = new GroupMapping(Server::get(IDBConnection::class));
$groupMapper->clear();
$this->access->setGroupMapper($groupMapper);
- $userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->query('LDAPUserPluginManager'));
- $userManager = \OC::$server->getUserManager();
+ $userBackend = new User_LDAP($this->access, Server::get(\OCP\Notification\IManager::class), Server::get(UserPluginManager::class), Server::get(LoggerInterface::class), Server::get(DeletedUsersIndex::class));
+ $userManager = Server::get(IUserManager::class);
$userManager->clearBackends();
$userManager->registerBackend($userBackend);
- $groupBackend = new Group_LDAP($this->access, \OC::$server->query('LDAPGroupPluginManager'));
- $groupManger = \OC::$server->getGroupManager();
+ $groupBackend = new Group_LDAP($this->access, Server::get(GroupPluginManager::class), Server::get(IConfig::class));
+ $groupManger = Server::get(IGroupManager::class);
$groupManger->clearBackends();
$groupManger->addBackend($groupBackend);
}
protected function caseNativeUUIDAttributeUsers() {
// trigger importing of users which also triggers UUID attribute detection
- \OC::$server->getUserManager()->search('', 5, 0);
+ Server::get(IUserManager::class)->search('', 5, 0);
return $this->connection->ldapUuidUserAttribute === 'entryuuid';
}
@@ -72,7 +63,7 @@ class IntegrationTestAttributeDetection extends AbstractIntegrationTest {
// are similar, but we take no chances.
// trigger importing of users which also triggers UUID attribute detection
- \OC::$server->getGroupManager()->search('', 5, 0);
+ Server::get(IGroupManager::class)->search('', 5, 0);
return $this->connection->ldapUuidGroupAttribute === 'entryuuid';
}
}
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestBackupServer.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestBackupServer.php
deleted file mode 100644
index 0eef5507538..00000000000
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestBackupServer.php
+++ /dev/null
@@ -1,124 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\User_LDAP\Tests\Integration\Lib;
-
-use OC\ServerNotAvailableException;
-use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
-use OCA\User_LDAP\Mapping\UserMapping;
-use OCA\User_LDAP\User_LDAP;
-
-require_once __DIR__ . '/../Bootstrap.php';
-
-class IntegrationTestBackupServer extends AbstractIntegrationTest {
- /** @var UserMapping */
- protected $mapping;
-
- /** @var User_LDAP */
- protected $backend;
-
- /**
- * sets up the LDAP configuration to be used for the test
- */
- protected function initConnection() {
- parent::initConnection();
- $originalHost = $this->connection->ldapHost;
- $originalPort = $this->connection->ldapPort;
- $this->connection->setConfiguration([
- 'ldapHost' => 'qwertz.uiop',
- 'ldapPort' => '32123',
- 'ldap_backup_host' => $originalHost,
- 'ldap_backup_port' => $originalPort,
- ]);
- }
-
- /**
- * tests that a backup connection is being used when the main LDAP server
- * is offline
- *
- * Beware: after starting docker, the LDAP host might not be ready yet, thus
- * causing a false positive. Retry in that case… or increase the sleep time
- * in run-test.sh
- *
- * @return bool
- */
- protected function case1() {
- try {
- $this->connection->getConnectionResource();
- } catch (ServerNotAvailableException $e) {
- return false;
- }
- return true;
- }
-
- /**
- * ensures that an exception is thrown if LDAP main server and LDAP backup
- * server are not available
- *
- * @return bool
- */
- protected function case2() {
- // reset possible LDAP connection
- $this->initConnection();
- try {
- $this->connection->setConfiguration([
- 'ldap_backup_host' => 'qwertz.uiop',
- 'ldap_backup_port' => '32123',
- ]);
- $this->connection->getConnectionResource();
- } catch (ServerNotAvailableException $e) {
- return true;
- }
- return false;
- }
-
- /**
- * ensures that an exception is thrown if main LDAP server is down and a
- * backup server is not given
- *
- * @return bool
- */
- protected function case3() {
- // reset possible LDAP connection
- $this->initConnection();
- try {
- $this->connection->setConfiguration([
- 'ldap_backup_host' => '',
- 'ldap_backup_port' => '',
- ]);
- $this->connection->getConnectionResource();
- } catch (ServerNotAvailableException $e) {
- return true;
- }
- return false;
- }
-}
-
-/** @var string $host */
-/** @var int $port */
-/** @var string $adn */
-/** @var string $apwd */
-/** @var string $bdn */
-$test = new IntegrationTestBackupServer($host, $port, $adn, $apwd, $bdn);
-$test->init();
-$test->run();
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestBatchApplyUserAttributes.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestBatchApplyUserAttributes.php
deleted file mode 100644
index 24476c9a868..00000000000
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestBatchApplyUserAttributes.php
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\User_LDAP\Tests\Integration\Lib;
-
-use OCA\User_LDAP\Mapping\UserMapping;
-use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
-
-require_once __DIR__ . '/../Bootstrap.php';
-
-class IntegrationTestBatchApplyUserAttributes extends AbstractIntegrationTest {
- /** @var UserMapping */
- protected $mapping;
-
- /**
- * prepares the LDAP environment and sets up a test configuration for
- * the LDAP backend.
- */
- public function init() {
- require(__DIR__ . '/../setup-scripts/createExplicitUsers.php');
- require(__DIR__ . '/../setup-scripts/createUsersWithoutDisplayName.php');
- parent::init();
-
- $this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
- $this->mapping->clear();
- $this->access->setUserMapper($this->mapping);
- }
-
- /**
- * sets up the LDAP configuration to be used for the test
- */
- protected function initConnection() {
- parent::initConnection();
- $this->connection->setConfiguration([
- 'ldapUserDisplayName' => 'displayname',
- ]);
- }
-
- /**
- * indirectly tests whether batchApplyUserAttributes does it job properly,
- * when a user without display name is included in the result set from LDAP.
- *
- * @return bool
- */
- protected function case1() {
- $result = $this->access->fetchListOfUsers('objectclass=person', 'dn');
- // on the original issue, PHP would emit a fatal error
- // – cannot catch it here, but will render the test as unsuccessful
- return is_array($result) && !empty($result);
- }
-
-}
-
-/** @var string $host */
-/** @var int $port */
-/** @var string $adn */
-/** @var string $apwd */
-/** @var string $bdn */
-$test = new IntegrationTestBatchApplyUserAttributes($host, $port, $adn, $apwd, $bdn);
-$test->init();
-$test->run();
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestConnect.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestConnect.php
deleted file mode 100644
index f4fc0f189b4..00000000000
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestConnect.php
+++ /dev/null
@@ -1,172 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\User_LDAP\Tests\Integration\Lib;
-
-use OC\ServerNotAvailableException;
-use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
-use OCA\User_LDAP\Mapping\UserMapping;
-use OCA\User_LDAP\User_LDAP;
-
-require_once __DIR__ . '/../Bootstrap.php';
-
-class IntegrationTestConnect extends AbstractIntegrationTest {
- /** @var UserMapping */
- protected $mapping;
-
- /** @var User_LDAP */
- protected $backend;
-
- /** @var string */
- protected $host;
-
- /** @var int */
- protected $port;
-
- public function __construct($host, $port, $bind, $pwd, $base) {
- // make sure host is a simple host name
- if(strpos($host, '://') !== false) {
- $host = substr_replace($host, '', 0, strpos($host, '://') + 3);
- }
- if(strpos($host, ':') !== false) {
- $host = substr_replace($host, '', strpos($host, ':'));
- }
- $this->host = $host;
- $this->port = $port;
- parent::__construct($host, $port, $bind, $pwd, $base);
- }
-
- /**
- * test that a faulty host will does not connect successfully
- *
- * @return bool
- */
- protected function case1() {
- // reset possible LDAP connection
- $this->initConnection();
- $this->connection->setConfiguration([
- 'ldapHost' => 'qwertz.uiop',
- ]);
- try {
- $this->connection->getConnectionResource();
- } catch (ServerNotAvailableException $e) {
- return true;
- }
- return false;
- }
-
- /**
- * tests that a connect succeeds when only a hostname is provided
- *
- * @return bool
- */
- protected function case2() {
- // reset possible LDAP connection
- $this->initConnection();
- $this->connection->setConfiguration([
- 'ldapHost' => $this->host,
- ]);
- try {
- $this->connection->getConnectionResource();
- } catch (ServerNotAvailableException $e) {
- return false;
- }
- return true;
- }
-
- /**
- * tests that a connect succeeds when an LDAP URL is provided
- *
- * @return bool
- */
- protected function case3() {
- // reset possible LDAP connection
- $this->initConnection();
- $this->connection->setConfiguration([
- 'ldapHost' => 'ldap://' . $this->host,
- ]);
- try {
- $this->connection->getConnectionResource();
- } catch (ServerNotAvailableException $e) {
- return false;
- }
- return true;
- }
-
- /**
- * tests that a connect succeeds when an LDAP URL with port is provided
- *
- * @return bool
- */
- protected function case4() {
- // reset possible LDAP connection
- $this->initConnection();
- $this->connection->setConfiguration([
- 'ldapHost' => 'ldap://' . $this->host . ':' . $this->port,
- ]);
- try {
- $this->connection->getConnectionResource();
- } catch (ServerNotAvailableException $e) {
- return false;
- }
- return true;
- }
-
- /**
- * tests that a connect succeeds when a hostname with port is provided
- *
- * @return bool
- */
- protected function case5() {
- // reset possible LDAP connection
- $this->initConnection();
- $this->connection->setConfiguration([
- 'ldapHost' => $this->host . ':' . $this->port,
- ]);
- try {
- $this->connection->getConnectionResource();
- } catch (ServerNotAvailableException $e) {
- return false;
- }
- return true;
- }
-
- /**
- * repeat case1, only to make sure that not a connection was reused by
- * accident.
- *
- * @return bool
- */
- protected function case6() {
- return $this->case1();
- }
-}
-
-/** @var string $host */
-/** @var int $port */
-/** @var string $adn */
-/** @var string $apwd */
-/** @var string $bdn */
-$test = new IntegrationTestConnect($host, $port, $adn, $apwd, $bdn);
-$test->init();
-$test->run();
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestCountUsersByLoginName.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestCountUsersByLoginName.php
index ebbe2197504..8a1093e4304 100644
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestCountUsersByLoginName.php
+++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestCountUsersByLoginName.php
@@ -1,26 +1,10 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OCA\User_LDAP\Tests\Integration\Lib;
use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php
index cab5f6196fd..1c2d7145ddf 100644
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php
+++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php
@@ -1,37 +1,25 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Vinicius Cubas Brand <vinicius@eita.org.br>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OCA\User_LDAP\Tests\Integration\Lib;
-use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
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 OCP\IDBConnection;
+use OCP\Server;
+use Psr\Log\LoggerInterface;
require_once __DIR__ . '/../Bootstrap.php';
class IntegrationTestFetchUsersByLoginName extends AbstractIntegrationTest {
- /** @var UserMapping */
+ /** @var UserMapping */
protected $mapping;
/** @var User_LDAP */
@@ -45,10 +33,10 @@ class IntegrationTestFetchUsersByLoginName extends AbstractIntegrationTest {
require(__DIR__ . '/../setup-scripts/createExplicitUsers.php');
parent::init();
- $this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
+ $this->mapping = new UserMapping(Server::get(IDBConnection::class));
$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('LDAPUserPluginManager'));
+ $this->backend = new User_LDAP($this->access, Server::get(\OCP\Notification\IManager::class), Server::get(UserPluginManager::class), Server::get(LoggerInterface::class), Server::get(DeletedUsersIndex::class));
}
/**
@@ -72,7 +60,6 @@ class IntegrationTestFetchUsersByLoginName extends AbstractIntegrationTest {
$result = $this->access->fetchUsersByLoginName('alice');
return count($result) === 1;
}
-
}
/** @var string $host */
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php
index d54d001c4ad..3e21d22fca3 100644
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php
+++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php
@@ -1,37 +1,24 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Vinicius Cubas Brand <vinicius@eita.org.br>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OCA\User_LDAP\Tests\Integration\Lib;
-use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
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 OCP\Server;
+use Psr\Log\LoggerInterface;
require_once __DIR__ . '/../Bootstrap.php';
class IntegrationTestPaging extends AbstractIntegrationTest {
- /** @var UserMapping */
+ /** @var UserMapping */
protected $mapping;
/** @var User_LDAP */
@@ -48,7 +35,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('LDAPUserPluginManager'));
+ $this->backend = new User_LDAP($this->access, Server::get(\OCP\Notification\IManager::class), Server::get(UserPluginManager::class), Server::get(LoggerInterface::class), Server::get(DeletedUsersIndex::class));
}
public function initConnection() {
@@ -59,29 +46,11 @@ class IntegrationTestPaging extends AbstractIntegrationTest {
}
/**
- * tests that paging works properly against a simple example (reading all
- * of few users in small steps)
- *
- * @return bool
- */
- protected function case1() {
- $filter = 'objectclass=inetorgperson';
- $attributes = ['cn', 'dn'];
-
- $result = $this->access->searchUsers($filter, $attributes);
- if(count($result) === 7) {
- return true;
- }
-
- return false;
- }
-
- /**
* fetch first three, afterwards all users
*
* @return bool
*/
- protected function case2() {
+ protected function case1() {
$filter = 'objectclass=inetorgperson';
$attributes = ['cn', 'dn'];
@@ -91,34 +60,17 @@ class IntegrationTestPaging extends AbstractIntegrationTest {
// the result will be 4, because the highest possible paging size
// is 2 (as configured).
// But also with more than one search base, the limit can be outpaced.
- if(count($result) !== 4) {
+ if (count($result) !== 4) {
return false;
}
$result = $this->access->searchUsers($filter, $attributes);
- if(count($result) !== 7) {
+ if (count($result) !== 7) {
return false;
}
return true;
}
-
- /**
- * reads all remaining users starting first page
- *
- * @return bool
- */
- protected function case3() {
- $filter = 'objectclass=inetorgperson';
- $attributes = ['cn', 'dn'];
-
- $result = $this->access->searchUsers($filter, $attributes, null, $this->pagingSize);
- if(count($result) === (7 - $this->pagingSize)) {
- return true;
- }
-
- return false;
- }
}
/** @var string $host */
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestUserHome.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestUserHome.php
deleted file mode 100644
index 9ee5a7efac2..00000000000
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestUserHome.php
+++ /dev/null
@@ -1,186 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Vinicius Cubas Brand <vinicius@eita.org.br>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\User_LDAP\Tests\Integration\Lib;
-
-use OCA\User_LDAP\FilesystemHelper;
-use OCA\User_LDAP\LogWrapper;
-use OCA\User_LDAP\User\Manager as LDAPUserManager;
-use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
-use OCA\User_LDAP\Mapping\UserMapping;
-use OCA\User_LDAP\User_LDAP;
-use OCP\Image;
-
-require_once __DIR__ . '/../Bootstrap.php';
-
-class IntegrationTestUserHome extends AbstractIntegrationTest {
- /** @var UserMapping */
- protected $mapping;
-
- /** @var User_LDAP */
- protected $backend;
-
- /**
- * prepares the LDAP environment and sets up a test configuration for
- * the LDAP backend.
- */
- public function init() {
- require(__DIR__ . '/../setup-scripts/createExplicitUsers.php');
- parent::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->query('LDAPUserPluginManager'));
- }
-
- /**
- * sets up the LDAP configuration to be used for the test
- */
- protected function initConnection() {
- parent::initConnection();
- $this->connection->setConfiguration([
- 'homeFolderNamingRule' => 'homeDirectory',
- ]);
- }
-
- /**
- * initializes an LDAP user manager instance
- * @return LDAPUserManager
- */
- protected function initUserManager() {
- $this->userManager = new LDAPUserManager(
- \OC::$server->getConfig(),
- new FilesystemHelper(),
- new LogWrapper(),
- \OC::$server->getAvatarManager(),
- new Image(),
- \OC::$server->getDatabaseConnection(),
- \OC::$server->getUserManager(),
- \OC::$server->getNotificationManager()
- );
- }
-
- /**
- * homeDirectory on LDAP is empty. Return values of getHome should be
- * identical to user name, following Nextcloud default.
- *
- * @return bool
- */
- protected function case1() {
- \OC::$server->getConfig()->setAppValue('user_ldap', 'enforce_home_folder_naming_rule', false);
- $userManager = \OC::$server->getUserManager();
- $userManager->clearBackends();
- $userManager->registerBackend($this->backend);
- $users = $userManager->search('', 5, 0);
-
- foreach($users as $user) {
- $home = $user->getHome();
- $uid = $user->getUID();
- $posFound = strpos($home, '/' . $uid);
- $posExpected = strlen($home) - (strlen($uid) + 1);
- if($posFound === false || $posFound !== $posExpected) {
- print('"' . $user->getUID() . '" was not found in "' . $home . '" or does not end with it.' . PHP_EOL);
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * homeDirectory on LDAP is empty. Having the attributes set is enforced.
- *
- * @return bool
- */
- protected function case2() {
- \OC::$server->getConfig()->setAppValue('user_ldap', 'enforce_home_folder_naming_rule', true);
- $userManager = \OC::$server->getUserManager();
- // clearing backends is critical, otherwise the userManager will have
- // the user objects cached and the value from case1 returned
- $userManager->clearBackends();
- $userManager->registerBackend($this->backend);
- $users = $userManager->search('', 5, 0);
-
- try {
- foreach ($users as $user) {
- $user->getHome();
- print('User home was retrieved without throwing an Exception!' . PHP_EOL);
- return false;
- }
- } catch (\Exception $e) {
- if(strpos($e->getMessage(), 'Home dir attribute') === 0) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * homeDirectory on LDAP is set to "attr:" which is effectively empty.
- * Return values of getHome should be Nextcloud default.
- *
- * @return bool
- */
- protected function case3() {
- \OC::$server->getConfig()->setAppValue('user_ldap', 'enforce_home_folder_naming_rule', true);
- $this->connection->setConfiguration([
- 'homeFolderNamingRule' => 'attr:',
- ]);
- $userManager = \OC::$server->getUserManager();
- $userManager->clearBackends();
- $userManager->registerBackend($this->backend);
- $users = $userManager->search('', 5, 0);
-
- try {
- foreach ($users as $user) {
- $home = $user->getHome();
- $uid = $user->getUID();
- $posFound = strpos($home, '/' . $uid);
- $posExpected = strlen($home) - (strlen($uid) + 1);
- if ($posFound === false || $posFound !== $posExpected) {
- print('"' . $user->getUID() . '" was not found in "' . $home . '" or does not end with it.' . PHP_EOL);
- return false;
- }
- }
- } catch (\Exception $e) {
- print("Unexpected Exception: " . $e->getMessage() . PHP_EOL);
- return false;
- }
-
- return true;
- }
-}
-
-/** @var string $host */
-/** @var int $port */
-/** @var string $adn */
-/** @var string $apwd */
-/** @var string $bdn */
-$test = new IntegrationTestUserHome($host, $port, $adn, $apwd, $bdn);
-$test->init();
-$test->run();
diff --git a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php
index 599458a9721..6726143a449 100644
--- a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php
+++ b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php
@@ -1,45 +1,31 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roger Szabo <roger.szabo@web.de>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Vinicius Cubas Brand <vinicius@eita.org.br>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OCA\User_LDAP\Tests\Integration\Lib\User;
-use OCA\User_LDAP\FilesystemHelper;
-use OCA\User_LDAP\LogWrapper;
-use OCA\User_LDAP\User\Manager;
-use OCA\User_LDAP\User\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\Manager;
+use OCA\User_LDAP\User\User;
use OCA\User_LDAP\User_LDAP;
+use OCA\User_LDAP\UserPluginManager;
+use OCP\IAvatarManager;
+use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\Image;
+use OCP\IUserManager;
+use OCP\Server;
+use Psr\Log\LoggerInterface;
require_once __DIR__ . '/../../Bootstrap.php';
class IntegrationTestUserAvatar extends AbstractIntegrationTest {
- /** @var UserMapping */
+ /** @var UserMapping */
protected $mapping;
/**
@@ -49,11 +35,11 @@ class IntegrationTestUserAvatar extends AbstractIntegrationTest {
public function init() {
require(__DIR__ . '/../../setup-scripts/createExplicitUsers.php');
parent::init();
- $this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
+ $this->mapping = new UserMapping(Server::get(IDBConnection::class));
$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('LDAPUserPluginManager'));
- \OC_User::useBackend($userBackend);
+ $userBackend = new User_LDAP($this->access, Server::get(\OCP\Notification\IManager::class), Server::get(UserPluginManager::class), Server::get(LoggerInterface::class), Server::get(DeletedUsersIndex::class));
+ Server::get(IUserManager::class)->registerBackend($userBackend);
}
/**
@@ -75,9 +61,9 @@ class IntegrationTestUserAvatar extends AbstractIntegrationTest {
\OC_Util::tearDownFS();
\OC_Util::setupFS($username);
\OC::$server->getUserFolder($username);
- \OC::$server->getConfig()->deleteUserValue($username, 'user_ldap', User::USER_PREFKEY_LASTREFRESH);
- if(\OC::$server->getAvatarManager()->getAvatar($username)->exists()) {
- \OC::$server->getAvatarManager()->getAvatar($username)->remove();
+ Server::get(IConfig::class)->deleteUserValue($username, 'user_ldap', User::USER_PREFKEY_LASTREFRESH);
+ if (Server::get(IAvatarManager::class)->getAvatar($username)->exists()) {
+ Server::get(IAvatarManager::class)->getAvatar($username)->remove();
}
// finally attempt to get the avatar set
@@ -97,7 +83,7 @@ class IntegrationTestUserAvatar extends AbstractIntegrationTest {
$this->execFetchTest($dn, $username, $image);
- return \OC::$server->getAvatarManager()->getAvatar($username)->exists();
+ return Server::get(IAvatarManager::class)->getAvatar($username)->exists();
}
/**
@@ -114,7 +100,7 @@ class IntegrationTestUserAvatar extends AbstractIntegrationTest {
$this->execFetchTest($dn, $username, $image);
- return !\OC::$server->getAvatarManager()->getAvatar($username)->exists();
+ return !Server::get(IAvatarManager::class)->getAvatar($username)->exists();
}
/**
@@ -131,14 +117,13 @@ class IntegrationTestUserAvatar extends AbstractIntegrationTest {
protected function initUserManager() {
$this->userManager = new Manager(
- \OC::$server->getConfig(),
- new FilesystemHelper(),
- new LogWrapper(),
- \OC::$server->getAvatarManager(),
+ Server::get(IConfig::class),
+ Server::get(LoggerInterface::class),
+ Server::get(IAvatarManager::class),
new Image(),
- \OC::$server->getDatabaseConnection(),
- \OC::$server->getUserManager(),
- \OC::$server->getNotificationManager()
+ Server::get(IDBConnection::class),
+ Server::get(IUserManager::class),
+ Server::get(\OCP\Notification\IManager::class)
);
}
diff --git a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserCleanUp.php b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserCleanUp.php
index 0d072bcf973..9b05298a151 100644
--- a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserCleanUp.php
+++ b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserCleanUp.php
@@ -1,38 +1,27 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Vinicius Cubas Brand <vinicius@eita.org.br>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OCA\User_LDAP\Tests\Integration\Lib\User;
-use OC\User\NoUserException;
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 OCP\IDBConnection;
+use OCP\IUserManager;
+use OCP\Server;
+use Psr\Log\LoggerInterface;
require_once __DIR__ . '/../../Bootstrap.php';
class IntegrationTestUserCleanUp extends AbstractIntegrationTest {
- /** @var UserMapping */
+ /** @var UserMapping */
protected $mapping;
/**
@@ -42,12 +31,12 @@ class IntegrationTestUserCleanUp extends AbstractIntegrationTest {
public function init() {
require(__DIR__ . '/../../setup-scripts/createExplicitUsers.php');
parent::init();
- $this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
+ $this->mapping = new UserMapping(Server::get(IDBConnection::class));
$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('LDAPUserPluginManager'));
- \OC_User::useBackend($userBackend);
+ $userBackend = new User_LDAP($this->access, Server::get(\OCP\Notification\IManager::class), Server::get(UserPluginManager::class), Server::get(LoggerInterface::class), Server::get(DeletedUsersIndex::class));
+ Server::get(IUserManager::class)->registerBackend($userBackend);
}
/**
@@ -84,13 +73,13 @@ class IntegrationTestUserCleanUp extends AbstractIntegrationTest {
// user instance must not be requested from global user manager, before
// it is deleted from the LDAP server. The instance will be returned
// from cache and may false-positively confirm the correctness.
- $user = \OC::$server->getUserManager()->get($username);
- if($user === null) {
+ $user = Server::get(IUserManager::class)->get($username);
+ if ($user === null) {
return false;
}
$user->delete();
- return null === \OC::$server->getUserManager()->get($username);
+ return Server::get(IUserManager::class)->get($username) === null;
}
}
diff --git a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php
index 476bc8e7596..6fbfd9ba51b 100644
--- a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php
+++ b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php
@@ -1,37 +1,26 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Vinicius Cubas Brand <vinicius@eita.org.br>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
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 OCP\IDBConnection;
+use OCP\IUserManager;
+use OCP\Server;
+use Psr\Log\LoggerInterface;
require_once __DIR__ . '/../../Bootstrap.php';
class IntegrationTestUserDisplayName extends AbstractIntegrationTest {
- /** @var UserMapping */
+ /** @var UserMapping */
protected $mapping;
/**
@@ -41,11 +30,11 @@ class IntegrationTestUserDisplayName extends AbstractIntegrationTest {
public function init() {
require(__DIR__ . '/../../setup-scripts/createExplicitUsers.php');
parent::init();
- $this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
+ $this->mapping = new UserMapping(Server::get(IDBConnection::class));
$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('LDAPUserPluginManager'));
- \OC_User::useBackend($userBackend);
+ $userBackend = new User_LDAP($this->access, Server::get(\OCP\Notification\IManager::class), Server::get(UserPluginManager::class), Server::get(LoggerInterface::class), Server::get(DeletedUsersIndex::class));
+ Server::get(IUserManager::class)->registerBackend($userBackend);
}
/**
@@ -68,9 +57,9 @@ class IntegrationTestUserDisplayName extends AbstractIntegrationTest {
$username = 'alice1337';
$dn = 'uid=alice,ou=Users,' . $this->base;
$this->prepareUser($dn, $username);
- $displayName = \OC::$server->getUserManager()->get($username)->getDisplayName();
+ $displayName = Server::get(IUserManager::class)->get($username)->getDisplayName();
- return strpos($displayName, '(Alice@example.com)') !== false;
+ return str_contains($displayName, '(Alice@example.com)');
}
/**
@@ -85,9 +74,9 @@ class IntegrationTestUserDisplayName extends AbstractIntegrationTest {
$username = 'boris23421';
$dn = 'uid=boris,ou=Users,' . $this->base;
$this->prepareUser($dn, $username);
- $displayName = \OC::$server->getUserManager()->get($username)->getDisplayName();
+ $displayName = Server::get(IUserManager::class)->get($username)->getDisplayName();
- return strpos($displayName, '(Boris@example.com)') === false;
+ return !str_contains($displayName, '(Boris@example.com)');
}
/**