diff --git a/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php b/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php index 3787ef42d9f7..1c29b1da736f 100644 --- a/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php +++ b/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php @@ -87,6 +87,11 @@ private function isSharingEnabled() { 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 0db8a1ed5bc1..58f4b8413399 100644 --- a/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php +++ b/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php @@ -54,7 +54,13 @@ public function testIsSharingEnabledWithEverythingEnabled() { ->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 @@ public function testIsSharingEnabledWithAppDisabled() { $this->assertFalse(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled')); } - public function testIsSharingEnabledWithSharingDisabled() { + public function testIsSharingEnabledWithLinkSharingDisabled() { $this->appManager ->expects($this->once()) ->method('isEnabledForUser') @@ -80,11 +86,34 @@ public function testIsSharingEnabledWithSharingDisabled() { ->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')); + } + }