summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2019-10-25 10:02:06 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2019-10-25 21:39:45 +0200
commit52870fd1d24caba10726c95e266b876394e9dbf2 (patch)
tree82c547f651445d6b40068455c416ab64d276e644 /apps/files_sharing/tests
parent9039dd89efccd5c9be75b97692c5da60dc7c680f (diff)
downloadnextcloud-server-52870fd1d24caba10726c95e266b876394e9dbf2.tar.gz
nextcloud-server-52870fd1d24caba10726c95e266b876394e9dbf2.zip
Add unit tests for getting shares of a file
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php191
1 files changed, 185 insertions, 6 deletions
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index 5fd5e7c4a46..4fda1aa4156 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -833,6 +833,11 @@ class ShareAPIControllerTest extends TestCase {
->setNode($file1)
->setId(15);
+ $file1UserShareRecipientExpected = [
+ 'id' => 15,
+ 'share_type' => IShare::TYPE_USER,
+ ];
+
$file1UserShareOther = \OC::$server->getShareManager()->newShare();
$file1UserShareOther->setShareType(IShare::TYPE_USER)
->setSharedWith('recipient')
@@ -912,6 +917,20 @@ class ShareAPIControllerTest extends TestCase {
'share_type' => IShare::TYPE_EMAIL,
];
+ $file1CircleShareOwner = \OC::$server->getShareManager()->newShare();
+ $file1CircleShareOwner->setShareType(IShare::TYPE_CIRCLE)
+ ->setSharedWith('recipient')
+ ->setSharedBy('initiator')
+ ->setShareOwner('currentUser')
+ ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setNode($file1)
+ ->setId(423);
+
+ $file1CircleShareOwnerExpected = [
+ 'id' => 423,
+ 'share_type' => IShare::TYPE_CIRCLE,
+ ];
+
$file1RoomShareOwner = \OC::$server->getShareManager()->newShare();
$file1RoomShareOwner->setShareType(IShare::TYPE_ROOM)
->setSharedWith('recipient')
@@ -919,10 +938,10 @@ class ShareAPIControllerTest extends TestCase {
->setShareOwner('currentUser')
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($file1)
- ->setId(423);
+ ->setId(442);
$file1RoomShareOwnerExpected = [
- 'id' => 423,
+ 'id' => 442,
'share_type' => IShare::TYPE_ROOM,
];
@@ -933,13 +952,27 @@ class ShareAPIControllerTest extends TestCase {
->setShareOwner('currentUser')
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($file1)
- ->setId(442);
+ ->setId(815);
$file1RemoteShareOwnerExpected = [
- 'id' => 442,
+ 'id' => 815,
'share_type' => IShare::TYPE_REMOTE,
];
+ $file1RemoteGroupShareOwner = \OC::$server->getShareManager()->newShare();
+ $file1RemoteGroupShareOwner->setShareType(IShare::TYPE_REMOTE_GROUP)
+ ->setSharedWith('recipient')
+ ->setSharedBy('initiator')
+ ->setShareOwner('currentUser')
+ ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setNode($file1)
+ ->setId(816);
+
+ $file1RemoteGroupShareOwnerExpected = [
+ 'id' => 816,
+ 'share_type' => IShare::TYPE_REMOTE_GROUP,
+ ];
+
$file2UserShareOwner = \OC::$server->getShareManager()->newShare();
$file2UserShareOwner->setShareType(IShare::TYPE_USER)
->setSharedWith('recipient')
@@ -947,16 +980,157 @@ class ShareAPIControllerTest extends TestCase {
->setShareOwner('currentUser')
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($file2)
- ->setId(815);
+ ->setId(823);
$file2UserShareOwnerExpected = [
- 'id' => 815,
+ 'id' => 823,
'share_type' => IShare::TYPE_USER,
];
$data = [
[
[
+ 'path' => $file1,
+ ],
+ [
+ 'file1' => [
+ IShare::TYPE_USER => [$file1UserShareOwner, $file1UserShareOwner, $file1UserShareOwner],
+ ],
+ ],
+ [
+ ],
+ [
+ $file1UserShareOwnerExpected,
+ $file1UserShareOwnerExpected,
+ $file1UserShareOwnerExpected,
+ ]
+ ],
+ [
+ [
+ 'path' => $file1,
+ ],
+ [
+ 'file1' => [
+ IShare::TYPE_USER => [$file1UserShareOwner, $file1UserShareRecipient],
+ ],
+ ],
+ [
+ ],
+ [
+ $file1UserShareOwnerExpected,
+ $file1UserShareRecipientExpected,
+ ]
+ ],
+ [
+ [
+ 'path' => $file1,
+ ],
+ [
+ 'file1' => [
+ IShare::TYPE_USER => [$file1UserShareOwner, $file1UserShareRecipient, $file1UserShareInitiator, $file1UserShareOther],
+ ],
+ ],
+ [
+ ],
+ [
+ $file1UserShareOwnerExpected,
+ $file1UserShareRecipientExpected,
+ $file1UserShareInitiatorExpected,
+ $file1UserShareOtherExpected,
+ ]
+ ],
+ [
+ [
+ 'path' => $file1,
+ ],
+ [
+ 'file1' => [
+ IShare::TYPE_USER => [$file1UserShareRecipient, $file1UserShareInitiator, $file1UserShareOther],
+ ],
+ ],
+ [
+ ],
+ [
+ $file1UserShareInitiatorExpected,
+ ]
+ ],
+ [
+ [
+ 'path' => $file1,
+ ],
+ [
+ 'file1' => [
+ IShare::TYPE_USER => [$file1UserShareOwner],
+ IShare::TYPE_GROUP => [$file1GroupShareRecipient],
+ ],
+ ],
+ [
+ ],
+ [
+ $file1UserShareOwnerExpected,
+ $file1GroupShareRecipientExpected,
+ ]
+ ],
+ [
+ [
+ 'path' => $file1,
+ ],
+ [
+ 'file1' => [
+ IShare::TYPE_USER => [$file1UserShareOwner],
+ IShare::TYPE_GROUP => [$file1GroupShareOwner],
+ IShare::TYPE_LINK => [$file1LinkShareOwner],
+ IShare::TYPE_EMAIL => [$file1EmailShareOwner],
+ IShare::TYPE_CIRCLE => [$file1CircleShareOwner],
+ IShare::TYPE_ROOM => [$file1RoomShareOwner],
+ IShare::TYPE_REMOTE => [$file1RemoteShareOwner],
+ IShare::TYPE_REMOTE_GROUP => [$file1RemoteGroupShareOwner],
+ ],
+ ],
+ [
+ ],
+ [
+ $file1UserShareOwnerExpected,
+ $file1GroupShareOwnerExpected,
+ $file1LinkShareOwnerExpected,
+ $file1RoomShareOwnerExpected,
+ ]
+ ],
+ [
+ [
+ 'path' => $file1,
+ ],
+ [
+ 'file1' => [
+ IShare::TYPE_USER => [$file1UserShareOwner],
+ IShare::TYPE_GROUP => [$file1GroupShareOwner],
+ IShare::TYPE_LINK => [$file1LinkShareOwner],
+ IShare::TYPE_EMAIL => [$file1EmailShareOwner],
+ IShare::TYPE_CIRCLE => [$file1CircleShareOwner],
+ IShare::TYPE_ROOM => [$file1RoomShareOwner],
+ IShare::TYPE_REMOTE => [$file1RemoteShareOwner],
+ IShare::TYPE_REMOTE_GROUP => [$file1RemoteGroupShareOwner],
+ ],
+ ],
+ [
+ IShare::TYPE_EMAIL => true,
+ IShare::TYPE_CIRCLE => true,
+ IShare::TYPE_REMOTE => true,
+ IShare::TYPE_REMOTE_GROUP => true,
+ ],
+ [
+ $file1UserShareOwnerExpected,
+ $file1GroupShareOwnerExpected,
+ $file1LinkShareOwnerExpected,
+ $file1EmailShareOwnerExpected,
+ $file1CircleShareOwnerExpected,
+ $file1RoomShareOwnerExpected,
+ $file1RemoteShareOwnerExpected,
+ $file1RemoteGroupShareOwnerExpected,
+ ]
+ ],
+ [
+ [
'path' => $folder,
'subfiles' => 'true',
],
@@ -1177,6 +1351,7 @@ class ShareAPIControllerTest extends TestCase {
$shareProviderExistsMap = [
[IShare::TYPE_EMAIL, $extraShareTypes[IShare::TYPE_EMAIL] ?? false],
+ [IShare::TYPE_CIRCLE, $extraShareTypes[IShare::TYPE_CIRCLE] ?? false],
];
$this->shareManager
@@ -1187,6 +1362,10 @@ class ShareAPIControllerTest extends TestCase {
->method('outgoingServer2ServerSharesAllowed')
->willReturn($extraShareTypes[ISHARE::TYPE_REMOTE] ?? false);
+ $this->shareManager
+ ->method('outgoingServer2ServerGroupSharesAllowed')
+ ->willReturn($extraShareTypes[ISHARE::TYPE_REMOTE_GROUP] ?? false);
+
$this->groupManager
->method('isInGroup')
->will($this->returnCallback(