Added functionality to change server configuration
This commit is contained in:
parent
4338a741f2
commit
0449dc387b
|
@ -22,7 +22,7 @@ Feature: capabilities
|
|||
|
||||
Scenario: Changing api_enabled
|
||||
Given As an "admin"
|
||||
And parameter "shareapi_allow_public_upload" is set to "0"
|
||||
And parameter "shareapi_allow_public_upload" of app "core" is set to "no"
|
||||
When sending "GET" to "/cloud/capabilities"
|
||||
Then the HTTP status code should be "200"
|
||||
And fields of capabilities match with
|
||||
|
@ -31,7 +31,7 @@ Feature: capabilities
|
|||
| core | webdav-root | remote.php/webdav | |
|
||||
| files_sharing | api_enabled | 1 | |
|
||||
| files_sharing | public | enabled | 1 |
|
||||
| files_sharing | public | upload | 0 |
|
||||
| files_sharing | public | upload | EMPTY |
|
||||
| files_sharing | resharing | 1 | |
|
||||
| files_sharing | federation | outgoing | 1 |
|
||||
| files_sharing | federation | incoming | 1 |
|
||||
|
|
|
@ -14,23 +14,16 @@ class CapabilitiesContext implements Context, SnippetAcceptingContext {
|
|||
use Provisioning;
|
||||
use Sharing;
|
||||
|
||||
private $apacheUser = '';
|
||||
private $apacheUser = NULL;
|
||||
|
||||
/**
|
||||
* @Given /^parameter "([^"]*)" is set to "([^"]*)"$/
|
||||
* @Given /^parameter "([^"]*)" of app "([^"]*)" is set to "([^"]*)"$/
|
||||
*/
|
||||
public function modifyServerConfig($parameter, $value){
|
||||
$this->apacheUser = exec('ps axho user,comm|grep -E "httpd|apache"|uniq|grep -v "root"|awk \'END {if ($1) print $1}\'');
|
||||
$comando = 'sudo -u ' . $this->apacheUser . ' ../../occ config:app:set ' . $parameter . ' ' . $value;
|
||||
echo "COMANDO: $comando\n";
|
||||
$expectedAnswer = "Config value $value for app $parameter set to";
|
||||
$output = exec($comando);
|
||||
PHPUnit_Framework_Assert::assertEquals(
|
||||
$output,
|
||||
$expectedAnswer,
|
||||
"Failed setting $parameter to $value"
|
||||
);
|
||||
|
||||
public function serverParameterIsSetTo($parameter, $app, $value){
|
||||
if (!isset($this->apacheUser)){
|
||||
$this->apacheUser = $this->getOSApacheUser();
|
||||
}
|
||||
$this->modifyServerConfig($this->apacheUser, $parameter, $app, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,11 +49,43 @@ class CapabilitiesContext implements Context, SnippetAcceptingContext {
|
|||
$answeredValue = (string)$capabilitiesXML->$row['capability']->$row['feature']->$row['value_or_subfeature'];
|
||||
PHPUnit_Framework_Assert::assertEquals(
|
||||
$answeredValue,
|
||||
$row['value'],
|
||||
$row['value']==="EMPTY" ? '' : $row['value'],
|
||||
"Failed field: " . $row['capability'] . " " . $row['feature'] . " " . $row['value_or_subfeature']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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}\'');
|
||||
}
|
||||
|
||||
/**
|
||||
* @BeforeSuite
|
||||
*/
|
||||
public static function prepareParameters(){
|
||||
$apacheUser = self::getOSApacheUser();
|
||||
self::modifyServerConfig($apacheUser, "shareapi_allow_public_upload", "core", "yes");
|
||||
}
|
||||
|
||||
/**
|
||||
* @AfterSuite
|
||||
*/
|
||||
public static function undoChangingParameters(){
|
||||
$apacheUser = self::getOSApacheUser();
|
||||
self::modifyServerConfig($apacheUser, "shareapi_allow_public_upload", "core", "yes");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue