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
This commit is contained in:
parent
762e7c3dd9
commit
4dba046712
|
@ -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;
|
||||
|
|
|
@ -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,29 @@ 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')
|
||||
->with('files_sharing')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->config
|
||||
->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')
|
||||
|
@ -82,9 +110,10 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
|
|||
$this->config
|
||||
->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('core', 'shareapi_allow_links', 'yes')
|
||||
->with('core', 'shareapi_enabled', 'yes')
|
||||
->will($this->returnValue('no'));
|
||||
|
||||
$this->assertFalse(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue