Merge pull request #18124 from owncloud/share-permwrongvar
Fix removal of share permissions when share disabled for user
This commit is contained in:
commit
ca8f7fd69c
|
@ -1354,7 +1354,7 @@ class View {
|
||||||
|
|
||||||
// if sharing was disabled for the user we remove the share permissions
|
// if sharing was disabled for the user we remove the share permissions
|
||||||
if (\OCP\Util::isSharingDisabledForUser()) {
|
if (\OCP\Util::isSharingDisabledForUser()) {
|
||||||
$content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE;
|
$rootEntry['permissions'] = $rootEntry['permissions'] & ~\OCP\Constants::PERMISSION_SHARE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry, $mount);
|
$files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry, $mount);
|
||||||
|
|
|
@ -44,8 +44,22 @@ class View extends \Test\TestCase {
|
||||||
* @var \OC\Files\Storage\Storage[] $storages
|
* @var \OC\Files\Storage\Storage[] $storages
|
||||||
*/
|
*/
|
||||||
private $storages = array();
|
private $storages = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \OCP\IUser
|
||||||
|
*/
|
||||||
|
private $userObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \OCP\IGroup
|
||||||
|
*/
|
||||||
|
private $groupObject;
|
||||||
|
|
||||||
/** @var \OC\Files\Storage\Storage */
|
/** @var \OC\Files\Storage\Storage */
|
||||||
private $tempStorage;
|
private $tempStorage;
|
||||||
|
|
||||||
|
@ -57,10 +71,15 @@ class View extends \Test\TestCase {
|
||||||
\OC_User::useBackend(new \OC_User_Dummy());
|
\OC_User::useBackend(new \OC_User_Dummy());
|
||||||
|
|
||||||
//login
|
//login
|
||||||
\OC_User::createUser('test', 'test');
|
$userManager = \OC::$server->getUserManager();
|
||||||
|
$groupManager = \OC::$server->getGroupManager();
|
||||||
|
$this->user = 'test';
|
||||||
|
$this->userObject = $userManager->createUser('test', 'test');
|
||||||
|
|
||||||
$this->loginAsUser('test');
|
$this->groupObject = $groupManager->createGroup('group1');
|
||||||
$this->user = \OC_User::getUser();
|
$this->groupObject->addUser($this->userObject);
|
||||||
|
|
||||||
|
$this->loginAsUser($this->user);
|
||||||
// clear mounts but somehow keep the root storage
|
// clear mounts but somehow keep the root storage
|
||||||
// that was initialized above...
|
// that was initialized above...
|
||||||
\OC\Files\Filesystem::clearMounts();
|
\OC\Files\Filesystem::clearMounts();
|
||||||
|
@ -81,6 +100,10 @@ class View extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logout();
|
$this->logout();
|
||||||
|
|
||||||
|
$this->userObject->delete();
|
||||||
|
$this->groupObject->delete();
|
||||||
|
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,6 +231,40 @@ class View extends \Test\TestCase {
|
||||||
$this->assertEquals(4, count($folderContent));
|
$this->assertEquals(4, count($folderContent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sharingDisabledPermissionProvider() {
|
||||||
|
return [
|
||||||
|
['no', '', true],
|
||||||
|
['yes', 'group1', false],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider sharingDisabledPermissionProvider
|
||||||
|
*/
|
||||||
|
public function testRemoveSharePermissionWhenSharingDisabledForUser($excludeGroups, $excludeGroupsList, $expectedShareable) {
|
||||||
|
$appConfig = \OC::$server->getAppConfig();
|
||||||
|
$oldExcludeGroupsFlag = $appConfig->getValue('core', 'shareapi_exclude_groups', 'no');
|
||||||
|
$oldExcludeGroupsList = $appConfig->getValue('core', 'shareapi_exclude_groups_list', '');
|
||||||
|
$appConfig->setValue('core', 'shareapi_exclude_groups', $excludeGroups);
|
||||||
|
$appConfig->setValue('core', 'shareapi_exclude_groups_list', $excludeGroupsList);
|
||||||
|
|
||||||
|
$storage1 = $this->getTestStorage();
|
||||||
|
$storage2 = $this->getTestStorage();
|
||||||
|
\OC\Files\Filesystem::mount($storage1, array(), '/');
|
||||||
|
\OC\Files\Filesystem::mount($storage2, array(), '/mount');
|
||||||
|
|
||||||
|
$view = new \OC\Files\View('/');
|
||||||
|
|
||||||
|
$folderContent = $view->getDirectoryContent('');
|
||||||
|
$this->assertEquals($expectedShareable, $folderContent[0]->isShareable());
|
||||||
|
|
||||||
|
$folderContent = $view->getDirectoryContent('mount');
|
||||||
|
$this->assertEquals($expectedShareable, $folderContent[0]->isShareable());
|
||||||
|
|
||||||
|
$appConfig->setValue('core', 'shareapi_exclude_groups', $oldExcludeGroupsFlag);
|
||||||
|
$appConfig->setValue('core', 'shareapi_exclude_groups_list', $oldExcludeGroupsList);
|
||||||
|
}
|
||||||
|
|
||||||
function testCacheIncompleteFolder() {
|
function testCacheIncompleteFolder() {
|
||||||
$storage1 = $this->getTestStorage(false);
|
$storage1 = $this->getTestStorage(false);
|
||||||
\OC\Files\Filesystem::clearMounts();
|
\OC\Files\Filesystem::clearMounts();
|
||||||
|
|
Loading…
Reference in New Issue