From 91dfcab0553a8bbc13df4b57e9fed061741bea74 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Sat, 12 Sep 2015 16:25:23 +0200 Subject: [PATCH] Expose federated sharing capabilities to authenticated users --- apps/files_sharing/lib/capabilities.php | 7 +++++ apps/files_sharing/tests/capabilities.php | 35 +++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/apps/files_sharing/lib/capabilities.php b/apps/files_sharing/lib/capabilities.php index ea71c47a05..b24eb8d61f 100644 --- a/apps/files_sharing/lib/capabilities.php +++ b/apps/files_sharing/lib/capabilities.php @@ -67,6 +67,13 @@ class Capabilities implements ICapability { $res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes'; + + //Federated sharing + $res['federation'] = [ + 'outgoing' => $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes', + 'incoming' => $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes' + ]; + return [ 'files_sharing' => $res, ]; diff --git a/apps/files_sharing/tests/capabilities.php b/apps/files_sharing/tests/capabilities.php index 5b9789ce32..f1a9626db9 100644 --- a/apps/files_sharing/tests/capabilities.php +++ b/apps/files_sharing/tests/capabilities.php @@ -202,5 +202,40 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase { $this->assertFalse($result['public']['upload']); } + public function testFederatedSharingIncomming() { + $map = [ + ['files_sharing', 'incoming_server2server_share_enabled', 'yes', 'yes'], + ]; + $result = $this->getResults($map); + $this->assertArrayHasKey('federation', $result); + $this->assertTrue($result['federation']['incoming']); + } + + public function testFederatedSharingNoIncomming() { + $map = [ + ['files_sharing', 'incoming_server2server_share_enabled', 'yes', 'no'], + ]; + $result = $this->getResults($map); + $this->assertArrayHasKey('federation', $result); + $this->assertFalse($result['federation']['incoming']); + } + + public function testFederatedSharingOutgoing() { + $map = [ + ['files_sharing', 'outgoing_server2server_share_enabled', 'yes', 'yes'], + ]; + $result = $this->getResults($map); + $this->assertArrayHasKey('federation', $result); + $this->assertTrue($result['federation']['outgoing']); + } + + public function testFederatedSharingNoOutgoing() { + $map = [ + ['files_sharing', 'outgoing_server2server_share_enabled', 'yes', 'no'], + ]; + $result = $this->getResults($map); + $this->assertArrayHasKey('federation', $result); + $this->assertFalse($result['federation']['outgoing']); + } }