diff options
3 files changed, 31 insertions, 172 deletions
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/build/integration/features/bootstrap/BasicStructure.php b/build/integration/features/bootstrap/BasicStructure.php index 32e02bad2a3..f6c93aa5174 100644 --- a/build/integration/features/bootstrap/BasicStructure.php +++ b/build/integration/features/bootstrap/BasicStructure.php @@ -497,4 +497,11 @@ trait BasicStructure { $file->isDir() ? rmdir($file) : unlink($file); } } + + /** + * @Given /^cookies are reset$/ + */ + public function cookiesAreReset() { + $this->cookieJar = new CookieJar(); + } } diff --git a/build/integration/ldap_features/ldap-openldap.feature b/build/integration/ldap_features/ldap-openldap.feature index bd2e7bb85a1..311334a7b49 100644 --- a/build/integration/ldap_features/ldap-openldap.feature +++ b/build/integration/ldap_features/ldap-openldap.feature @@ -8,6 +8,30 @@ Feature: LDAP And Sending a "GET" to "/remote.php/webdav/welcome.txt" with requesttoken Then the HTTP status code should be "200" + Scenario: Test valid configuration with port in the hostname by logging in + Given modify LDAP configuration + | ldapHost | openldap:389 | + And cookies are reset + And Logging in using web as "alice" + And Sending a "GET" to "/remote.php/webdav/welcome.txt" with requesttoken + Then the HTTP status code should be "200" + + Scenario: Test valid configuration with LDAP protocol by logging in + Given modify LDAP configuration + | ldapHost | ldap://openldap | + And cookies are reset + And Logging in using web as "alice" + And Sending a "GET" to "/remote.php/webdav/welcome.txt" with requesttoken + Then the HTTP status code should be "200" + + Scenario: Test valid configuration with LDAP protoccol and port by logging in + Given modify LDAP configuration + | ldapHost | ldap://openldap:389 | + And cookies are reset + And Logging in using web as "alice" + And Sending a "GET" to "/remote.php/webdav/welcome.txt" with requesttoken + Then the HTTP status code should be "200" + Scenario: Look for a known LDAP user Given As an "admin" And sending "GET" to "/cloud/users?search=alice" |