Merge pull request #19362 from owncloud/fix_capabilities_shareAPI
Reflect enabled shareAPI in capabilities
This commit is contained in:
commit
87e067f4c8
|
@ -45,6 +45,14 @@ class Capabilities implements ICapability {
|
|||
public function getCapabilities() {
|
||||
$res = [];
|
||||
|
||||
if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
|
||||
$res['api_enabled'] = false;
|
||||
$res['public'] = ['enabled' => false];
|
||||
$res['user'] = ['send_mail' => false];
|
||||
$res['resharing'] = false;
|
||||
} else {
|
||||
$res['api_enabled'] = true;
|
||||
|
||||
$public = [];
|
||||
$public['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes';
|
||||
if ($public['enabled']) {
|
||||
|
@ -66,7 +74,7 @@ class Capabilities implements ICapability {
|
|||
$res['user']['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'no') === 'yes';
|
||||
|
||||
$res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes';
|
||||
|
||||
}
|
||||
|
||||
//Federated sharing
|
||||
$res['federation'] = [
|
||||
|
|
|
@ -56,8 +56,31 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
return $result;
|
||||
}
|
||||
|
||||
public function testEnabledSharingAPI() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
];
|
||||
$result = $this->getResults($map);
|
||||
$this->assertTrue($result['api_enabled']);
|
||||
$this->assertContains('public', $result);
|
||||
$this->assertContains('user', $result);
|
||||
$this->assertContains('resharing', $result);
|
||||
}
|
||||
|
||||
public function testDisabledSharingAPI() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'no'],
|
||||
];
|
||||
$result = $this->getResults($map);
|
||||
$this->assertFalse($result['api_enabled']);
|
||||
$this->assertNotContains('public', $result);
|
||||
$this->assertNotContains('user', $result);
|
||||
$this->assertNotContains('resharing', $result);
|
||||
}
|
||||
|
||||
public function testNoLinkSharing() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_links', 'yes', 'no'],
|
||||
];
|
||||
$result = $this->getResults($map);
|
||||
|
@ -67,6 +90,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testOnlyLinkSharing() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
||||
];
|
||||
$result = $this->getResults($map);
|
||||
|
@ -76,6 +100,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testLinkPassword() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
||||
['core', 'shareapi_enforce_links_password', 'no', 'yes'],
|
||||
];
|
||||
|
@ -87,6 +112,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testLinkNoPassword() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
||||
['core', 'shareapi_enforce_links_password', 'no', 'no'],
|
||||
];
|
||||
|
@ -98,6 +124,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testLinkNoExpireDate() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
||||
['core', 'shareapi_default_expire_date', 'no', 'no'],
|
||||
];
|
||||
|
@ -109,6 +136,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testLinkExpireDate() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
||||
['core', 'shareapi_default_expire_date', 'no', 'yes'],
|
||||
['core', 'shareapi_expire_after_n_days', '7', '7'],
|
||||
|
@ -124,6 +152,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testLinkExpireDateEnforced() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
||||
['core', 'shareapi_default_expire_date', 'no', 'yes'],
|
||||
['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
|
||||
|
@ -136,6 +165,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testLinkSendMail() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_public_notification', 'no', 'yes'],
|
||||
];
|
||||
|
@ -145,6 +175,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testLinkNoSendMail() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_public_notification', 'no', 'no'],
|
||||
];
|
||||
|
@ -154,6 +185,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testUserSendMail() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_mail_notification', 'no', 'yes'],
|
||||
];
|
||||
$result = $this->getResults($map);
|
||||
|
@ -162,6 +194,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testUserNoSendMail() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_mail_notification', 'no', 'no'],
|
||||
];
|
||||
$result = $this->getResults($map);
|
||||
|
@ -170,6 +203,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testResharing() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_resharing', 'yes', 'yes'],
|
||||
];
|
||||
$result = $this->getResults($map);
|
||||
|
@ -178,6 +212,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testNoResharing() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_resharing', 'yes', 'no'],
|
||||
];
|
||||
$result = $this->getResults($map);
|
||||
|
@ -186,6 +221,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testLinkPublicUpload() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_public_upload', 'yes', 'yes'],
|
||||
];
|
||||
|
@ -195,6 +231,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
|
|||
|
||||
public function testLinkNoPublicUpload() {
|
||||
$map = [
|
||||
['core', 'shareapi_enabled', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
||||
['core', 'shareapi_allow_public_upload', 'yes', 'no'],
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue