aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/testing/appinfo/info.xml12
-rw-r--r--apps/testing/appinfo/routes.php46
-rw-r--r--apps/testing/config.php70
-rw-r--r--build/integration/features/bootstrap/CapabilitiesContext.php80
-rw-r--r--build/integration/features/provisioning-v1.feature5
5 files changed, 172 insertions, 41 deletions
diff --git a/apps/testing/appinfo/info.xml b/apps/testing/appinfo/info.xml
new file mode 100644
index 00000000000..b11ec2f88e6
--- /dev/null
+++ b/apps/testing/appinfo/info.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<info>
+ <id>testing</id>
+ <name>QA Testing</name>
+ <description>This app is only for testing! It is dangerous to have it enabled in a live instance</description>
+ <licence>AGPL</licence>
+ <author>Joas Schilling</author>
+ <version>0.1.0</version>
+ <dependencies>
+ <owncloud min-version="9.0" />
+ </dependencies>
+</info>
diff --git a/apps/testing/appinfo/routes.php b/apps/testing/appinfo/routes.php
new file mode 100644
index 00000000000..b6f20d04ef2
--- /dev/null
+++ b/apps/testing/appinfo/routes.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Testing\AppInfo;
+
+use OCA\Testing\Config;
+use OCP\API;
+
+$config = new Config(
+ \OC::$server->getConfig(),
+ \OC::$server->getRequest()
+);
+
+API::register(
+ 'post',
+ '/apps/testing/api/v1/app/{appid}/{configkey}',
+ [$config, 'setAppValue'],
+ 'testing',
+ API::ADMIN_AUTH
+);
+
+API::register(
+ 'delete',
+ '/apps/testing/api/v1/app/{appid}/{configkey}',
+ [$config, 'deleteAppValue'],
+ 'testing',
+ API::ADMIN_AUTH
+);
diff --git a/apps/testing/config.php b/apps/testing/config.php
new file mode 100644
index 00000000000..068cb28e04b
--- /dev/null
+++ b/apps/testing/config.php
@@ -0,0 +1,70 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Testing;
+
+use OCP\IConfig;
+use OCP\IRequest;
+
+class Config {
+
+ /** @var IConfig */
+ private $config;
+
+ /** @var IRequest */
+ private $request;
+
+ /**
+ * @param IConfig $config
+ * @param IRequest $request
+ */
+ public function __construct(IConfig $config, IRequest $request) {
+ $this->config = $config;
+ $this->request = $request;
+ }
+
+ /**
+ * @param array $parameters
+ * @return \OC_OCS_Result
+ */
+ public function setAppValue($parameters) {
+ $app = $parameters['appid'];
+ $configKey = $parameters['configkey'];
+
+ $value = $this->request->getParam('value');
+ $this->config->setAppValue($app, $configKey, $value);
+
+ return new \OC_OCS_Result();
+ }
+
+ /**
+ * @param array $parameters
+ * @return \OC_OCS_Result
+ */
+ public function deleteAppValue($parameters) {
+ $app = $parameters['appid'];
+ $configKey = $parameters['configkey'];
+
+ $this->config->deleteAppValue($app, $configKey);
+
+ return new \OC_OCS_Result();
+ }
+}
diff --git a/build/integration/features/bootstrap/CapabilitiesContext.php b/build/integration/features/bootstrap/CapabilitiesContext.php
index 9cdd98cc059..ee13db4bcba 100644
--- a/build/integration/features/bootstrap/CapabilitiesContext.php
+++ b/build/integration/features/bootstrap/CapabilitiesContext.php
@@ -14,30 +14,21 @@ class CapabilitiesContext implements Context, SnippetAcceptingContext {
use Provisioning;
use Sharing;
- private $apacheUser = NULL;
-
/**
* @Given /^parameter "([^"]*)" of app "([^"]*)" is set to "([^"]*)"$/
*/
public function serverParameterIsSetTo($parameter, $app, $value){
- if (!isset($this->apacheUser)){
- $this->apacheUser = $this->getOSApacheUser();
- }
- $this->modifyServerConfig($this->apacheUser, $parameter, $app, $value);
+ $this->modifyServerConfig($app, $parameter, $value);
}
/**
* @Then /^fields of capabilities match with$/
* @param \Behat\Gherkin\Node\TableNode|null $formData
*/
- public function checkCapabilitiesResponse($formData){
- if ($formData instanceof \Behat\Gherkin\Node\TableNode) {
- $fd = $formData->getHash();
- }
-
+ public function checkCapabilitiesResponse(\Behat\Gherkin\Node\TableNode $formData){
$capabilitiesXML = $this->response->xml()->data->capabilities;
-
- foreach ($fd as $row) {
+
+ foreach ($formData->getHash() as $row) {
if ($row['value'] === ''){
$answeredValue = (string)$capabilitiesXML->$row['capability']->$row['feature'];
PHPUnit_Framework_Assert::assertEquals(
@@ -47,7 +38,7 @@ class CapabilitiesContext implements Context, SnippetAcceptingContext {
);
} else{
$answeredValue = (string)$capabilitiesXML->$row['capability']->$row['feature']->$row['value_or_subfeature'];
- PHPUnit_Framework_Assert::assertEquals(
+ PHPUnit_Framework_Assert::assertEquals(
$answeredValue,
$row['value']==="EMPTY" ? '' : $row['value'],
"Failed field: " . $row['capability'] . " " . $row['feature'] . " " . $row['value_or_subfeature']
@@ -56,36 +47,53 @@ class CapabilitiesContext implements Context, SnippetAcceptingContext {
}
}
- public static function modifyServerConfig($apacheUser, $parameter, $app, $value){
- $comando = 'sudo -u ' . $apacheUser . ' ../../occ config:app:set ' . $app . " " . $parameter . ' --value=' . $value;
- $expectedAnswer = "Config value $parameter for app $app set to $value";
- $output = exec($comando);
- PHPUnit_Framework_Assert::assertEquals(
- $output,
- $expectedAnswer,
- "Failed setting $parameter to $value"
- );
-
- }
-
- public static function getOSApacheUser(){
- return exec('ps axho user,comm|grep -E "httpd|apache"|uniq|grep -v "root"|awk \'END {if ($1) print $1}\'');
+ /**
+ * @BeforeScenario
+ */
+ public function prepareParameters(){
+ $this->modifyServerConfig('core', 'shareapi_allow_public_upload', 'yes');
}
/**
- * @BeforeSuite
+ * @AfterScenario
*/
- public static function prepareParameters(){
- $apacheUser = self::getOSApacheUser();
- self::modifyServerConfig($apacheUser, "shareapi_allow_public_upload", "core", "yes");
+ public function undoChangingParameters(){
+ $this->modifyServerConfig('core', 'shareapi_allow_public_upload', 'yes');
}
/**
- * @AfterSuite
+ * @param string $app
+ * @param string $parameter
+ * @param string $value
*/
- public static function undoChangingParameters(){
- $apacheUser = self::getOSApacheUser();
- self::modifyServerConfig($apacheUser, "shareapi_allow_public_upload", "core", "yes");
+ protected function modifyServerConfig($app, $parameter, $value) {
+ $user = $this->currentUser;
+
+ $this->currentUser = 'admin';
+
+ $this->setStatusTestingApp(true);
+
+ $body = new \Behat\Gherkin\Node\TableNode([['value', $value]]);
+ $this->sendingToWith('post', "/apps/testing/api/v1/app/{$app}/{$parameter}", $body);
+ $this->theHTTPStatusCodeShouldBe('200');
+ $this->theOCSStatusCodeShouldBe('100');
+
+ $this->setStatusTestingApp(false);
+
+ $this->currentUser = $user;
}
+ protected function setStatusTestingApp($enabled) {
+ $this->sendingTo(($enabled ? 'post' : 'delete'), '/cloud/apps/testing');
+ $this->theHTTPStatusCodeShouldBe('200');
+ $this->theOCSStatusCodeShouldBe('100');
+
+ $this->sendingTo('get', '/cloud/apps?filter=enabled');
+ $this->theHTTPStatusCodeShouldBe('200');
+ if ($enabled) {
+ PHPUnit_Framework_Assert::assertContains('testing', $this->response->getBody()->getContents());
+ } else {
+ PHPUnit_Framework_Assert::assertNotContains('testing', $this->response->getBody()->getContents());
+ }
+ }
}
diff --git a/build/integration/features/provisioning-v1.feature b/build/integration/features/provisioning-v1.feature
index 2a3e8e07fc4..467ac448e94 100644
--- a/build/integration/features/provisioning-v1.feature
+++ b/build/integration/features/provisioning-v1.feature
@@ -291,8 +291,3 @@ Feature: provisioning
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And app "files_external" is disabled
-
-
-
-
-