/** * test re-re-share of folder if the path gets constructed correctly * @medium */ function testGetShareFromFileReReShares() { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $fileInfo1 = $this->view->getFileInfo($this->folder . $this->subfolder); $fileInfo2 = $this->view->getFileInfo($this->folder . $this->subfolder . $this->filename); // share sub-folder to user2 $result = \OCP\Share::shareItem('folder', $fileInfo1['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31); // share was successful? $this->assertTrue($result); // login as user2 self::loginHelper(self::TEST_FILES_SHARING_API_USER2); // reshare subsubfolder $result = \OCP\Share::shareItem('file', $fileInfo2['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER3, 31); // share was successful? $this->assertTrue($result); // login as user3 self::loginHelper(self::TEST_FILES_SHARING_API_USER3); $result = \OCP\Share::shareItem('file', $fileInfo2['fileid'], \OCP\Share::SHARE_TYPE_LINK, null, 1); // share was successful? $this->assertTrue(is_string($result)); $_GET['path'] = '/'; $_GET['subfiles'] = 'true'; $result = Share\Api::getAllShares(array()); $this->assertTrue($result->succeeded()); // test should return one share within $this->folder $data = $result->getData(); // we should get exactly one result $this->assertEquals(1, count($data)); $expectedPath = $this->filename; $this->assertEquals($expectedPath, $data[0]['path']); // cleanup $result = \OCP\Share::unshare('file', $fileInfo2['fileid'], \OCP\Share::SHARE_TYPE_LINK, null); $this->assertTrue($result); self::loginHelper(self::TEST_FILES_SHARING_API_USER2); $result = \OCP\Share::unshare('file', $fileInfo2['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER3); $this->assertTrue($result); self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $result = \OCP\Share::unshare('folder', $fileInfo1['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2); $this->assertTrue($result); }
/** * @medium */ function testGetShareFromFolder() { $fileInfo1 = $this->view->getFileInfo($this->filename); $fileInfo2 = $this->view->getFileInfo($this->folder . '/' . $this->filename); $result = \OCP\Share::shareItem('file', $fileInfo1['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31); // share was successful? $this->assertTrue($result); $result = \OCP\Share::shareItem('folder', $fileInfo2['fileid'], \OCP\Share::SHARE_TYPE_LINK, null, 1); // share was successful? $this->assertTrue(is_string($result)); $_GET['path'] = $this->folder; $_GET['subfiles'] = 'true'; $result = Share\Api::getAllShares(array()); $this->assertTrue($result->succeeded()); // test should return one share within $this->folder $this->assertTrue(count($result->getData()) === 1); \OCP\Share::unshare('file', $fileInfo1['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2); \OCP\Share::unshare('folder', $fileInfo2['fileid'], \OCP\Share::SHARE_TYPE_LINK, null); }