diff options
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r-- | apps/files_sharing/tests/api.php | 24 | ||||
-rw-r--r-- | apps/files_sharing/tests/controller/sharecontroller.php | 8 | ||||
-rw-r--r-- | apps/files_sharing/tests/deleteorphanedsharesjobtest.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/tests/etagpropagation.php | 14 | ||||
-rw-r--r-- | apps/files_sharing/tests/external/managertest.php | 20 | ||||
-rw-r--r-- | apps/files_sharing/tests/js/publicAppSpec.js | 107 | ||||
-rw-r--r-- | apps/files_sharing/tests/middleware/sharingcheckmiddleware.php | 7 | ||||
-rw-r--r-- | apps/files_sharing/tests/permissions.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/tests/sharedmount.php | 7 | ||||
-rw-r--r-- | apps/files_sharing/tests/sizepropagation.php | 3 | ||||
-rw-r--r-- | apps/files_sharing/tests/testcase.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/tests/unsharechildren.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/tests/updater.php | 45 | ||||
-rw-r--r-- | apps/files_sharing/tests/watcher.php | 1 |
14 files changed, 207 insertions, 34 deletions
diff --git a/apps/files_sharing/tests/api.php b/apps/files_sharing/tests/api.php index 44c6b1dc4b9..d5a6fd5b657 100644 --- a/apps/files_sharing/tests/api.php +++ b/apps/files_sharing/tests/api.php @@ -888,7 +888,6 @@ class Test_Files_Sharing_Api extends TestCase { $this->assertEquals('1', $newUserShare['permissions']); // update password for link share - $this->assertTrue(empty($linkShare['share_with'])); $params = array(); @@ -913,6 +912,29 @@ class Test_Files_Sharing_Api extends TestCase { $this->assertTrue(is_array($newLinkShare)); $this->assertTrue(!empty($newLinkShare['share_with'])); + // Remove password for link share + $params = array(); + $params['id'] = $linkShare['id']; + $params['_put'] = array(); + $params['_put']['password'] = ''; + + $result = \OCA\Files_Sharing\API\Local::updateShare($params); + + $this->assertTrue($result->succeeded()); + + $items = \OCP\Share::getItemShared('file', $linkShare['file_source']); + + $newLinkShare = null; + foreach ($items as $item) { + if ($item['share_type'] === \OCP\Share::SHARE_TYPE_LINK) { + $newLinkShare = $item; + break; + } + } + + $this->assertTrue(is_array($newLinkShare)); + $this->assertTrue(empty($newLinkShare['share_with'])); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2); diff --git a/apps/files_sharing/tests/controller/sharecontroller.php b/apps/files_sharing/tests/controller/sharecontroller.php index 64ee5b8ce51..0b56aafc8a9 100644 --- a/apps/files_sharing/tests/controller/sharecontroller.php +++ b/apps/files_sharing/tests/controller/sharecontroller.php @@ -4,6 +4,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * @author Vincent Cloutier <vincent1cloutier@gmail.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. @@ -29,7 +30,6 @@ use OC\Files\Filesystem; use OCA\Files_Sharing\AppInfo\Application; use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\IAppContainer; -use OCP\Files; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\TemplateResponse; use OCP\Security\ISecureRandom; @@ -78,10 +78,7 @@ class ShareControllerTest extends \Test\TestCase { \OC_User::createUser($this->user, $this->user); \OC_Util::tearDownFS(); - \OC_User::setUserId(''); - Filesystem::tearDown(); - \OC_User::setUserId($this->user); - \OC_Util::setupFS($this->user); + $this->loginAsUser($this->user); // Create a dummy shared file $view = new View('/'. $this->user . '/files'); @@ -182,6 +179,7 @@ class ShareControllerTest extends \Test\TestCase { 'nonHumanFileSize' => 33, 'maxSizeAnimateGif' => 10, 'previewSupported' => true, + 'previewEnabled' => true, ); $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); diff --git a/apps/files_sharing/tests/deleteorphanedsharesjobtest.php b/apps/files_sharing/tests/deleteorphanedsharesjobtest.php index 8b5afcb9149..124cb83e6f0 100644 --- a/apps/files_sharing/tests/deleteorphanedsharesjobtest.php +++ b/apps/files_sharing/tests/deleteorphanedsharesjobtest.php @@ -1,6 +1,5 @@ <?php /** - * @author Morris Jobke <hey@morrisjobke.de> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_sharing/tests/etagpropagation.php b/apps/files_sharing/tests/etagpropagation.php index 60b7c525e35..d978daf200c 100644 --- a/apps/files_sharing/tests/etagpropagation.php +++ b/apps/files_sharing/tests/etagpropagation.php @@ -1,5 +1,7 @@ <?php /** + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. @@ -69,9 +71,12 @@ class EtagPropagation extends TestCase { $view1->mkdir('/directReshare'); $view1->mkdir('/sub1/sub2/folder/other'); $view1->mkdir('/sub1/sub2/folder/other'); + $view1->file_put_contents('/foo.txt', 'foobar'); $view1->file_put_contents('/sub1/sub2/folder/file.txt', 'foobar'); $view1->file_put_contents('/sub1/sub2/folder/inside/file.txt', 'foobar'); $folderInfo = $view1->getFileInfo('/sub1/sub2/folder'); + $fileInfo = $view1->getFileInfo('/foo.txt'); + \OCP\Share::shareItem('file', $fileInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31); \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31); \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER3, 31); $folderInfo = $view1->getFileInfo('/directReshare'); @@ -179,6 +184,15 @@ class EtagPropagation extends TestCase { $this->assertAllUnchaged(); } + public function testOwnerWritesToSingleFileShare() { + $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1); + Filesystem::file_put_contents('/foo.txt', 'bar'); + $this->assertEtagsNotChanged([self::TEST_FILES_SHARING_API_USER4, self::TEST_FILES_SHARING_API_USER3]); + $this->assertEtagsChanged([self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2]); + + $this->assertAllUnchaged(); + } + public function testOwnerWritesToShareWithReshare() { $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1); Filesystem::file_put_contents('/sub1/sub2/folder/inside/bar.txt', 'bar'); diff --git a/apps/files_sharing/tests/external/managertest.php b/apps/files_sharing/tests/external/managertest.php index f7b216530d5..df01ea0f738 100644 --- a/apps/files_sharing/tests/external/managertest.php +++ b/apps/files_sharing/tests/external/managertest.php @@ -76,7 +76,7 @@ class ManagerTest extends TestCase { $this->assertCount(1, $openShares); $this->assertExternalShareEntry($shareData1, $openShares[0], 1, '{{TemporaryMountPointName#' . $shareData1['name'] . '}}'); - \Test_Helper::invokePrivate($this->manager, 'setupMounts'); + self::invokePrivate($this->manager, 'setupMounts'); $this->assertNotMount('SharedFolder'); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}'); @@ -88,7 +88,7 @@ class ManagerTest extends TestCase { // New share falls back to "-1" appendix, because the name is already taken $this->assertExternalShareEntry($shareData2, $openShares[1], 2, '{{TemporaryMountPointName#' . $shareData2['name'] . '}}-1'); - \Test_Helper::invokePrivate($this->manager, 'setupMounts'); + self::invokePrivate($this->manager, 'setupMounts'); $this->assertNotMount('SharedFolder'); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}'); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1'); @@ -101,7 +101,7 @@ class ManagerTest extends TestCase { $this->manager->acceptShare($openShares[0]['id']); // Check remaining shares - Accepted - $acceptedShares = \Test_Helper::invokePrivate($this->manager, 'getShares', [true]); + $acceptedShares = self::invokePrivate($this->manager, 'getShares', [true]); $this->assertCount(1, $acceptedShares); $shareData1['accepted'] = true; $this->assertExternalShareEntry($shareData1, $acceptedShares[0], 1, $shareData1['name']); @@ -110,7 +110,7 @@ class ManagerTest extends TestCase { $this->assertCount(1, $openShares); $this->assertExternalShareEntry($shareData2, $openShares[0], 2, '{{TemporaryMountPointName#' . $shareData2['name'] . '}}-1'); - \Test_Helper::invokePrivate($this->manager, 'setupMounts'); + self::invokePrivate($this->manager, 'setupMounts'); $this->assertMount($shareData1['name']); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}'); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1'); @@ -123,7 +123,7 @@ class ManagerTest extends TestCase { // New share falls back to the original name (no "-\d", because the name is not taken) $this->assertExternalShareEntry($shareData3, $openShares[1], 3, '{{TemporaryMountPointName#' . $shareData3['name'] . '}}'); - \Test_Helper::invokePrivate($this->manager, 'setupMounts'); + self::invokePrivate($this->manager, 'setupMounts'); $this->assertMount($shareData1['name']); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}'); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1'); @@ -135,13 +135,13 @@ class ManagerTest extends TestCase { // Decline the third share $this->manager->declineShare($openShares[1]['id']); - \Test_Helper::invokePrivate($this->manager, 'setupMounts'); + self::invokePrivate($this->manager, 'setupMounts'); $this->assertMount($shareData1['name']); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}'); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1'); // Check remaining shares - Accepted - $acceptedShares = \Test_Helper::invokePrivate($this->manager, 'getShares', [true]); + $acceptedShares = self::invokePrivate($this->manager, 'getShares', [true]); $this->assertCount(1, $acceptedShares); $shareData1['accepted'] = true; $this->assertExternalShareEntry($shareData1, $acceptedShares[0], 1, $shareData1['name']); @@ -150,7 +150,7 @@ class ManagerTest extends TestCase { $this->assertCount(1, $openShares); $this->assertExternalShareEntry($shareData2, $openShares[0], 2, '{{TemporaryMountPointName#' . $shareData2['name'] . '}}-1'); - \Test_Helper::invokePrivate($this->manager, 'setupMounts'); + self::invokePrivate($this->manager, 'setupMounts'); $this->assertMount($shareData1['name']); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}'); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1'); @@ -163,10 +163,10 @@ class ManagerTest extends TestCase { ->with($this->stringStartsWith('http://localhost/ocs/v1.php/cloud/shares/' . $acceptedShares[0]['remote_id'] . '/decline'), $this->anything()); $this->manager->removeUserShares($this->uid); - $this->assertEmpty(\Test_Helper::invokePrivate($this->manager, 'getShares', [null]), 'Asserting all shares for the user have been deleted'); + $this->assertEmpty(self::invokePrivate($this->manager, 'getShares', [null]), 'Asserting all shares for the user have been deleted'); $this->mountManager->clear(); - \Test_Helper::invokePrivate($this->manager, 'setupMounts'); + self::invokePrivate($this->manager, 'setupMounts'); $this->assertNotMount($shareData1['name']); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}'); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1'); diff --git a/apps/files_sharing/tests/js/publicAppSpec.js b/apps/files_sharing/tests/js/publicAppSpec.js new file mode 100644 index 00000000000..d496b78acfa --- /dev/null +++ b/apps/files_sharing/tests/js/publicAppSpec.js @@ -0,0 +1,107 @@ +/** +* ownCloud +* +* @author Vincent Petry +* @copyright 2015 Vincent Petry <pvince81@owncloud.com> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +* +*/ + +describe('OCA.Sharing.PublicApp tests', function() { + var App = OCA.Sharing.PublicApp; + var $preview; + var fileListIn; + var fileListOut; + + beforeEach(function() { + $preview = $('<div id="preview"></div>'); + $('#testArea').append($preview); + $preview.append( + '<div id="mimetype"></div>' + + '<div id="mimetypeIcon"></div>' + + '<input type="hidden" id="sharingToken" value="sh4tok"></input>' + ); + }); + + describe('File list', function() { + // TODO: this should be moved to a separate file once the PublicFileList is extracted from public.js + beforeEach(function() { + $preview.append( + '<div id="app-content-files">' + + // init horrible parameters + '<input type="hidden" id="dir" value="/subdir"/>' + + '<input type="hidden" id="permissions" value="31"/>' + + // dummy controls + '<div id="controls">' + + ' <div class="actions creatable"></div>' + + ' <div class="notCreatable"></div>' + + '</div>' + + // uploader + '<input type="file" id="file_upload_start" name="files[]" multiple="multiple">' + + // dummy table + // TODO: at some point this will be rendered by the fileList class itself! + '<table id="filestable">' + + '<thead><tr>' + + '<th id="headerName" class="hidden column-name">' + + '<input type="checkbox" id="select_all_files" class="select-all">' + + '<a class="name columntitle" data-sort="name"><span>Name</span><span class="sort-indicator"></span></a>' + + '<span class="selectedActions hidden">' + + '<a href class="download">Download</a>' + + '</th>' + + '<th class="hidden column-size"><a class="columntitle" data-sort="size"><span class="sort-indicator"></span></a></th>' + + '<th class="hidden column-mtime"><a class="columntitle" data-sort="mtime"><span class="sort-indicator"></span></a></th>' + + '</tr></thead>' + + '<tbody id="fileList"></tbody>' + + '<tfoot></tfoot>' + + '</table>' + + // TODO: move to handlebars template + '<div id="emptycontent"><h2>Empty content message</h2><p class="uploadmessage">Upload message</p></div>' + + '<div class="nofilterresults hidden"></div>' + + '</div>' + ); + + App.initialize($('#preview')); + }); + afterEach(function() { + App._initialized = false; + }); + + describe('Download Url', function() { + var fileList; + + beforeEach(function() { + fileList = App.fileList; + }); + + it('returns correct download URL for single files', function() { + expect(fileList.getDownloadUrl('some file.txt')) + .toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2Fsubdir&files=some%20file.txt'); + expect(fileList.getDownloadUrl('some file.txt', '/anotherpath/abc')) + .toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2Fanotherpath%2Fabc&files=some%20file.txt'); + fileList.changeDirectory('/'); + expect(fileList.getDownloadUrl('some file.txt')) + .toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2F&files=some%20file.txt'); + }); + it('returns correct download URL for multiple files', function() { + expect(fileList.getDownloadUrl(['a b c.txt', 'd e f.txt'])) + .toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2Fsubdir&files=%5B%22a%20b%20c.txt%22%2C%22d%20e%20f.txt%22%5D'); + }); + it('returns the correct ajax URL', function() { + expect(fileList.getAjaxUrl('test', {a:1, b:'x y'})) + .toEqual(OC.webroot + '/index.php/apps/files_sharing/ajax/test.php?a=1&b=x%20y&t=sh4tok'); + }); + }); + }); +}); diff --git a/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php b/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php index b1113e7a455..0db8a1ed5bc 100644 --- a/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php +++ b/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php @@ -1,5 +1,6 @@ <?php /** + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> @@ -58,7 +59,7 @@ class SharingCheckMiddlewareTest extends \Test\TestCase { ->with('core', 'shareapi_allow_links', 'yes') ->will($this->returnValue('yes')); - $this->assertTrue(\Test_Helper::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled')); + $this->assertTrue(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled')); } public function testIsSharingEnabledWithAppDisabled() { @@ -68,7 +69,7 @@ class SharingCheckMiddlewareTest extends \Test\TestCase { ->with('files_sharing') ->will($this->returnValue(false)); - $this->assertFalse(\Test_Helper::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled')); + $this->assertFalse(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled')); } public function testIsSharingEnabledWithSharingDisabled() { @@ -84,6 +85,6 @@ class SharingCheckMiddlewareTest extends \Test\TestCase { ->with('core', 'shareapi_allow_links', 'yes') ->will($this->returnValue('no')); - $this->assertFalse(\Test_Helper::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled')); + $this->assertFalse(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled')); } } diff --git a/apps/files_sharing/tests/permissions.php b/apps/files_sharing/tests/permissions.php index 91f0347163a..c10333defaa 100644 --- a/apps/files_sharing/tests/permissions.php +++ b/apps/files_sharing/tests/permissions.php @@ -3,6 +3,7 @@ * @author Björn Schießle <schiessle@owncloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files_sharing/tests/sharedmount.php b/apps/files_sharing/tests/sharedmount.php index ff4cb4c0e49..d1db6a644f0 100644 --- a/apps/files_sharing/tests/sharedmount.php +++ b/apps/files_sharing/tests/sharedmount.php @@ -5,6 +5,7 @@ * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 @@ -61,11 +62,11 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase { self::TEST_FILES_SHARING_API_USER2, 31); $statement = "UPDATE `*PREFIX*share` SET `file_target` = ? where `share_with` = ?"; - $query = \OC_DB::prepare($statement); + $query = \OCP\DB::prepare($statement); $arguments = array('/foo/bar' . $this->folder, self::TEST_FILES_SHARING_API_USER2); $query->execute($arguments); - $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share`'); + $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*share`'); $result = $query->execute(); $shares = $result->fetchAll(); @@ -79,7 +80,7 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase { // share should have moved up - $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share`'); + $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*share`'); $result = $query->execute(); $shares = $result->fetchAll(); diff --git a/apps/files_sharing/tests/sizepropagation.php b/apps/files_sharing/tests/sizepropagation.php index 4ab3475ccfc..dbaa316f603 100644 --- a/apps/files_sharing/tests/sizepropagation.php +++ b/apps/files_sharing/tests/sizepropagation.php @@ -1,6 +1,7 @@ <?php /** - * @author Vincent Petry <pvince81@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/tests/testcase.php b/apps/files_sharing/tests/testcase.php index b9e9f077201..7533b13f79d 100644 --- a/apps/files_sharing/tests/testcase.php +++ b/apps/files_sharing/tests/testcase.php @@ -153,6 +153,7 @@ abstract class TestCase extends \Test\TestCase { \OC::$server->getUserSession()->setUser(null); \OC\Files\Filesystem::tearDown(); \OC::$server->getUserSession()->login($user, $password); + \OC::$server->getUserFolder($user); \OC_Util::setupFS($user); } diff --git a/apps/files_sharing/tests/unsharechildren.php b/apps/files_sharing/tests/unsharechildren.php index b49180fdc83..0cf551c0500 100644 --- a/apps/files_sharing/tests/unsharechildren.php +++ b/apps/files_sharing/tests/unsharechildren.php @@ -3,7 +3,7 @@ * @author Björn Schießle <schiessle@owncloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Robin Appelman <icewind@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/tests/updater.php b/apps/files_sharing/tests/updater.php index 294388bfe26..63ab452a5e1 100644 --- a/apps/files_sharing/tests/updater.php +++ b/apps/files_sharing/tests/updater.php @@ -3,7 +3,6 @@ * @author Björn Schießle <schiessle@owncloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. @@ -117,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); @@ -133,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); } /** diff --git a/apps/files_sharing/tests/watcher.php b/apps/files_sharing/tests/watcher.php index 4af5de6aaae..488792db4ef 100644 --- a/apps/files_sharing/tests/watcher.php +++ b/apps/files_sharing/tests/watcher.php @@ -4,6 +4,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * |