Merge pull request #19616 from owncloud/ocs_provisioning_api_checking_lists

Ocs provisioning api checking lists
This commit is contained in:
Thomas Müller 2015-10-08 16:17:30 +02:00
commit adeab41e2a
2 changed files with 64 additions and 1 deletions

View File

@ -49,7 +49,6 @@ class FeatureContext extends BehatContext {
$this->sendingToWith($verb, $url, null); $this->sendingToWith($verb, $url, null);
} }
/** /**
* Parses the xml answer to get ocs response which doesn't match with * Parses the xml answer to get ocs response which doesn't match with
* http one in v1 of the api. * http one in v1 of the api.
@ -58,6 +57,50 @@ class FeatureContext extends BehatContext {
return $response->xml()->meta[0]->statuscode; return $response->xml()->meta[0]->statuscode;
} }
/**
* Parses the xml answer to get the array of users returned.
*/
public function getArrayOfUsersResponded($resp) {
$listCheckedElements = $resp->xml()->data[0]->users[0]->element;
$extractedElementsArray = json_decode( json_encode($listCheckedElements) , 1);
return $extractedElementsArray;
}
/**
* Parses the xml answer to get the array of groups returned.
*/
public function getArrayOfGroupsResponded($resp) {
$listCheckedElements = $resp->xml()->data[0]->groups[0]->element;
$extractedElementsArray = json_decode( json_encode($listCheckedElements) , 1);
return $extractedElementsArray;
}
/**
* @Then /^users returned are$/
* @param \Behat\Gherkin\Node\TableNode|null $formData
*/
public function theUsersShouldBe($usersList) {
if ($usersList instanceof \Behat\Gherkin\Node\TableNode) {
$users = $usersList->getRows()[0];
$respondedArray = $this->getArrayOfUsersResponded($this->response);
PHPUnit_Framework_Assert::assertEquals(asort($users), asort($respondedArray));
}
}
/**
* @Then /^groups returned are$/
* @param \Behat\Gherkin\Node\TableNode|null $formData
*/
public function theGroupsShouldBe($groupsList) {
if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) {
$groups = $groupsList->getRows()[0];
$respondedArray = $this->getArrayOfGroupsResponded($this->response);
PHPUnit_Framework_Assert::assertEquals(asort($groups), asort($respondedArray));
}
}
/** /**
* @Then /^the OCS status code should be "([^"]*)"$/ * @Then /^the OCS status code should be "([^"]*)"$/
*/ */

View File

@ -40,6 +40,16 @@ Feature: provisioning
And the HTTP status code should be "200" And the HTTP status code should be "200"
Scenario: Getting all users
Given As an "admin"
And user "brand-new-user" exists
And user "admin" exists
When sending "GET" to "/cloud/users"
And users returned are
| brand-new-user |
| admin |
Scenario: Edit a user Scenario: Edit a user
Given As an "admin" Given As an "admin"
And user "brand-new-user" exists And user "brand-new-user" exists
@ -74,6 +84,16 @@ Feature: provisioning
And group "new-group" exists And group "new-group" exists
Scenario: Getting all groups
Given As an "admin"
And group "new-group" exists
And group "admin" exists
When sending "GET" to "/cloud/groups"
And groups returned are
| admin |
| new-group |
Scenario: Delete a group Scenario: Delete a group
Given As an "admin" Given As an "admin"
And group "new-group" exists And group "new-group" exists