aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests/updater.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-06-24 17:04:27 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-06-25 12:11:56 +0200
commita0b85fc5e4a56ff553f224083cbdf87cd05ec55a (patch)
treeb44fc4364013d26f2f477ab822ebfb5fd6c7891f /apps/files_sharing/tests/updater.php
parent89f26915152e5aaf357b2aa633d5bea954e4bcc2 (diff)
downloadnextcloud-server-a0b85fc5e4a56ff553f224083cbdf87cd05ec55a.tar.gz
nextcloud-server-a0b85fc5e4a56ff553f224083cbdf87cd05ec55a.zip
make sure that during share and unshare the etags get propagated correctly
Diffstat (limited to 'apps/files_sharing/tests/updater.php')
-rw-r--r--apps/files_sharing/tests/updater.php106
1 files changed, 106 insertions, 0 deletions
diff --git a/apps/files_sharing/tests/updater.php b/apps/files_sharing/tests/updater.php
index 8183e7067a4..c0099b4ded1 100644
--- a/apps/files_sharing/tests/updater.php
+++ b/apps/files_sharing/tests/updater.php
@@ -104,6 +104,112 @@ 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);
+ }
+
+ /**
+ * if a file gets shared the etag for the recipients root should change
+ */
+ function testShareFile() {
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
+
+ $beforeShare = \OC\Files\Filesystem::getFileInfo('');
+ $etagBeforeShare = $beforeShare->getEtag();
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
+ $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
+ $result = \OCP\Share::shareItem('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
+ $this->assertTrue($result);
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
+
+ $afterShare = \OC\Files\Filesystem::getFileInfo('');
+ $etagAfterShare = $afterShare->getEtag();
+
+ $this->assertTrue(is_string($etagBeforeShare));
+ $this->assertTrue(is_string($etagAfterShare));
+ $this->assertTrue($etagBeforeShare !== $etagAfterShare);
+
+ // 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);
+ }
+
+ /**
+ * if a file gets unshared by the owner the etag for the recipients root should change
+ */
+ function testUnshareFile() {
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
+ $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
+ $result = \OCP\Share::shareItem('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
+ $this->assertTrue($result);
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
+
+ $beforeUnshare = \OC\Files\Filesystem::getFileInfo('');
+ $etagBeforeUnshare = $beforeUnshare->getEtag();
+
+ $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);
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
+
+ $afterUnshare = \OC\Files\Filesystem::getFileInfo('');
+ $etagAfterUnshare = $afterUnshare->getEtag();
+
+ $this->assertTrue(is_string($etagBeforeUnshare));
+ $this->assertTrue(is_string($etagAfterUnshare));
+ $this->assertTrue($etagBeforeUnshare !== $etagAfterUnshare);
+
+ }
+
+ /**
+ * if a file gets unshared from self the etag for the recipients root should change
+ */
+ function testUnshareFromSelfFile() {
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
+ $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
+ $result = \OCP\Share::shareItem('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
+ $this->assertTrue($result);
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
+
+ $result = \OCP\Share::shareItem('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER3, 31);
+
+ $beforeUnshareUser2 = \OC\Files\Filesystem::getFileInfo('');
+ $etagBeforeUnshareUser2 = $beforeUnshareUser2->getEtag();
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER3);
+
+ $beforeUnshareUser3 = \OC\Files\Filesystem::getFileInfo('');
+ $etagBeforeUnshareUser3 = $beforeUnshareUser3->getEtag();
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
+
+ $result = \OC\Files\Filesystem::unlink($this->folder);
+ $this->assertTrue($result);
+
+ $afterUnshareUser2 = \OC\Files\Filesystem::getFileInfo('');
+ $etagAfterUnshareUser2 = $afterUnshareUser2->getEtag();
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER3);
+
+ $afterUnshareUser3 = \OC\Files\Filesystem::getFileInfo('');
+ $etagAfterUnshareUser3 = $afterUnshareUser3->getEtag();
+
+ $this->assertTrue(is_string($etagBeforeUnshareUser2));
+ $this->assertTrue(is_string($etagBeforeUnshareUser3));
+ $this->assertTrue(is_string($etagAfterUnshareUser2));
+ $this->assertTrue(is_string($etagAfterUnshareUser3));
+ $this->assertTrue($etagBeforeUnshareUser2 !== $etagAfterUnshareUser2);
+ $this->assertTrue($etagBeforeUnshareUser3 !== $etagAfterUnshareUser3);
+
}
}