Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2018-04-11 01:32:49 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2018-08-10 00:45:10 +0300
commit3450ed4536030ccc8ddd34836fc2e17ddc328a18 (patch)
tree8884e9d3f06de441e8e446aefe675439ef7068ef /build/integration
parentb4eeb9eff5b2892fc9c1da5f56fb1129730d07a6 (diff)
integration test checking the group filter
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'build/integration')
-rw-r--r--build/integration/features/bootstrap/LDAPContext.php31
-rw-r--r--build/integration/ldap_features/ldap-openldap.feature43
2 files changed, 74 insertions, 0 deletions
diff --git a/build/integration/features/bootstrap/LDAPContext.php b/build/integration/features/bootstrap/LDAPContext.php
index b1ccd59ab7b..4b9810aeff7 100644
--- a/build/integration/features/bootstrap/LDAPContext.php
+++ b/build/integration/features/bootstrap/LDAPContext.php
@@ -98,6 +98,7 @@ class LDAPContext implements Context {
['configData[ldapUserFilter]', '(&(objectclass=inetorgperson))'],
['configData[ldapLoginFilter]', '(&(objectclass=inetorgperson)(uid=%uid))'],
['configData[ldapUserDisplayName]', 'displayname'],
+ ['configData[ldapGroupDisplayName]', 'cn'],
['configData[ldapEmailAttribute]', 'mail'],
['configData[ldapConfigurationActive]', '1'],
]);
@@ -124,4 +125,34 @@ class LDAPContext implements Context {
$backend = (string)simplexml_load_string($this->response->getBody())->data[0]->backend;
PHPUnit_Framework_Assert::assertEquals('LDAP', $backend);
}
+
+ /**
+ * @Given /^modify LDAP configuration$/
+ */
+ public function modifyLDAPConfiguration(TableNode $table) {
+ $originalAsAn = $this->currentUser;
+ $this->asAn('admin');
+ $configData = $table->getRows();
+ foreach($configData as &$row) {
+ $row[0] = 'configData[' . $row[0] . ']';
+ }
+ $this->settingTheLDAPConfigurationTo(new TableNode($configData));
+ $this->asAn($originalAsAn);
+ }
+
+ /**
+ * @Given /^the group result should$/
+ */
+ 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);
+ } else {
+ PHPUnit_Framework_Assert::assertNotContains($groupExpectation[0], $extractedGroupsArray);
+ }
+ }
+ }
}
diff --git a/build/integration/ldap_features/ldap-openldap.feature b/build/integration/ldap_features/ldap-openldap.feature
index c63fdf1f9c5..a2b16950bb1 100644
--- a/build/integration/ldap_features/ldap-openldap.feature
+++ b/build/integration/ldap_features/ldap-openldap.feature
@@ -15,3 +15,46 @@ Feature: LDAP
And looking up details for the first result matches expectations
| email | alice@nextcloud.ci |
| displayname | Alice |
+
+ Scenario: Test group filter with one specific group
+ Given having a valid LDAP configuration
+ And modify LDAP configuration
+ | ldapGroupFilter | cn=RedGroup |
+ | ldapBaseGroups | ou=Groups,ou=Ordinary,dc=nextcloud,dc=ci |
+ And As an "admin"
+ And sending "GET" to "/cloud/groups"
+ Then the OCS status code should be "200"
+ And the group result should
+ | RedGroup | 1 |
+ | GreenGroup | 0 |
+ | BlueGroup | 0 |
+ | PurpleGroup | 0 |
+
+ Scenario: Test group filter with two specific groups
+ Given having a valid LDAP configuration
+ And modify LDAP configuration
+ | ldapGroupFilter | (\|(cn=RedGroup)(cn=GreenGroup)) |
+ | ldapBaseGroups | ou=Groups,ou=Ordinary,dc=nextcloud,dc=ci |
+ And As an "admin"
+ And sending "GET" to "/cloud/groups"
+ Then the OCS status code should be "200"
+ And the group result should
+ | RedGroup | 1 |
+ | GreenGroup | 1 |
+ | BlueGroup | 0 |
+ | PurpleGroup | 0 |
+
+ Scenario: Test group filter ruling out a group from a different base
+ Given having a valid LDAP configuration
+ And modify LDAP configuration
+ | ldapGroupFilter | (objectClass=groupOfNames) |
+ | ldapBaseGroups | ou=Groups,ou=Ordinary,dc=nextcloud,dc=ci |
+ And As an "admin"
+ And sending "GET" to "/cloud/groups"
+ Then the OCS status code should be "200"
+ And the group result should
+ | RedGroup | 1 |
+ | GreenGroup | 1 |
+ | BlueGroup | 1 |
+ | PurpleGroup | 1 |
+ | SquareGroup | 0 |