[Pkg-owncloud-commits] [owncloud] 14/79: Fix removal of share permissions when share disabled for user

David Prévot taffit at moszumanska.debian.org
Tue Sep 1 20:55:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 89ccdcf134cacccdadd4865bcbcf621839483247
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Fri Aug 7 15:43:27 2015 +0200

    Fix removal of share permissions when share disabled for user
---
 lib/private/files/view.php |  2 +-
 tests/lib/files/view.php   | 63 +++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 1706818..3f96e54 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1354,7 +1354,7 @@ class View {
 
 							// if sharing was disabled for the user we remove the share permissions
 							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);
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 382c033..bf99a58 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -44,8 +44,22 @@ class View extends \Test\TestCase {
 	 * @var \OC\Files\Storage\Storage[] $storages
 	 */
 	private $storages = array();
+
+	/**
+	 * @var string
+	 */
 	private $user;
 
+	/**
+	 * @var \OCP\IUser
+	 */
+	private $userObject;
+
+	/**
+	 * @var \OCP\IGroup
+	 */
+	private $groupObject;
+
 	/** @var \OC\Files\Storage\Storage */
 	private $tempStorage;
 
@@ -57,10 +71,15 @@ class View extends \Test\TestCase {
 		\OC_User::useBackend(new \OC_User_Dummy());
 
 		//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->user = \OC_User::getUser();
+		$this->groupObject = $groupManager->createGroup('group1');
+		$this->groupObject->addUser($this->userObject);
+
+		$this->loginAsUser($this->user);
 		// clear mounts but somehow keep the root storage
 		// that was initialized above...
 		\OC\Files\Filesystem::clearMounts();
@@ -81,6 +100,10 @@ class View extends \Test\TestCase {
 		}
 
 		$this->logout();
+
+		$this->userObject->delete();
+		$this->groupObject->delete();
+
 		parent::tearDown();
 	}
 
@@ -208,6 +231,40 @@ class View extends \Test\TestCase {
 		$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() {
 		$storage1 = $this->getTestStorage(false);
 		\OC\Files\Filesystem::clearMounts();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list