diff options
4 files changed, 84 insertions, 57 deletions
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php index d54d001c4ad..fcb2e59b4a9 100644 --- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php +++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php @@ -59,29 +59,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']; @@ -102,23 +84,6 @@ class IntegrationTestPaging extends AbstractIntegrationTest { 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/build/integration/features/bootstrap/LDAPContext.php b/build/integration/features/bootstrap/LDAPContext.php index a4a878b1ca8..5b226753e5c 100644 --- a/build/integration/features/bootstrap/LDAPContext.php +++ b/build/integration/features/bootstrap/LDAPContext.php @@ -167,4 +167,19 @@ class LDAPContext implements Context { } PHPUnit_Framework_Assert::assertTrue(false, 'expected Exception not received'); } + + /** + * @Given /^the "([^"]*)" result should contain "([^"]*)" of$/ + */ + public function theResultShouldContainOf($type, $expectedCount, TableNode $expectations) { + $listReturnedElements = simplexml_load_string($this->response->getBody())->data[0]->$type[0]->element; + $extractedIDsArray = json_decode(json_encode($listReturnedElements), 1); + $uidsFound = 0; + foreach($expectations->getRows() as $expectation) { + if(in_array($expectation[0], $extractedIDsArray)) { + $uidsFound++; + } + } + PHPUnit_Framework_Assert::assertSame((int)$expectedCount, $uidsFound); + } } diff --git a/build/integration/ldap_features/ldap-openldap.feature b/build/integration/ldap_features/ldap-openldap.feature index 311334a7b49..299142cfedc 100644 --- a/build/integration/ldap_features/ldap-openldap.feature +++ b/build/integration/ldap_features/ldap-openldap.feature @@ -80,26 +80,25 @@ Feature: LDAP | PurpleGroup | 1 | | SquareGroup | 0 | - Scenario: Test backup server - Given modify LDAP configuration - | ldapBackupHost | openldap | - | ldapBackupPort | 389 | - | ldapHost | foo.bar | - | ldapPort | 2456 | - And Logging in using web as "alice" - Then the HTTP status code should be "200" - - Scenario: Test backup server offline - Given modify LDAP configuration - | ldapBackupHost | off.line | - | ldapBackupPort | 3892 | - | ldapHost | foo.bar | - | ldapPort | 2456 | - Then Expect ServerException on failed web login as "alice" + Scenario: Test backup server + Given modify LDAP configuration + | ldapBackupHost | openldap | + | ldapBackupPort | 389 | + | ldapHost | foo.bar | + | ldapPort | 2456 | + And Logging in using web as "alice" + Then the HTTP status code should be "200" - Scenario: Test LDAP server offline, no backup server - Given modify LDAP configuration - | ldapHost | foo.bar | - | ldapPort | 2456 | - Then Expect ServerException on failed web login as "alice" + Scenario: Test backup server offline + Given modify LDAP configuration + | ldapBackupHost | off.line | + | ldapBackupPort | 3892 | + | ldapHost | foo.bar | + | ldapPort | 2456 | + Then Expect ServerException on failed web login as "alice" + Scenario: Test LDAP server offline, no backup server + Given modify LDAP configuration + | ldapHost | foo.bar | + | ldapPort | 2456 | + Then Expect ServerException on failed web login as "alice" diff --git a/build/integration/ldap_features/openldap-uid-username.feature b/build/integration/ldap_features/openldap-uid-username.feature index a8bb20abf8e..aa6010875c1 100644 --- a/build/integration/ldap_features/openldap-uid-username.feature +++ b/build/integration/ldap_features/openldap-uid-username.feature @@ -12,3 +12,51 @@ Feature: LDAP And the "users" result should match | alice | 1 | | ghost | 0 | + + Scenario: Fetch all users, invoking pagination + Given modify LDAP configuration + | ldapBaseUsers | ou=PagingTest,dc=nextcloud,dc=ci | + | ldapPagingSize | 2 | + And As an "admin" + And sending "GET" to "/cloud/users" + Then the OCS status code should be "200" + And the "users" result should match + | ebba | 1 | + | eindis | 1 | + | fjolnir | 1 | + | gunna | 1 | + | juliana | 1 | + | leo | 1 | + | stigur | 1 | + + Scenario: Fetch all users, invoking pagination + Given modify LDAP configuration + | ldapBaseUsers | ou=PagingTest,dc=nextcloud,dc=ci | + | ldapPagingSize | 2 | + And As an "admin" + And sending "GET" to "/cloud/users?limit=10" + Then the OCS status code should be "200" + And the "users" result should match + | ebba | 1 | + | eindis | 1 | + | fjolnir | 1 | + | gunna | 1 | + | juliana | 1 | + | leo | 1 | + | stigur | 1 | + + Scenario: Fetch first foall users, invoking pagination + Given modify LDAP configuration + | ldapBaseUsers | ou=PagingTest,dc=nextcloud,dc=ci | + | ldapPagingSize | 2 | + And As an "admin" + And sending "GET" to "/cloud/users?limit=10&offset=2" + Then the OCS status code should be "200" + And the "users" result should contain "5" of + | ebba | + | eindis | + | fjolnir | + | gunna | + | juliana | + | leo | + | stigur | |