summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-02-26 10:48:07 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-26 10:48:07 +0100
commit66536f912ebe7b2287dad839ffac66f949c1bf41 (patch)
tree95d8deb68531d28858f96df308fdcb9560b9a8e8 /apps/files_sharing/tests
parentc6c15ba8252231b90e0600d5b6e43c3c10cc3bcd (diff)
parent0c9c7737b4b03f17af957b5036c143351a445a1b (diff)
downloadnextcloud-server-66536f912ebe7b2287dad839ffac66f949c1bf41.tar.gz
nextcloud-server-66536f912ebe7b2287dad839ffac66f949c1bf41.zip
Merge pull request #22640 from owncloud/fix_22587
Remove delete permissions for read-only federated reshares
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/api/share20ocstest.php120
1 files changed, 120 insertions, 0 deletions
diff --git a/apps/files_sharing/tests/api/share20ocstest.php b/apps/files_sharing/tests/api/share20ocstest.php
index 44d94868a32..057df20a5a4 100644
--- a/apps/files_sharing/tests/api/share20ocstest.php
+++ b/apps/files_sharing/tests/api/share20ocstest.php
@@ -553,6 +553,11 @@ class Share20OCSTest extends \Test\TestCase {
->willReturn($userFolder);
$path = $this->getMock('\OCP\Files\File');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
$userFolder->expects($this->once())
->method('get')
->with('valid-path')
@@ -586,6 +591,11 @@ class Share20OCSTest extends \Test\TestCase {
->willReturn($userFolder);
$path = $this->getMock('\OCP\Files\File');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
$userFolder->expects($this->once())
->method('get')
->with('valid-path')
@@ -632,6 +642,11 @@ class Share20OCSTest extends \Test\TestCase {
->willReturn($userFolder);
$path = $this->getMock('\OCP\Files\File');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
$userFolder->expects($this->once())
->method('get')
->with('valid-path')
@@ -678,6 +693,11 @@ class Share20OCSTest extends \Test\TestCase {
->willReturn($userFolder);
$path = $this->getMock('\OCP\Files\File');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
$userFolder->expects($this->once())
->method('get')
->with('valid-path')
@@ -724,6 +744,11 @@ class Share20OCSTest extends \Test\TestCase {
->willReturn($userFolder);
$path = $this->getMock('\OCP\Files\Folder');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
$userFolder->expects($this->once())
->method('get')
->with('valid-path')
@@ -754,6 +779,11 @@ class Share20OCSTest extends \Test\TestCase {
]));
$path = $this->getMock('\OCP\Files\Folder');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
$this->rootFolder->method('getUserFolder')->with($this->currentUser->getUID())->will($this->returnSelf());
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
@@ -776,6 +806,11 @@ class Share20OCSTest extends \Test\TestCase {
]));
$path = $this->getMock('\OCP\Files\Folder');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
$this->rootFolder->method('getUserFolder')->with($this->currentUser->getUID())->will($this->returnSelf());
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
@@ -799,6 +834,11 @@ class Share20OCSTest extends \Test\TestCase {
]));
$path = $this->getMock('\OCP\Files\File');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
$this->rootFolder->method('getUserFolder')->with($this->currentUser->getUID())->will($this->returnSelf());
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
@@ -827,6 +867,11 @@ class Share20OCSTest extends \Test\TestCase {
]));
$path = $this->getMock('\OCP\Files\Folder');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
$this->rootFolder->method('getUserFolder')->with($this->currentUser->getUID())->will($this->returnSelf());
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
@@ -866,6 +911,11 @@ class Share20OCSTest extends \Test\TestCase {
]));
$path = $this->getMock('\OCP\Files\Folder');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
$this->rootFolder->method('getUserFolder')->with($this->currentUser->getUID())->will($this->returnSelf());
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
@@ -905,6 +955,11 @@ class Share20OCSTest extends \Test\TestCase {
]));
$path = $this->getMock('\OCP\Files\Folder');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
$this->rootFolder->method('getUserFolder')->with($this->currentUser->getUID())->will($this->returnSelf());
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
@@ -947,6 +1002,11 @@ class Share20OCSTest extends \Test\TestCase {
]));
$path = $this->getMock('\OCP\Files\Folder');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
$this->rootFolder->method('getUserFolder')->with($this->currentUser->getUID())->will($this->returnSelf());
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
@@ -961,6 +1021,66 @@ class Share20OCSTest extends \Test\TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
+ /**
+ * Test for https://github.com/owncloud/core/issues/22587
+ * TODO: Remove once proper solution is in place
+ */
+ public function testCreateReshareOfFederatedMountNoDeletePermissions() {
+ $share = \OC::$server->getShareManager()->newShare();
+ $this->shareManager->method('newShare')->willReturn($share);
+
+ $ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS')
+ ->setConstructorArgs([
+ $this->shareManager,
+ $this->groupManager,
+ $this->userManager,
+ $this->request,
+ $this->rootFolder,
+ $this->urlGenerator,
+ $this->currentUser
+ ])->setMethods(['formatShare'])
+ ->getMock();
+
+ $this->request
+ ->method('getParam')
+ ->will($this->returnValueMap([
+ ['path', null, 'valid-path'],
+ ['permissions', null, \OCP\Constants::PERMISSION_ALL],
+ ['shareType', $this->any(), \OCP\Share::SHARE_TYPE_USER],
+ ['shareWith', null, 'validUser'],
+ ]));
+
+ $userFolder = $this->getMock('\OCP\Files\Folder');
+ $this->rootFolder->expects($this->once())
+ ->method('getUserFolder')
+ ->with('currentUser')
+ ->willReturn($userFolder);
+
+ $path = $this->getMock('\OCP\Files\Folder');
+ $storage = $this->getMock('OCP\Files\Storage');
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(true);
+ $path->method('getStorage')->willReturn($storage);
+ $path->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ);
+ $userFolder->expects($this->once())
+ ->method('get')
+ ->with('valid-path')
+ ->willReturn($path);
+
+ $this->userManager->method('userExists')->with('validUser')->willReturn(true);
+
+ $this->shareManager
+ ->expects($this->once())
+ ->method('createShare')
+ ->with($this->callback(function (\OCP\Share\IShare $share) {
+ return $share->getPermissions() === \OCP\Constants::PERMISSION_READ;
+ }))
+ ->will($this->returnArgument(0));
+
+ $ocs->createShare();
+ }
+
public function testUpdateShareCantAccess() {
$share = \OC::$server->getShareManager()->newShare();