summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestBatchApplyUserAttributes.php81
-rw-r--r--build/integration/features/bootstrap/LDAPContext.php17
-rw-r--r--build/integration/ldap_features/ldap-openldap.feature17
3 files changed, 22 insertions, 93 deletions
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/build/integration/features/bootstrap/LDAPContext.php b/build/integration/features/bootstrap/LDAPContext.php
index ce63bc3f698..a4a878b1ca8 100644
--- a/build/integration/features/bootstrap/LDAPContext.php
+++ b/build/integration/features/bootstrap/LDAPContext.php
@@ -141,17 +141,16 @@ class LDAPContext implements Context {
}
/**
- * @Given /^the group result should$/
+ * @Given /^the "([^"]*)" result should match$/
*/
- public function theGroupResultShould(TableNode $expectations) {
- $listReturnedGroups = simplexml_load_string($this->response->getBody())->data[0]->groups[0]->element;
- $extractedGroupsArray = json_decode(json_encode($listReturnedGroups), 1);
-
- foreach($expectations->getRows() as $groupExpectation) {
- if((int)$groupExpectation[1] === 1) {
- PHPUnit_Framework_Assert::assertContains($groupExpectation[0], $extractedGroupsArray);
+ public function theGroupResultShouldMatch(string $type, TableNode $expectations) {
+ $listReturnedElements = simplexml_load_string($this->response->getBody())->data[0]->$type[0]->element;
+ $extractedIDsArray = json_decode(json_encode($listReturnedElements), 1);
+ foreach($expectations->getRows() as $expectation) {
+ if((int)$expectation[1] === 1) {
+ PHPUnit_Framework_Assert::assertContains($expectation[0], $extractedIDsArray);
} else {
- PHPUnit_Framework_Assert::assertNotContains($groupExpectation[0], $extractedGroupsArray);
+ PHPUnit_Framework_Assert::assertNotContains($expectation[0], $extractedIDsArray);
}
}
}
diff --git a/build/integration/ldap_features/ldap-openldap.feature b/build/integration/ldap_features/ldap-openldap.feature
index 13e011bb0c8..d992f77c67c 100644
--- a/build/integration/ldap_features/ldap-openldap.feature
+++ b/build/integration/ldap_features/ldap-openldap.feature
@@ -17,6 +17,17 @@ Feature: LDAP
| email | alice@nextcloud.ci |
| displayname | Alice |
+ Scenario: Look for a expected LDAP users
+ Given having a valid LDAP configuration
+ And modify LDAP configuration
+ | ldapExpertUsernameAttr | uid |
+ And As an "admin"
+ And sending "GET" to "/cloud/users"
+ Then the OCS status code should be "200"
+ And the "users" result should match
+ | alice | 1 |
+ | ghost | 0 |
+
Scenario: Test group filter with one specific group
Given having a valid LDAP configuration
And modify LDAP configuration
@@ -25,7 +36,7 @@ Feature: LDAP
And As an "admin"
And sending "GET" to "/cloud/groups"
Then the OCS status code should be "200"
- And the group result should
+ And the "groups" result should match
| RedGroup | 1 |
| GreenGroup | 0 |
| BlueGroup | 0 |
@@ -39,7 +50,7 @@ Feature: LDAP
And As an "admin"
And sending "GET" to "/cloud/groups"
Then the OCS status code should be "200"
- And the group result should
+ And the "groups" result should match
| RedGroup | 1 |
| GreenGroup | 1 |
| BlueGroup | 0 |
@@ -53,7 +64,7 @@ Feature: LDAP
And As an "admin"
And sending "GET" to "/cloud/groups"
Then the OCS status code should be "200"
- And the group result should
+ And the "groups" result should match
| RedGroup | 1 |
| GreenGroup | 1 |
| BlueGroup | 1 |