diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-06-29 09:10:37 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-06-29 09:10:37 +0200 |
commit | b55f71ee032a77105b823ee01653f39fe066977f (patch) | |
tree | 212fe0a045cdc3a45eea284d6521cc4c6e78d7dd | |
parent | 733d59ed44aac05b2863cb4cf4782ab1e367891f (diff) | |
parent | 56d9df34cb4bed8267453bcf894f7ead775a5827 (diff) | |
download | nextcloud-server-b55f71ee032a77105b823ee01653f39fe066977f.tar.gz nextcloud-server-b55f71ee032a77105b823ee01653f39fe066977f.zip |
Merge pull request #17083 from owncloud/share-etag-update-target
take share target into account when updating recipient etags
-rw-r--r-- | apps/files_sharing/lib/updater.php | 4 | ||||
-rw-r--r-- | apps/files_sharing/tests/updater.php | 44 |
2 files changed, 38 insertions, 10 deletions
diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php index 88bb68aa36e..5a0326c4288 100644 --- a/apps/files_sharing/lib/updater.php +++ b/apps/files_sharing/lib/updater.php @@ -77,10 +77,10 @@ class Shared_Updater { $shareType = $params['shareType']; if ($shareType === \OCP\Share::SHARE_TYPE_USER) { - self::correctUsersFolder($shareWith, '/'); + self::correctUsersFolder($shareWith, $params['fileTarget']); } elseif ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { foreach (\OC_Group::usersInGroup($shareWith) as $user) { - self::correctUsersFolder($user, '/'); + self::correctUsersFolder($user, $params['fileTarget']); } } } diff --git a/apps/files_sharing/tests/updater.php b/apps/files_sharing/tests/updater.php index 7b4d7459571..63ab452a5e1 100644 --- a/apps/files_sharing/tests/updater.php +++ b/apps/files_sharing/tests/updater.php @@ -116,14 +116,34 @@ class Test_Files_Sharing_Updater extends OCA\Files_Sharing\Tests\TestCase { \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin'); } + public function shareFolderProvider() { + return [ + ['/'], + ['/my_shares'], + ]; + } + /** * if a file gets shared the etag for the recipients root should change + * + * @dataProvider shareFolderProvider + * + * @param string $shareFolder share folder to use */ - function testShareFile() { + public function testShareFile($shareFolder) { + $config = \OC::$server->getConfig(); + $oldShareFolder = $config->getSystemValue('share_folder'); + $config->setSystemValue('share_folder', $shareFolder); + $this->loginHelper(self::TEST_FILES_SHARING_API_USER2); - $beforeShare = \OC\Files\Filesystem::getFileInfo(''); - $etagBeforeShare = $beforeShare->getEtag(); + $beforeShareRoot = \OC\Files\Filesystem::getFileInfo(''); + $etagBeforeShareRoot = $beforeShareRoot->getEtag(); + + \OC\Files\Filesystem::mkdir($shareFolder); + + $beforeShareDir = \OC\Files\Filesystem::getFileInfo($shareFolder); + $etagBeforeShareDir = $beforeShareDir->getEtag(); $this->loginHelper(self::TEST_FILES_SHARING_API_USER1); $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder); @@ -132,17 +152,25 @@ class Test_Files_Sharing_Updater extends OCA\Files_Sharing\Tests\TestCase { $this->loginHelper(self::TEST_FILES_SHARING_API_USER2); - $afterShare = \OC\Files\Filesystem::getFileInfo(''); - $etagAfterShare = $afterShare->getEtag(); + $afterShareRoot = \OC\Files\Filesystem::getFileInfo(''); + $etagAfterShareRoot = $afterShareRoot->getEtag(); + + $afterShareDir = \OC\Files\Filesystem::getFileInfo($shareFolder); + $etagAfterShareDir = $afterShareDir->getEtag(); - $this->assertTrue(is_string($etagBeforeShare)); - $this->assertTrue(is_string($etagAfterShare)); - $this->assertTrue($etagBeforeShare !== $etagAfterShare); + $this->assertTrue(is_string($etagBeforeShareRoot)); + $this->assertTrue(is_string($etagBeforeShareDir)); + $this->assertTrue(is_string($etagAfterShareRoot)); + $this->assertTrue(is_string($etagAfterShareDir)); + $this->assertTrue($etagBeforeShareRoot !== $etagAfterShareRoot); + $this->assertTrue($etagBeforeShareDir !== $etagAfterShareDir); // cleanup $this->loginHelper(self::TEST_FILES_SHARING_API_USER1); $result = \OCP\Share::unshare('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $this->assertTrue($result); + + $config->setSystemValue('share_folder', $oldShareFolder); } /** |