summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-10-17 12:23:37 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2013-10-17 12:23:37 +0200
commit99738ae0bc204709e47ea42cd1a2b5694b2b1222 (patch)
treecfe791fa4d1559adae82dc7a8f5779aa47bc913f /apps/files_sharing/tests
parentab6ee79e116d7c212867ae1044bf4672c0b02084 (diff)
downloadnextcloud-server-99738ae0bc204709e47ea42cd1a2b5694b2b1222.tar.gz
nextcloud-server-99738ae0bc204709e47ea42cd1a2b5694b2b1222.zip
add test for the reshare option
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/api.php61
1 files changed, 59 insertions, 2 deletions
diff --git a/apps/files_sharing/tests/api.php b/apps/files_sharing/tests/api.php
index 14902df21c6..44fc4d8b7b3 100644
--- a/apps/files_sharing/tests/api.php
+++ b/apps/files_sharing/tests/api.php
@@ -31,6 +31,7 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
const TEST_FILES_SHARING_API_USER1 = "test-share-user1";
const TEST_FILES_SHARING_API_USER2 = "test-share-user2";
+ const TEST_FILES_SHARING_API_USER3 = "test-share-user3";
public $stateFilesEncryption;
public $filename;
@@ -54,6 +55,7 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
// create users
self::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1, true);
self::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, true);
+ self::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER3, true);
}
@@ -101,6 +103,7 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
// cleanup users
\OC_User::deleteUser(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
\OC_User::deleteUser(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
+ \OC_User::deleteUser(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER3);
}
/**
@@ -197,9 +200,9 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_LINK,
null, 1);
- $params = array('path' => $this->filename);
+ $_GET['path'] = $this->filename;
- $result = Share\Api::getAllShares($params);
+ $result = Share\Api::getAllShares(array());
$this->assertTrue($result->succeeded());
@@ -217,6 +220,60 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
* @medium
* @depends testCreateShare
*/
+ function testGetShareFromSourceWithReshares() {
+
+ $fileInfo = $this->view->getFileInfo($this->filename);
+
+ // share the file as user1 to user2
+ \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
+ \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
+
+ // login as user2 and reshare the file to user3
+ \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
+
+ \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
+ \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER3, 31);
+
+ // login as user1 again
+ \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
+
+ $_GET['path'] = $this->filename;
+
+ $result = Share\Api::getAllShares(array());
+
+ $this->assertTrue($result->succeeded());
+
+ // test should return one share
+ $this->assertTrue(count($result->getData()) === 1);
+
+ // now also ask for the reshares
+ $_GET['reshares'] = 'true';
+
+ $result = Share\Api::getAllShares(array());
+
+ $this->assertTrue($result->succeeded());
+
+ // now we should get two shares, the initial share and the reshare
+ $this->assertTrue(count($result->getData()) === 2);
+
+ // unshare files again
+
+ \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
+
+ \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
+ \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER3);
+
+ \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
+
+ \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
+ \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
+
+ }
+
+ /**
+ * @medium
+ * @depends testCreateShare
+ */
function testGetShareFromId() {
$fileInfo = $this->view->getFileInfo($this->filename);