Reset app configs by deleting the values instead of setting the defaults

This avoids the need to keep the default values in the integration tests
in sync with the code, and also makes possible to reset values with
"dynamic" defaults (defaults that depend on other values).

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2020-11-12 11:51:37 +01:00 committed by backportbot[bot]
parent 1464ace788
commit bf844567a5
5 changed files with 31 additions and 18 deletions

View File

@ -72,6 +72,19 @@ trait AppConfiguration {
} }
} }
/**
* @param string $app
* @param string $parameter
* @param string $value
*/
protected function deleteServerConfig($app, $parameter) {
$this->sendingTo('DELETE', "/apps/testing/api/v1/app/{$app}/{$parameter}");
$this->theHTTPStatusCodeShouldBe('200');
if ($this->apiVersion === 1) {
$this->theOCSStatusCodeShouldBe('100');
}
}
protected function setStatusTestingApp($enabled) { protected function setStatusTestingApp($enabled) {
$this->sendingTo(($enabled ? 'post' : 'delete'), '/cloud/apps/testing'); $this->sendingTo(($enabled ? 'post' : 'delete'), '/cloud/apps/testing');
$this->theHTTPStatusCodeShouldBe('200'); $this->theHTTPStatusCodeShouldBe('200');

View File

@ -61,16 +61,16 @@ class CapabilitiesContext implements Context, SnippetAcceptingContext {
} }
protected function resetAppConfigs() { protected function resetAppConfigs() {
$this->modifyServerConfig('core', 'shareapi_enabled', 'yes'); $this->deleteServerConfig('core', 'shareapi_enabled');
$this->modifyServerConfig('core', 'shareapi_allow_links', 'yes'); $this->deleteServerConfig('core', 'shareapi_allow_links');
$this->modifyServerConfig('core', 'shareapi_allow_public_upload', 'yes'); $this->deleteServerConfig('core', 'shareapi_allow_public_upload');
$this->modifyServerConfig('core', 'shareapi_allow_resharing', 'yes'); $this->deleteServerConfig('core', 'shareapi_allow_resharing');
$this->modifyServerConfig('files_sharing', 'outgoing_server2server_share_enabled', 'yes'); $this->deleteServerConfig('files_sharing', 'outgoing_server2server_share_enabled');
$this->modifyServerConfig('files_sharing', 'incoming_server2server_share_enabled', 'yes'); $this->deleteServerConfig('files_sharing', 'incoming_server2server_share_enabled');
$this->modifyServerConfig('core', 'shareapi_enforce_links_password', 'no'); $this->deleteServerConfig('core', 'shareapi_enforce_links_password');
$this->modifyServerConfig('core', 'shareapi_allow_public_notification', 'no'); $this->deleteServerConfig('core', 'shareapi_allow_public_notification');
$this->modifyServerConfig('core', 'shareapi_default_expire_date', 'no'); $this->deleteServerConfig('core', 'shareapi_default_expire_date');
$this->modifyServerConfig('core', 'shareapi_enforce_expire_date', 'no'); $this->deleteServerConfig('core', 'shareapi_enforce_expire_date');
$this->modifyServerConfig('core', 'shareapi_allow_group_sharing', 'yes'); $this->deleteServerConfig('core', 'shareapi_allow_group_sharing');
} }
} }

View File

@ -97,7 +97,7 @@ class FederationContext implements Context, SnippetAcceptingContext {
} }
protected function resetAppConfigs() { protected function resetAppConfigs() {
$this->modifyServerConfig('files_sharing', 'incoming_server2server_group_share_enabled', 'no'); $this->deleteServerConfig('files_sharing', 'incoming_server2server_group_share_enabled');
$this->modifyServerConfig('files_sharing', 'outgoing_server2server_group_share_enabled', 'no'); $this->deleteServerConfig('files_sharing', 'outgoing_server2server_group_share_enabled');
} }
} }

View File

@ -36,8 +36,8 @@ class ShareesContext implements Context, SnippetAcceptingContext {
use AppConfiguration; use AppConfiguration;
protected function resetAppConfigs() { protected function resetAppConfigs() {
$this->modifyServerConfig('core', 'shareapi_only_share_with_group_members', 'no'); $this->deleteServerConfig('core', 'shareapi_only_share_with_group_members');
$this->modifyServerConfig('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'); $this->deleteServerConfig('core', 'shareapi_allow_share_dialog_user_enumeration');
$this->modifyServerConfig('core', 'shareapi_allow_group_sharing', 'yes'); $this->deleteServerConfig('core', 'shareapi_allow_group_sharing');
} }
} }

View File

@ -37,7 +37,7 @@ class SharingContext implements Context, SnippetAcceptingContext {
use CommandLine; use CommandLine;
protected function resetAppConfigs() { protected function resetAppConfigs() {
$this->modifyServerConfig('core', 'shareapi_default_permissions', '31'); $this->deleteServerConfig('core', 'shareapi_default_permissions');
$this->modifyServerConfig('sharebymail', 'enforcePasswordProtection', 'no'); $this->deleteServerConfig('sharebymail', 'enforcePasswordProtection');
} }
} }