summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/sharedstorage.php21
-rw-r--r--apps/files_sharing/tests/share.php65
2 files changed, 77 insertions, 9 deletions
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 6b2873302a5..59de2dfa4c4 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -403,15 +403,18 @@ class Shared extends \OC\Files\Storage\Common {
|| $shares
) {
foreach ($shares as $share) {
- $mount = new SharedMount(
- '\OC\Files\Storage\Shared',
- $options['user_dir'] . '/' . $share['file_target'],
- array(
- 'share' => $share,
- ),
- $loader
- );
- $manager->addMount($mount);
+ // don't mount shares where we have no permissions
+ if ($share['permissions'] > 0) {
+ $mount = new SharedMount(
+ '\OC\Files\Storage\Shared',
+ $options['user_dir'] . '/' . $share['file_target'],
+ array(
+ 'share' => $share,
+ ),
+ $loader
+ );
+ $manager->addMount($mount);
+ }
}
}
}
diff --git a/apps/files_sharing/tests/share.php b/apps/files_sharing/tests/share.php
index 195fac461be..d3ca1816c75 100644
--- a/apps/files_sharing/tests/share.php
+++ b/apps/files_sharing/tests/share.php
@@ -60,6 +60,71 @@ class Test_Files_Sharing extends Test_Files_Sharing_Base {
parent::tearDown();
}
+ function testUnshareFromSelf() {
+
+ \OC_Group::createGroup('testGroup');
+ \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
+ \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
+
+ $fileinfo = $this->view->getFileInfo($this->filename);
+
+ $pathinfo = pathinfo($this->filename);
+
+ $duplicate = '/' . $pathinfo['filename'] . ' (2).' . $pathinfo['extension'];
+
+ $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
+ \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, 31);
+
+ $this->assertTrue($result);
+
+ $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP,
+ 'testGroup', 31);
+
+ $this->assertTrue($result);
+
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
+ $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertTrue(\OC\Files\Filesystem::file_exists($duplicate));
+
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
+ $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
+
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
+ \OC\Files\Filesystem::unlink($this->filename);
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
+ $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertTrue(\OC\Files\Filesystem::file_exists($duplicate));
+
+ // for user3 nothing should change
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
+ $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
+
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
+ \OC\Files\Filesystem::unlink($duplicate);
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
+ $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
+
+ // for user3 nothing should change
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
+ $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
+
+ //cleanup
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
+ \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP,
+ 'testGroup');
+ \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
+ self::TEST_FILES_SHARING_API_USER2);
+ \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
+ \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
+ \OC_Group::deleteGroup('testGroup');
+
+
+ }
+
/**
* shared files should never have delete permissions
* @dataProvider DataProviderTestFileSharePermissions