summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Bertolin <sbertolin@solidgear.es>2015-10-22 13:28:48 +0000
committerSergio Bertolin <sbertolin@solidgear.es>2015-10-22 13:28:48 +0000
commit64ea35af05861c421aef07d0e107f755e0e83e4f (patch)
tree070f8b0e74d573515f3c2d44245a08b59c9a0bff
parent5e9dc381b44bff03764dd3e14d2afbb9b07c952b (diff)
downloadnextcloud-server-64ea35af05861c421aef07d0e107f755e0e83e4f.tar.gz
nextcloud-server-64ea35af05861c421aef07d0e107f755e0e83e4f.zip
added tests for apps
-rw-r--r--build/integration/features/bootstrap/FeatureContext.php57
-rw-r--r--build/integration/features/provisioning-v1.feature37
2 files changed, 94 insertions, 0 deletions
diff --git a/build/integration/features/bootstrap/FeatureContext.php b/build/integration/features/bootstrap/FeatureContext.php
index 45dd23ddf17..70e73b66a71 100644
--- a/build/integration/features/bootstrap/FeatureContext.php
+++ b/build/integration/features/bootstrap/FeatureContext.php
@@ -86,6 +86,15 @@ class FeatureContext extends BehatContext {
}
/**
+ * 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.
*/
public function simplifyArray($arrayOfArrays){
@@ -144,6 +153,20 @@ class FeatureContext extends BehatContext {
}
/**
+ * @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 "([^"]*)"$/
*/
public function theOCSStatusCodeShouldBe($statusCode) {
@@ -276,6 +299,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"$/
*/
public function creatingTheUser($user) {
diff --git a/build/integration/features/provisioning-v1.feature b/build/integration/features/provisioning-v1.feature
index 3a291c1b69c..91050e82c28 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
+
+
+