aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/tests/Integration
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/tests/Integration')
-rw-r--r--apps/user_ldap/tests/Integration/AbstractIntegrationTest.php105
-rw-r--r--apps/user_ldap/tests/Integration/Bootstrap.php25
-rw-r--r--apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php106
-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
-rw-r--r--apps/user_ldap/tests/Integration/data/avatar-valid.jpgbin95495 -> 75950 bytes
-rw-r--r--apps/user_ldap/tests/Integration/readme.md5
-rwxr-xr-xapps/user_ldap/tests/Integration/run-all.sh5
-rwxr-xr-xapps/user_ldap/tests/Integration/run-test.sh5
-rw-r--r--apps/user_ldap/tests/Integration/setup-scripts/createExplicitGroups.php25
-rw-r--r--apps/user_ldap/tests/Integration/setup-scripts/createExplicitGroupsDifferentOU.php25
-rw-r--r--apps/user_ldap/tests/Integration/setup-scripts/createExplicitUsers.php25
-rw-r--r--apps/user_ldap/tests/Integration/setup-scripts/createUsersWithoutDisplayName.php24
23 files changed, 238 insertions, 1157 deletions
diff --git a/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php b/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
index 8d29df6ede6..00f8be18586 100644
--- a/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
+++ b/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
@@ -1,44 +1,32 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author root <root@localhost.localdomain>
- * @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;
use OCA\User_LDAP\Access;
use OCA\User_LDAP\Connection;
-use OCA\User_LDAP\FilesystemHelper;
-use OCA\User_LDAP\LDAP;
+use OCA\User_LDAP\GroupPluginManager;
use OCA\User_LDAP\Helper;
-use OCA\User_LDAP\LogWrapper;
+use OCA\User_LDAP\LDAP;
use OCA\User_LDAP\User\Manager;
+use OCA\User_LDAP\UserPluginManager;
+use OCP\IAvatarManager;
+use OCP\IConfig;
+use OCP\Image;
+use OCP\IUserManager;
+use OCP\Server;
+use OCP\Share\IManager;
+use Psr\Log\LoggerInterface;
abstract class AbstractIntegrationTest {
- /** @var LDAP */
+ /** @var LDAP */
protected $ldap;
- /** @var Connection */
+ /** @var Connection */
protected $connection;
/** @var Access */
@@ -46,23 +34,28 @@ abstract class AbstractIntegrationTest {
/** @var Manager */
protected $userManager;
-
+
/** @var Helper */
protected $helper;
- /** @var string */
- protected $base;
-
/** @var string[] */
protected $server;
- public function __construct($host, $port, $bind, $pwd, $base) {
- $this->base = $base;
+ /**
+ * @param string $base
+ */
+ public function __construct(
+ $host,
+ $port,
+ $bind,
+ $pwd,
+ protected $base,
+ ) {
$this->server = [
'host' => $host,
'port' => $port,
- 'dn' => $bind,
- 'pwd' => $pwd
+ 'dn' => $bind,
+ 'pwd' => $pwd
];
}
@@ -71,11 +64,11 @@ abstract class AbstractIntegrationTest {
* the LDAP backend.
*/
public function init() {
- \OC::$server->registerService('LDAPUserPluginManager', function() {
- return new \OCA\User_LDAP\UserPluginManager();
+ \OC::$server->registerService(UserPluginManager::class, function () {
+ return new UserPluginManager();
});
- \OC::$server->registerService('LDAPGroupPluginManager', function() {
- return new \OCA\User_LDAP\GroupPluginManager();
+ \OC::$server->registerService(GroupPluginManager::class, function () {
+ return new GroupPluginManager();
});
$this->initLDAPWrapper();
@@ -83,7 +76,6 @@ abstract class AbstractIntegrationTest {
$this->initUserManager();
$this->initHelper();
$this->initAccess();
-
}
/**
@@ -118,29 +110,28 @@ abstract class AbstractIntegrationTest {
*/
protected function initUserManager() {
$this->userManager = new Manager(
- \OC::$server->getConfig(),
- new FilesystemHelper(),
- new LogWrapper(),
- \OC::$server->getAvatarManager(),
- new \OCP\Image(),
- \OC::$server->getDatabaseConnection(),
- \OC::$server->getUserManager(),
- \OC::$server->getNotificationManager()
+ Server::get(IConfig::class),
+ Server::get(LoggerInterface::class),
+ Server::get(IAvatarManager::class),
+ new Image(),
+ Server::get(IUserManager::class),
+ Server::get(\OCP\Notification\IManager::class),
+ Server::get(IManager::class)
);
}
-
+
/**
* initializes the test Helper
*/
protected function initHelper() {
- $this->helper = new Helper(\OC::$server->getConfig());
+ $this->helper = Server::get(Helper::class);
}
/**
* initializes the Access test instance
*/
protected function initAccess() {
- $this->access = new Access($this->connection, $this->ldap, $this->userManager, $this->helper, \OC::$server->getConfig());
+ $this->access = new Access($this->connection, $this->ldap, $this->userManager, $this->helper, Server::get(IConfig::class), Server::get(LoggerInterface::class));
}
/**
@@ -151,23 +142,23 @@ abstract class AbstractIntegrationTest {
public function run() {
$methods = get_class_methods($this);
$atLeastOneCaseRan = false;
- foreach($methods as $method) {
- if(strpos($method, 'case') === 0) {
+ foreach ($methods as $method) {
+ if (str_starts_with($method, 'case')) {
print("running $method " . PHP_EOL);
try {
- if(!$this->$method()) {
+ if (!$this->$method()) {
print(PHP_EOL . '>>> !!! Test ' . $method . ' FAILED !!! <<<' . PHP_EOL . PHP_EOL);
exit(1);
}
$atLeastOneCaseRan = true;
- } catch(\Exception $e) {
+ } catch (\Exception $e) {
print(PHP_EOL . '>>> !!! Test ' . $method . ' RAISED AN EXCEPTION !!! <<<' . PHP_EOL);
print($e->getMessage() . PHP_EOL . PHP_EOL);
exit(1);
}
}
}
- if($atLeastOneCaseRan) {
+ if ($atLeastOneCaseRan) {
print('Tests succeeded' . PHP_EOL);
} else {
print('No Test was available.' . PHP_EOL);
diff --git a/apps/user_ldap/tests/Integration/Bootstrap.php b/apps/user_ldap/tests/Integration/Bootstrap.php
index 46299098ab2..ef0909d4bea 100644
--- a/apps/user_ldap/tests/Integration/Bootstrap.php
+++ b/apps/user_ldap/tests/Integration/Bootstrap.php
@@ -1,26 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @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: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
define('CLI_TEST_RUN', true);
-require_once __DIR__ . '/../../../../lib/base.php';
+require_once __DIR__ . '/../../../../lib/base.php';
require_once __DIR__ . '/setup-scripts/config.php';
diff --git a/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php b/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php
index 32dfb72d9c1..3eec3df675a 100644
--- a/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php
+++ b/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php
@@ -1,32 +1,16 @@
<?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>
- *
- * @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;
-
use OC\ServerNotAvailableException;
use OCA\User_LDAP\LDAP;
+use OCP\App\IAppManager;
+use OCP\Server;
/**
* Class ExceptionOnLostConnection
@@ -35,48 +19,33 @@ use OCA\User_LDAP\LDAP;
*
* LDAP must be available via toxiproxy.
*
- * This test must be run manually.
+ * This test must be run manually.
*
*/
class ExceptionOnLostConnection {
- /** @var string */
- private $toxiProxyHost;
-
- /** @var string */
- private $toxiProxyName;
-
- /** @var string */
- private $ldapBase;
-
- /** @var string|null */
- private $ldapBindDN;
-
- /** @var string|null */
- private $ldapBindPwd;
-
- /** @var string */
+ /** @var string */
private $ldapHost;
- /** @var \OCA\User_LDAP\LDAP */
+ /** @var LDAP */
private $ldap;
- /** @var bool */
+ /** @var bool */
private $originalProxyState;
/**
- * @param string $proxyHost host of toxiproxy as url, like http://localhost:8474
- * @param string $proxyName name of the LDAP proxy service as configured in toxiProxy
+ * @param string $toxiProxyHost host of toxiproxy as url, like http://localhost:8474
+ * @param string $toxiProxyName name of the LDAP proxy service as configured in toxiProxy
* @param string $ldapBase any valid LDAP base DN
- * @param null $bindDN optional, bind DN if anonymous bind is not possible
- * @param null $bindPwd optional
+ * @param null $ldapBindDN optional, bind DN if anonymous bind is not possible
+ * @param null $ldapBindPwd optional
*/
- public function __construct($proxyHost, $proxyName, $ldapBase, $bindDN = null, $bindPwd = null) {
- $this->toxiProxyHost = $proxyHost;
- $this->toxiProxyName = $proxyName;
- $this->ldapBase = $ldapBase;
- $this->ldapBindDN = $bindDN;
- $this->ldapBindPwd = $bindPwd;
-
+ public function __construct(
+ private $toxiProxyHost,
+ private $toxiProxyName,
+ private $ldapBase,
+ private $ldapBindDN = null,
+ private $ldapBindPwd = null,
+ ) {
$this->setUp();
}
@@ -94,9 +63,9 @@ class ExceptionOnLostConnection {
*
* @throws \Exception
*/
- public function setUp() {
- require_once __DIR__ . '/../../../../lib/base.php';
- \OC_App::loadApps('user_ldap');
+ public function setUp(): void {
+ require_once __DIR__ . '/../../../../lib/base.php';
+ Server::get(IAppManager::class)->loadApps(['user_ldap']);
$ch = $this->getCurl();
$proxyInfoJson = curl_exec($ch);
@@ -112,7 +81,7 @@ class ExceptionOnLostConnection {
* restores original state of the LDAP proxy, if necessary
*/
public function cleanUp() {
- if($this->originalProxyState === true) {
+ if ($this->originalProxyState === true) {
$this->setProxyState(true);
}
}
@@ -122,23 +91,23 @@ class ExceptionOnLostConnection {
* fail
*/
public function run() {
- if($this->originalProxyState === false) {
+ if ($this->originalProxyState === false) {
$this->setProxyState(true);
}
//host contains port, 2nd parameter will be ignored
$cr = $this->ldap->connect($this->ldapHost, 0);
$this->ldap->bind($cr, $this->ldapBindDN, $this->ldapBindPwd);
- $this->ldap->search($cr, $this->ldapBase, 'objectClass=*', array('dn'), true, 5);
+ $this->ldap->search($cr, $this->ldapBase, 'objectClass=*', ['dn'], true, 5);
// disable LDAP, will cause lost connection
$this->setProxyState(false);
try {
- $this->ldap->search($cr, $this->ldapBase, 'objectClass=*', array('dn'), true, 5);
+ $this->ldap->search($cr, $this->ldapBase, 'objectClass=*', ['dn'], true, 5);
} catch (ServerNotAvailableException $e) {
- print("Test PASSED" . PHP_EOL);
+ print('Test PASSED' . PHP_EOL);
exit(0);
}
- print("Test FAILED" . PHP_EOL);
+ print('Test FAILED' . PHP_EOL);
exit(1);
}
@@ -146,12 +115,12 @@ class ExceptionOnLostConnection {
* tests whether a curl operation ran successfully. If not, an exception
* is thrown
*
- * @param resource $ch
+ * @param resource|\CurlHandle $ch
* @param mixed $result
* @throws \Exception
*/
private function checkCurlResult($ch, $result) {
- if($result === false) {
+ if ($result === false) {
$error = curl_error($ch);
curl_close($ch);
throw new \Exception($error);
@@ -165,16 +134,16 @@ class ExceptionOnLostConnection {
* @throws \Exception
*/
private function setProxyState($isEnabled) {
- if(!is_bool($isEnabled)) {
+ if (!is_bool($isEnabled)) {
throw new \InvalidArgumentException('Bool expected');
}
$postData = json_encode(['enabled' => $isEnabled]);
$ch = $this->getCurl();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Content-Length: ' . strlen($postData))
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
+ 'Content-Type: application/json',
+ 'Content-Length: ' . strlen($postData)]
);
$recvd = curl_exec($ch);
$this->checkCurlResult($ch, $recvd);
@@ -182,7 +151,7 @@ class ExceptionOnLostConnection {
/**
* initializes a curl handler towards the toxiproxy LDAP proxy service
- * @return resource
+ * @return resource|\CurlHandle
*/
private function getCurl() {
$ch = curl_init();
@@ -195,4 +164,3 @@ class ExceptionOnLostConnection {
$test = new ExceptionOnLostConnection('http://localhost:8474', 'ldap', 'dc=owncloud,dc=bzoc');
$test->run();
-
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)');
}
/**
diff --git a/apps/user_ldap/tests/Integration/data/avatar-valid.jpg b/apps/user_ldap/tests/Integration/data/avatar-valid.jpg
index 61b5ec2e730..451b631eea6 100644
--- a/apps/user_ldap/tests/Integration/data/avatar-valid.jpg
+++ b/apps/user_ldap/tests/Integration/data/avatar-valid.jpg
Binary files differ
diff --git a/apps/user_ldap/tests/Integration/readme.md b/apps/user_ldap/tests/Integration/readme.md
index e20efef8fdc..d551387c903 100644
--- a/apps/user_ldap/tests/Integration/readme.md
+++ b/apps/user_ldap/tests/Integration/readme.md
@@ -1,3 +1,8 @@
+<!--
+ - SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+ - SPDX-License-Identifier: AGPL-3.0-only
+ -->
# Requirements #
Have (as in do copy if not already done) the following files from https://github.com/owncloud/administration/tree/master/ldap-testing copied into the directory "setup-scripts":
diff --git a/apps/user_ldap/tests/Integration/run-all.sh b/apps/user_ldap/tests/Integration/run-all.sh
index 02bab97e45f..a0739a019eb 100755
--- a/apps/user_ldap/tests/Integration/run-all.sh
+++ b/apps/user_ldap/tests/Integration/run-all.sh
@@ -1,5 +1,8 @@
#!/bin/bash
-
+#
+# SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
+#
trigger_notification() {
which notify-send 1>/dev/null
if [[ $? == 1 ]] ; then
diff --git a/apps/user_ldap/tests/Integration/run-test.sh b/apps/user_ldap/tests/Integration/run-test.sh
index 7a29db25670..1b674aa04f3 100755
--- a/apps/user_ldap/tests/Integration/run-test.sh
+++ b/apps/user_ldap/tests/Integration/run-test.sh
@@ -1,5 +1,8 @@
#!/bin/sh
-
+#
+# SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
+#
if [ $1 ] ; then
TESTSCRIPT=$1
else
diff --git a/apps/user_ldap/tests/Integration/setup-scripts/createExplicitGroups.php b/apps/user_ldap/tests/Integration/setup-scripts/createExplicitGroups.php
index 597b85020c8..819c4c6e860 100644
--- a/apps/user_ldap/tests/Integration/setup-scripts/createExplicitGroups.php
+++ b/apps/user_ldap/tests/Integration/setup-scripts/createExplicitGroups.php
@@ -1,26 +1,11 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @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: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-if(php_sapi_name() !== 'cli') {
+if (php_sapi_name() !== 'cli') {
print('Only via CLI, please.');
exit(1);
}
diff --git a/apps/user_ldap/tests/Integration/setup-scripts/createExplicitGroupsDifferentOU.php b/apps/user_ldap/tests/Integration/setup-scripts/createExplicitGroupsDifferentOU.php
index b99115074a4..b0a3cd46b4f 100644
--- a/apps/user_ldap/tests/Integration/setup-scripts/createExplicitGroupsDifferentOU.php
+++ b/apps/user_ldap/tests/Integration/setup-scripts/createExplicitGroupsDifferentOU.php
@@ -1,26 +1,11 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @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: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-if(php_sapi_name() !== 'cli') {
+if (php_sapi_name() !== 'cli') {
print('Only via CLI, please.');
exit(1);
}
diff --git a/apps/user_ldap/tests/Integration/setup-scripts/createExplicitUsers.php b/apps/user_ldap/tests/Integration/setup-scripts/createExplicitUsers.php
index b01c498f859..7137bd18a58 100644
--- a/apps/user_ldap/tests/Integration/setup-scripts/createExplicitUsers.php
+++ b/apps/user_ldap/tests/Integration/setup-scripts/createExplicitUsers.php
@@ -1,26 +1,11 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @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
*/
-if(php_sapi_name() !== 'cli') {
+if (php_sapi_name() !== 'cli') {
print('Only via CLI, please.');
exit(1);
}
diff --git a/apps/user_ldap/tests/Integration/setup-scripts/createUsersWithoutDisplayName.php b/apps/user_ldap/tests/Integration/setup-scripts/createUsersWithoutDisplayName.php
index e08dd798341..18584fbe748 100644
--- a/apps/user_ldap/tests/Integration/setup-scripts/createUsersWithoutDisplayName.php
+++ b/apps/user_ldap/tests/Integration/setup-scripts/createUsersWithoutDisplayName.php
@@ -1,25 +1,11 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @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: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-if(php_sapi_name() !== 'cli') {
+if (php_sapi_name() !== 'cli') {
print('Only via CLI, please.');
exit(1);
}