diff options
Diffstat (limited to 'apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php')
-rw-r--r-- | apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php | 79 |
1 files changed, 24 insertions, 55 deletions
diff --git a/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php b/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php index fa46f73054c..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 Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @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 @@ -39,44 +23,29 @@ use OCA\User_LDAP\LDAP; * */ 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(); } @@ -95,8 +64,8 @@ class ExceptionOnLostConnection { * @throws \Exception */ public function setUp(): void { - require_once __DIR__ . '/../../../../lib/base.php'; - \OC_App::loadApps(['user_ldap']); + require_once __DIR__ . '/../../../../lib/base.php'; + Server::get(IAppManager::class)->loadApps(['user_ldap']); $ch = $this->getCurl(); $proxyInfoJson = curl_exec($ch); @@ -135,10 +104,10 @@ class ExceptionOnLostConnection { try { $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); } |