diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-12-09 18:08:14 +0300 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-12-11 18:20:04 +0300 |
commit | 7d3e40c0658a4195a38458a5512894c91147ea2d (patch) | |
tree | e1db765f01db70b20599b241a647d1c86a4bfd97 /build | |
parent | 0449dc387b7ca8de56ccf76084b542ca8455c885 (diff) |
Add an OCS app for testing instead of using sudo and exec
Diffstat (limited to 'build')
-rw-r--r-- | build/integration/features/bootstrap/CapabilitiesContext.php | 80 | ||||
-rw-r--r-- | build/integration/features/provisioning-v1.feature | 5 |
2 files changed, 44 insertions, 41 deletions
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 - - - - - |