summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-02-26 14:58:41 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-03-22 19:43:23 +0100
commit00f48ec37ba90254aca4643b2627bb2ffc7bd1fb (patch)
tree3ee7bbe37e47bdfb6b199e4b2f7ce293d9318394 /apps/files_sharing/tests
parent460bafea8a636beb450c939f0bfe57dc0229a8c2 (diff)
downloadnextcloud-server-00f48ec37ba90254aca4643b2627bb2ffc7bd1fb.tar.gz
nextcloud-server-00f48ec37ba90254aca4643b2627bb2ffc7bd1fb.zip
When the Share API is disabled do not return shares
Fixes #22668 Block everything in the OCS Share API
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/api/share20ocstest.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/apps/files_sharing/tests/api/share20ocstest.php b/apps/files_sharing/tests/api/share20ocstest.php
index a2c70d7673c..f641f683e79 100644
--- a/apps/files_sharing/tests/api/share20ocstest.php
+++ b/apps/files_sharing/tests/api/share20ocstest.php
@@ -65,6 +65,10 @@ class Share20OCSTest extends \Test\TestCase {
$this->shareManager = $this->getMockBuilder('OCP\Share\IManager')
->disableOriginalConstructor()
->getMock();
+ $this->shareManager
+ ->expects($this->any())
+ ->method('shareApiEnabled')
+ ->willReturn(true);
$this->groupManager = $this->getMock('OCP\IGroupManager');
$this->userManager = $this->getMock('OCP\IUserManager');
$this->request = $this->getMock('OCP\IRequest');
@@ -1827,7 +1831,74 @@ class Share20OCSTest extends \Test\TestCase {
} catch (NotFoundException $e) {
$this->assertTrue($exception);
}
+ }
+
+ /**
+ * @return Share20OCS
+ */
+ public function getOcsDisabledAPI() {
+ $shareManager = $this->getMockBuilder('OCP\Share\IManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $shareManager
+ ->expects($this->any())
+ ->method('shareApiEnabled')
+ ->willReturn(false);
+
+ return new Share20OCS(
+ $shareManager,
+ $this->groupManager,
+ $this->userManager,
+ $this->request,
+ $this->rootFolder,
+ $this->urlGenerator,
+ $this->currentUser
+ );
+ }
+
+ public function testGetShareApiDisabled() {
+ $ocs = $this->getOcsDisabledAPI();
+
+ $expected = new \OC_OCS_Result(null, 404, 'Share API is disabled');
+ $result = $ocs->getShare('my:id');
+
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testDeleteShareApiDisabled() {
+ $ocs = $this->getOcsDisabledAPI();
+
+ $expected = new \OC_OCS_Result(null, 404, 'Share API is disabled');
+ $result = $ocs->deleteShare('my:id');
+
+ $this->assertEquals($expected, $result);
+ }
+
+
+ public function testCreateShareApiDisabled() {
+ $ocs = $this->getOcsDisabledAPI();
+
+ $expected = new \OC_OCS_Result(null, 404, 'Share API is disabled');
+ $result = $ocs->createShare();
+
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testGetSharesApiDisabled() {
+ $ocs = $this->getOcsDisabledAPI();
+
+ $expected = new \OC_OCS_Result();
+ $result = $ocs->getShares();
+
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testUpdateShareApiDisabled() {
+ $ocs = $this->getOcsDisabledAPI();
+ $expected = new \OC_OCS_Result(null, 404, 'Share API is disabled');
+ $result = $ocs->updateShare('my:id');
+ $this->assertEquals($expected, $result);
}
}