Merge pull request #19977 from owncloud/provisioning_api_integration_tests_apps_new_getusers
Provisioning api integration tests added app tests and getusers by a subadmin
This commit is contained in:
commit
7afbf0f8c1
2 changed files with 118 additions and 11 deletions
|
@ -85,6 +85,15 @@ class FeatureContext extends BehatContext {
|
|||
return $extractedElementsArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the xml answer to get the array of apps returned.
|
||||
*/
|
||||
public function getArrayOfAppsResponded($resp) {
|
||||
$listCheckedElements = $resp->xml()->data[0]->apps[0]->element;
|
||||
$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
|
||||
return $extractedElementsArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is needed to use a vertical fashion in the gherkin tables.
|
||||
*/
|
||||
|
@ -143,6 +152,20 @@ class FeatureContext extends BehatContext {
|
|||
$this->theSubadminGroupsShouldBe($groupsList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^apps returned are$/
|
||||
* @param \Behat\Gherkin\Node\TableNode|null $formData
|
||||
*/
|
||||
public function theAppsShouldBe($appList) {
|
||||
if ($appList instanceof \Behat\Gherkin\Node\TableNode) {
|
||||
$apps = $appList->getRows();
|
||||
$appsSimplified = $this->simplifyArray($apps);
|
||||
$respondedArray = $this->getArrayOfAppsResponded($this->response);
|
||||
PHPUnit_Framework_Assert::assertEquals($appsSimplified, $respondedArray, "", 0.0, 10, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the OCS status code should be "([^"]*)"$/
|
||||
*/
|
||||
|
@ -275,6 +298,40 @@ class FeatureContext extends BehatContext {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^app "([^"]*)" is disabled$/
|
||||
*/
|
||||
public function appIsDisabled($app) {
|
||||
$fullUrl = $this->baseUrl . "v2.php/cloud/apps?filter=disabled";
|
||||
$client = new Client();
|
||||
$options = [];
|
||||
if ($this->currentUser === 'admin') {
|
||||
$options['auth'] = $this->adminUser;
|
||||
}
|
||||
|
||||
$this->response = $client->get($fullUrl, $options);
|
||||
$respondedArray = $this->getArrayOfAppsResponded($this->response);
|
||||
PHPUnit_Framework_Assert::assertContains($app, $respondedArray);
|
||||
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^app "([^"]*)" is enabled$/
|
||||
*/
|
||||
public function appIsEnabled($app) {
|
||||
$fullUrl = $this->baseUrl . "v2.php/cloud/apps?filter=enabled";
|
||||
$client = new Client();
|
||||
$options = [];
|
||||
if ($this->currentUser === 'admin') {
|
||||
$options['auth'] = $this->adminUser;
|
||||
}
|
||||
|
||||
$this->response = $client->get($fullUrl, $options);
|
||||
$respondedArray = $this->getArrayOfAppsResponded($this->response);
|
||||
PHPUnit_Framework_Assert::assertContains($app, $respondedArray);
|
||||
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^creating the user "([^"]*)r"$/
|
||||
*/
|
||||
|
@ -352,7 +409,7 @@ class FeatureContext extends BehatContext {
|
|||
if ($this->currentUser === 'admin') {
|
||||
$options['auth'] = $this->adminUser;
|
||||
} else {
|
||||
$options['auth'] = $this->regularUser;
|
||||
$options['auth'] = [$this->currentUser, $this->regularUser];
|
||||
}
|
||||
if ($body instanceof \Behat\Gherkin\Node\TableNode) {
|
||||
$fd = $body->getRowsHash();
|
||||
|
|
|
@ -112,16 +112,6 @@ Feature: provisioning
|
|||
| new-group |
|
||||
And the OCS status code should be "100"
|
||||
|
||||
Scenario: removing a user from a group
|
||||
Given As an "admin"
|
||||
And user "brand-new-user" exists
|
||||
And group "new-group" exists
|
||||
And user "brand-new-user" belongs to group "new-group"
|
||||
When sending "DELETE" to "/cloud/users/brand-new-user/groups" with
|
||||
| groupid | new-group |
|
||||
Then the OCS status code should be "100"
|
||||
And user "brand-new-user" does not belong to group "new-group"
|
||||
|
||||
Scenario: adding a user which doesn't exist to a group
|
||||
Given As an "admin"
|
||||
And user "not-user" does not exist
|
||||
|
@ -156,6 +146,29 @@ Feature: provisioning
|
|||
Then the OCS status code should be "100"
|
||||
And the HTTP status code should be "200"
|
||||
|
||||
Scenario: get users using a subadmin
|
||||
Given As an "admin"
|
||||
And user "brand-new-user" exists
|
||||
And group "new-group" exists
|
||||
And user "brand-new-user" belongs to group "new-group"
|
||||
And user "brand-new-user" is subadmin of group "new-group"
|
||||
And As an "brand-new-user"
|
||||
When sending "GET" to "/cloud/users"
|
||||
Then users returned are
|
||||
| brand-new-user |
|
||||
And the OCS status code should be "100"
|
||||
And the HTTP status code should be "200"
|
||||
|
||||
Scenario: removing a user from a group
|
||||
Given As an "admin"
|
||||
And user "brand-new-user" exists
|
||||
And group "new-group" exists
|
||||
And user "brand-new-user" belongs to group "new-group"
|
||||
When sending "DELETE" to "/cloud/users/brand-new-user/groups" with
|
||||
| groupid | new-group |
|
||||
Then the OCS status code should be "100"
|
||||
And user "brand-new-user" does not belong to group "new-group"
|
||||
|
||||
Scenario: create a subadmin using a user which not exist
|
||||
Given As an "admin"
|
||||
And user "not-user" does not exist
|
||||
|
@ -236,5 +249,42 @@ Feature: provisioning
|
|||
And the HTTP status code should be "200"
|
||||
And group "new-group" does not exist
|
||||
|
||||
Scenario: get enabled apps
|
||||
Given As an "admin"
|
||||
When sending "GET" to "/cloud/apps?filter=enabled"
|
||||
Then the OCS status code should be "100"
|
||||
And the HTTP status code should be "200"
|
||||
And apps returned are
|
||||
| files |
|
||||
| dav |
|
||||
| files_sharing |
|
||||
| files_trashbin |
|
||||
| files_versions |
|
||||
| provisioning_api |
|
||||
|
||||
Scenario: get app info
|
||||
Given As an "admin"
|
||||
When sending "GET" to "/cloud/apps/files"
|
||||
Then the OCS status code should be "100"
|
||||
And the HTTP status code should be "200"
|
||||
|
||||
Scenario: enable an app
|
||||
Given As an "admin"
|
||||
And app "files_external" is disabled
|
||||
When sending "POST" to "/cloud/apps/files_external"
|
||||
Then the OCS status code should be "100"
|
||||
And the HTTP status code should be "200"
|
||||
And app "files_external" is enabled
|
||||
|
||||
Scenario: disable an app
|
||||
Given As an "admin"
|
||||
And app "files_external" is enabled
|
||||
When sending "DELETE" to "/cloud/apps/files_external"
|
||||
Then the OCS status code should be "100"
|
||||
And the HTTP status code should be "200"
|
||||
And app "files_external" is disabled
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue