aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2015-09-22 14:47:04 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2015-09-22 15:12:16 +0200
commit4dba046712ebe611ba946ae31d780eb48d224cf0 (patch)
tree4c3f0542735079926b05cb6d8de3dd5ff93ffb9f /apps/files_sharing
parent762e7c3dd98790cecd99b98e3ecb9e488458a302 (diff)
downloadnextcloud-server-4dba046712ebe611ba946ae31d780eb48d224cf0.tar.gz
nextcloud-server-4dba046712ebe611ba946ae31d780eb48d224cf0.zip
Respect disabled sharing API settings
If the sharing API setting is disabled that sharing check middle ware should block the request. Thus making link shares unavailable. Fixes #18970 * Unit test added * Unit tests updated
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/middleware/sharingcheckmiddleware.php5
-rw-r--r--apps/files_sharing/tests/middleware/sharingcheckmiddleware.php35
2 files changed, 37 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php b/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php
index 3787ef42d9f..1c29b1da736 100644
--- a/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php
+++ b/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php
@@ -87,6 +87,11 @@ class SharingCheckMiddleware extends Middleware {
return false;
}
+ // Check if the shareAPI is enabled
+ if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
+ return false;
+ }
+
// Check whether public sharing is enabled
if($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
return false;
diff --git a/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php b/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php
index 0db8a1ed5bc..58f4b841339 100644
--- a/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php
+++ b/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php
@@ -54,7 +54,13 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
->will($this->returnValue(true));
$this->config
- ->expects($this->once())
+ ->expects($this->at(0))
+ ->method('getAppValue')
+ ->with('core', 'shareapi_enabled', 'yes')
+ ->will($this->returnValue('yes'));
+
+ $this->config
+ ->expects($this->at(1))
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->will($this->returnValue('yes'));
@@ -72,7 +78,7 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
$this->assertFalse(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled'));
}
- public function testIsSharingEnabledWithSharingDisabled() {
+ public function testIsSharingEnabledWithLinkSharingDisabled() {
$this->appManager
->expects($this->once())
->method('isEnabledForUser')
@@ -80,11 +86,34 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
->will($this->returnValue(true));
$this->config
- ->expects($this->once())
+ ->expects($this->at(0))
+ ->method('getAppValue')
+ ->with('core', 'shareapi_enabled', 'yes')
+ ->will($this->returnValue('yes'));
+
+ $this->config
+ ->expects($this->at(1))
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->will($this->returnValue('no'));
$this->assertFalse(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled'));
}
+
+ public function testIsSharingEnabledWithSharingAPIDisabled() {
+ $this->appManager
+ ->expects($this->once())
+ ->method('isEnabledForUser')
+ ->with('files_sharing')
+ ->will($this->returnValue(true));
+
+ $this->config
+ ->expects($this->once())
+ ->method('getAppValue')
+ ->with('core', 'shareapi_enabled', 'yes')
+ ->will($this->returnValue('no'));
+
+ $this->assertFalse(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled'));
+ }
+
}