diff --git a/build/integration/features/bootstrap/FeatureContext.php b/build/integration/features/bootstrap/FeatureContext.php index 45dd23ddf1..70e73b66a7 100644 --- a/build/integration/features/bootstrap/FeatureContext.php +++ b/build/integration/features/bootstrap/FeatureContext.php @@ -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"$/ */ diff --git a/build/integration/features/provisioning-v1.feature b/build/integration/features/provisioning-v1.feature index 3a291c1b69..91050e82c2 100644 --- a/build/integration/features/provisioning-v1.feature +++ b/build/integration/features/provisioning-v1.feature @@ -249,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 + + +