summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-07-02 14:40:22 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-07-04 10:34:54 +0200
commit3b9fa8158183950634172799737489cefccd170c (patch)
treea0965d3509af464225c5e1393be9b9aea9cdb3e9 /apps/files_sharing/tests
parente4a3f8d3c44f3238071d03f793cd2c5395062b5e (diff)
downloadnextcloud-server-3b9fa8158183950634172799737489cefccd170c.tar.gz
nextcloud-server-3b9fa8158183950634172799737489cefccd170c.zip
if a folder gets deleted we unshare all shared files/folders below
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/proxy.php27
-rw-r--r--apps/files_sharing/tests/updater.php14
2 files changed, 21 insertions, 20 deletions
diff --git a/apps/files_sharing/tests/proxy.php b/apps/files_sharing/tests/proxy.php
index 634ed86db54..b6599a1b646 100644
--- a/apps/files_sharing/tests/proxy.php
+++ b/apps/files_sharing/tests/proxy.php
@@ -47,7 +47,6 @@ class Test_Files_Sharing_Proxy extends Test_Files_Sharing_Base {
$this->filename = '/share-api-test';
// save file with content
- $this->view->file_put_contents($this->filename, $this->data);
$this->view->mkdir($this->folder);
$this->view->mkdir($this->folder . $this->subfolder);
$this->view->mkdir($this->folder . $this->subfolder . $this->subsubfolder);
@@ -56,7 +55,6 @@ class Test_Files_Sharing_Proxy extends Test_Files_Sharing_Base {
}
function tearDown() {
- $this->view->unlink($this->filename);
$this->view->deleteAll($this->folder);
self::$tempStorage = null;
@@ -69,30 +67,33 @@ class Test_Files_Sharing_Proxy extends Test_Files_Sharing_Base {
*/
function testpreUnlink() {
- $fileInfo1 = \OC\Files\Filesystem::getFileInfo($this->filename);
$fileInfo2 = \OC\Files\Filesystem::getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('file', $fileInfo1->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
- $this->assertTrue($result);
-
$result = \OCP\Share::shareItem('folder', $fileInfo2->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
$this->assertTrue($result);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- // move shared folder to 'localDir' and rename it, so that it uses the same
- // name as the shared file
+ // one folder should be shared with the user
+ $sharedFolders = \OCP\Share::getItemsSharedWith('folder');
+ $this->assertSame(1, count($sharedFolders));
+
+ // move shared folder to 'localDir'
\OC\Files\Filesystem::mkdir('localDir');
- $result = \OC\Files\Filesystem::rename($this->folder, '/localDir/' . $this->filename);
+ $result = \OC\Files\Filesystem::rename($this->folder, '/localDir/' . $this->folder);
$this->assertTrue($result);
\OC\Files\Filesystem::unlink('localDir');
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- // after we deleted 'localDir' the share should be moved up to the root and be
- // renamed to "filename (2)"
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename . ' (2)' ));
+ // after the parent directory was deleted the share should be unshared
+ $sharedFolders = \OCP\Share::getItemsSharedWith('folder');
+ $this->assertTrue(empty($sharedFolders));
+
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
+
+ // the folder for the owner should still exists
+ $this->assertTrue(\OC\Files\Filesystem::file_exists($this->folder));
}
}
diff --git a/apps/files_sharing/tests/updater.php b/apps/files_sharing/tests/updater.php
index 5ec53488702..1f51b9a315c 100644
--- a/apps/files_sharing/tests/updater.php
+++ b/apps/files_sharing/tests/updater.php
@@ -57,7 +57,7 @@ class Test_Files_Sharing_Updater extends Test_Files_Sharing_Base {
/**
* test deletion of a folder which contains share mount points. Share mount
- * points should move up to the parent before the folder gets deleted so
+ * points should be unshared before the folder gets deleted so
* that the mount point doesn't end up at the trash bin
*/
function testDeleteParentFolder() {
@@ -78,6 +78,9 @@ class Test_Files_Sharing_Updater extends Test_Files_Sharing_Base {
// check if user2 can see the shared folder
$this->assertTrue($view->file_exists($this->folder));
+ $foldersShared = \OCP\Share::getItemsSharedWith('folder');
+ $this->assertSame(1, count($foldersShared));
+
$view->mkdir("localFolder");
$view->file_put_contents("localFolder/localFile.txt", "local file");
@@ -91,8 +94,9 @@ class Test_Files_Sharing_Updater extends Test_Files_Sharing_Base {
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- // mount point should move up again
- $this->assertTrue($view->file_exists($this->folder));
+ // shared folder should be unshared
+ $foldersShared = \OCP\Share::getItemsSharedWith('folder');
+ $this->assertTrue(empty($foldersShared));
// trashbin should contain the local file but not the mount point
$rootView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
@@ -109,10 +113,6 @@ class Test_Files_Sharing_Updater extends Test_Files_Sharing_Base {
if ($status === false) {
\OC_App::disable('files_trashbin');
}
- // 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);
}
/**