aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-05-03 15:21:53 +0200
committerRobin Appelman <robin@icewind.nl>2024-05-13 16:41:56 +0200
commitd1d6e79375c971201bea8e9881329f52cc237323 (patch)
tree151b3de1e1a6f0d8321880fac1fe1bc0ae8e6626 /tests
parentdd5d75d86f142bd22b5c7ac724dca2127a2094ab (diff)
downloadnextcloud-server-d1d6e79375c971201bea8e9881329f52cc237323.tar.gz
nextcloud-server-d1d6e79375c971201bea8e9881329f52cc237323.zip
test: adjust test to new permissions check logic
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Share20/ManagerTest.php21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index c2ca5fe9811..aeea1b5b863 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -612,7 +612,7 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'verifyPassword', ['password']);
}
- public function createShare($id, $type, $path, $sharedWith, $sharedBy, $shareOwner,
+ public function createShare($id, $type, $node, $sharedWith, $sharedBy, $shareOwner,
$permissions, $expireDate = null, $password = null, $attributes = null) {
$share = $this->createMock(IShare::class);
@@ -620,7 +620,10 @@ class ManagerTest extends \Test\TestCase {
$share->method('getSharedWith')->willReturn($sharedWith);
$share->method('getSharedBy')->willReturn($sharedBy);
$share->method('getShareOwner')->willReturn($shareOwner);
- $share->method('getNode')->willReturn($path);
+ $share->method('getNode')->willReturn($node);
+ if ($node && $node->getId()) {
+ $share->method('getNodeId')->willReturn($node->getId());
+ }
$share->method('getPermissions')->willReturn($permissions);
$share->method('getAttributes')->willReturn($attributes);
$share->method('getExpirationDate')->willReturn($expireDate);
@@ -645,8 +648,10 @@ class ManagerTest extends \Test\TestCase {
->willReturn(false);
$file->method('getStorage')
->willReturn($storage);
+ $file->method('getId')->willReturn(108);
$node->method('getStorage')
->willReturn($storage);
+ $node->method('getId')->willReturn(108);
$data = [
[$this->createShare(null, IShare::TYPE_USER, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
@@ -676,6 +681,7 @@ class ManagerTest extends \Test\TestCase {
];
$nonShareAble = $this->createMock(Folder::class);
+ $nonShareAble->method('getId')->willReturn(108);
$nonShareAble->method('isShareable')->willReturn(false);
$nonShareAble->method('getPath')->willReturn('path');
$nonShareAble->method('getName')->willReturn('name');
@@ -711,16 +717,22 @@ class ManagerTest extends \Test\TestCase {
$data[] = [$this->createShare(null, IShare::TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Cannot increase permissions of path', true];
$data[] = [$this->createShare(null, IShare::TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Cannot increase permissions of path', true];
+ $nonMovableStorage = $this->createMock(Storage\IStorage::class);
+ $nonMovableStorage->method('instanceOfStorage')
+ ->with('\OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $nonMovableStorage->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_ALL);
$nonMoveableMountPermssions = $this->createMock(Folder::class);
$nonMoveableMountPermssions->method('isShareable')->willReturn(true);
$nonMoveableMountPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ);
$nonMoveableMountPermssions->method('getId')->willReturn(108);
$nonMoveableMountPermssions->method('getPath')->willReturn('path');
$nonMoveableMountPermssions->method('getName')->willReturn('name');
+ $nonMoveableMountPermssions->method('getInternalPath')->willReturn('');
$nonMoveableMountPermssions->method('getOwner')
->willReturn($owner);
$nonMoveableMountPermssions->method('getStorage')
- ->willReturn($storage);
+ ->willReturn($nonMovableStorage);
$data[] = [$this->createShare(null, IShare::TYPE_USER, $nonMoveableMountPermssions, $user2, $user0, $user0, 11, null, null), 'Cannot increase permissions of path', false];
$data[] = [$this->createShare(null, IShare::TYPE_GROUP, $nonMoveableMountPermssions, $group0, $user0, $user0, 11, null, null), 'Cannot increase permissions of path', false];
@@ -794,8 +806,7 @@ class ManagerTest extends \Test\TestCase {
->method('getId')
->willReturn(42);
// Id 108 is used in the data to refer to the node of the share.
- $userFolder->expects($this->any())
- ->method('getById')
+ $userFolder->method('getById')
->with(108)
->willReturn([$share->getNode()]);
$userFolder->expects($this->any())