[Pkg-owncloud-commits] [owncloud] 31/61: remove share permission if user is excluded from sharing

David Prévot taffit at moszumanska.debian.org
Thu Jul 31 03:51:46 UTC 2014


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

taffit pushed a commit to branch master
in repository owncloud.

commit b4a379b7e39a989902de204349f187f614f87ced
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Mon Jul 28 22:35:11 2014 +0200

    remove share permission if user is excluded from sharing
---
 lib/private/share/share.php |  2 +-
 tests/lib/share/share.php   | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index af286e7..0c42853 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -1397,7 +1397,7 @@ class Share extends \OC\Share\Constants {
 				}
 			}
 			// Check if resharing is allowed, if not remove share permission
-			if (isset($row['permissions']) && !self::isResharingAllowed()) {
+			if (isset($row['permissions']) && (!self::isResharingAllowed() | \OC_Util::isSharingDisabledForUser())) {
 				$row['permissions'] &= ~\OCP\PERMISSION_SHARE;
 			}
 			// Add display names to result
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index 0e3dfe8..24dedb6 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -375,6 +375,39 @@ class Test_Share extends PHPUnit_Framework_TestCase {
 
 	}
 
+	/*
+	 * if user is in a group excluded from resharing, then the share permission should
+	 * be removed
+	 */
+	public function testShareWithUserAndUserIsExcludedFromResharing() {
+
+		OC_User::setUserId($this->user1);
+		$this->assertTrue(
+			OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user4, OCP\PERMISSION_ALL),
+			'Failed asserting that user 1 successfully shared text.txt with user 4.'
+		);
+		$this->assertContains(
+			'test.txt',
+			OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+			'Failed asserting that test.txt is a shared file of user 1.'
+		);
+
+		// exclude group2 from sharing
+		\OC_Appconfig::setValue('core', 'shareapi_exclude_groups_list', $this->group2);
+		\OC_Appconfig::setValue('core', 'shareapi_exclude_groups', "yes");
+
+		OC_User::setUserId($this->user4);
+
+		$share = OCP\Share::getItemSharedWith('test', 'test.txt');
+
+		$this->assertSame(\OCP\PERMISSION_ALL & ~OCP\PERMISSION_SHARE, $share['permissions'],
+				'Failed asserting that user 4 is excluded from re-sharing');
+
+		\OC_Appconfig::deleteKey('core', 'shareapi_exclude_groups_list');
+		\OC_Appconfig::deleteKey('core', 'shareapi_exclude_groups');
+
+	}
+
 	protected function shareUserOneTestFileWithGroupOne() {
 		OC_User::setUserId($this->user1);
 		$this->assertTrue(

-- 
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