convert pagination tests
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
0f6d98eed2
commit
b069b13226
4 changed files with 84 additions and 57 deletions
|
@ -58,30 +58,12 @@ 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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
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 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"
|
||||
|
|
|
@ -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 |
|
||||
|
|
Loading…
Reference in a new issue