summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2014-07-29 14:05:13 +0200
committerBjörn Schießle <schiessle@owncloud.com>2014-07-29 14:05:13 +0200
commita36c4402f5f531aff8ee952742c1dc2f678d75bc (patch)
treeb79357091802da3812ea5536bf0400e00589c256 /tests
parent03f7c5c56161c68ecc52a5e15d6f4d41a13fbef1 (diff)
parent67e302885cab639c70d3dca5c022d6fa9648956c (diff)
downloadnextcloud-server-a36c4402f5f531aff8ee952742c1dc2f678d75bc.tar.gz
nextcloud-server-a36c4402f5f531aff8ee952742c1dc2f678d75bc.zip
Merge pull request #9988 from owncloud/sharing_remove_share_permission
remove share permission if user is excluded from sharing
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/share/share.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index 0e3dfe8291d..24dedb619f8 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(