summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-11-02 11:04:33 +0100
committerGitHub <noreply@github.com>2016-11-02 11:04:33 +0100
commit7da3ba3f91f561da664fc601b29cd7948f876f3f (patch)
tree8e320070d69622432fdf8ab641b36b160a901533 /apps/files_sharing
parent42b0a0d2afe95b974545436e112a1d97edaeeb1a (diff)
parentf2b2b8d8940b2487d7f9f3a3a304a6a95d145fd2 (diff)
downloadnextcloud-server-7da3ba3f91f561da664fc601b29cd7948f876f3f.tar.gz
nextcloud-server-7da3ba3f91f561da664fc601b29cd7948f876f3f.zip
Merge pull request #657 from nextcloud/share-by-mail
New share provider: Share by mail
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php67
-rw-r--r--apps/files_sharing/lib/Controller/ShareesAPIController.php187
-rw-r--r--apps/files_sharing/tests/ApiTest.php10
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php2
-rw-r--r--apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php308
5 files changed, 312 insertions, 262 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index ad9ac6c0851..4f80b8fc966 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -36,7 +36,6 @@ use OCP\IL10N;
use OCP\IUserManager;
use OCP\IRequest;
use OCP\IURLGenerator;
-use OCP\IUser;
use OCP\Files\IRootFolder;
use OCP\Lock\LockedException;
use OCP\Share\IManager;
@@ -186,7 +185,11 @@ class ShareAPIController extends OCSController {
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) {
$result['share_with'] = $share->getSharedWith();
- $result['share_with_displayname'] = $share->getSharedWith();
+ $result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'CLOUD');
+ $result['token'] = $share->getToken();
+ } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
+ $result['share_with'] = $share->getSharedWith();
+ $result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL');
$result['token'] = $share->getToken();
}
@@ -196,6 +199,28 @@ class ShareAPIController extends OCSController {
}
/**
+ * Check if one of the users address books knows the exact property, if
+ * yes we return the full name.
+ *
+ * @param string $query
+ * @param string $property
+ * @return string
+ */
+ private function getDisplayNameFromAddressBook($query, $property) {
+ // FIXME: If we inject the contacts manager it gets initialized bofore any address books are registered
+ $result = \OC::$server->getContactsManager()->search($query, [$property]);
+ foreach ($result as $r) {
+ foreach($r[$property] as $value) {
+ if ($value === $query) {
+ return $r['FN'];
+ }
+ }
+ }
+
+ return $query;
+ }
+
+ /**
* Get a specific share by id
*
* @NoAdminRequired
@@ -400,6 +425,17 @@ class ShareAPIController extends OCSController {
$share->setSharedWith($shareWith);
$share->setPermissions($permissions);
+ } else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
+ if ($share->getNodeType() === 'file') {
+ $share->setPermissions(\OCP\Constants::PERMISSION_READ);
+ } else {
+ $share->setPermissions(
+ \OCP\Constants::PERMISSION_READ |
+ \OCP\Constants::PERMISSION_CREATE |
+ \OCP\Constants::PERMISSION_UPDATE |
+ \OCP\Constants::PERMISSION_DELETE);
+ }
+ $share->setSharedWith($shareWith);
} else {
throw new OCSBadRequestException($this->l->t('Unknown share type'));
}
@@ -466,6 +502,9 @@ class ShareAPIController extends OCSController {
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0));
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0));
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0));
+ if($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
+ $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_EMAIL, $node, false, -1, 0));
+ }
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_REMOTE, $node, false, -1, 0));
}
@@ -541,7 +580,12 @@ class ShareAPIController extends OCSController {
$userShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $path, $reshares, -1, 0);
$groupShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0);
$linkShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0);
- $shares = array_merge($userShares, $groupShares, $linkShares);
+ if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
+ $mailShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_EMAIL, $path, $reshares, -1, 0);
+ } else {
+ $mailShares = [];
+ }
+ $shares = array_merge($userShares, $groupShares, $linkShares, $mailShares);
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
$federatedShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_REMOTE, $path, $reshares, -1, 0);
@@ -774,13 +818,24 @@ class ShareAPIController extends OCSController {
// First check if it is an internal share.
try {
$share = $this->shareManager->getShareById('ocinternal:' . $id);
+ return $share;
} catch (ShareNotFound $e) {
- if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
- throw new ShareNotFound();
+ // Do nothing, just try the other share type
+ }
+
+ try {
+ if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
+ $share = $this->shareManager->getShareById('ocMailShare:' . $id);
+ return $share;
}
+ } catch (ShareNotFound $e) {
+ // Do nothing, just try the other share type
+ }
- $share = $this->shareManager->getShareById('ocFederatedSharing:' . $id);
+ if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
+ throw new ShareNotFound();
}
+ $share = $this->shareManager->getShareById('ocFederatedSharing:' . $id);
return $share;
}
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php
index 99c6b55240d..5e01c9bfb09 100644
--- a/apps/files_sharing/lib/Controller/ShareesAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php
@@ -273,15 +273,15 @@ class ShareesAPIController extends OCSController {
/**
* @param string $search
- * @return array possible sharees
+ * @return array
*/
protected function getRemote($search) {
- $this->result['remotes'] = [];
+ $result = ['results' => [], 'exact' => []];
// Search in contacts
//@todo Pagination missing
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN']);
- $foundRemoteById = false;
+ $result['exactIdMatch'] = false;
foreach ($addressBookContacts as $contact) {
if (isset($contact['isLocalSystemBook'])) {
continue;
@@ -295,10 +295,10 @@ class ShareesAPIController extends OCSController {
list(, $serverUrl) = $this->splitUserRemote($cloudId);
if (strtolower($contact['FN']) === strtolower($search) || strtolower($cloudId) === strtolower($search)) {
if (strtolower($cloudId) === strtolower($search)) {
- $foundRemoteById = true;
+ $result['exactIdMatch'] = true;
}
- $this->result['exact']['remotes'][] = [
- 'label' => $contact['FN'],
+ $result['exact'][] = [
+ 'label' => $contact['FN'] . " ($cloudId)",
'value' => [
'shareType' => Share::SHARE_TYPE_REMOTE,
'shareWith' => $cloudId,
@@ -306,8 +306,8 @@ class ShareesAPIController extends OCSController {
],
];
} else {
- $this->result['remotes'][] = [
- 'label' => $contact['FN'],
+ $result['results'][] = [
+ 'label' => $contact['FN'] . " ($cloudId)",
'value' => [
'shareType' => Share::SHARE_TYPE_REMOTE,
'shareWith' => $cloudId,
@@ -320,11 +320,11 @@ class ShareesAPIController extends OCSController {
}
if (!$this->shareeEnumeration) {
- $this->result['remotes'] = [];
+ $result['results'] = [];
}
- if (!$foundRemoteById && substr_count($search, '@') >= 1 && $this->offset === 0) {
- $this->result['exact']['remotes'][] = [
+ if (!$result['exactIdMatch'] && substr_count($search, '@') >= 1 && $this->offset === 0) {
+ $result['exact'][] = [
'label' => $search,
'value' => [
'shareType' => Share::SHARE_TYPE_REMOTE,
@@ -334,6 +334,8 @@ class ShareesAPIController extends OCSController {
}
$this->reachedEndFor[] = 'remotes';
+
+ return $result;
}
/**
@@ -405,68 +407,6 @@ class ShareesAPIController extends OCSController {
}
/**
- * @param string $search
- */
- protected function getEmails($search) {
- $this->result['emails'] = [];
- $this->result['exact']['emails'] = [];
-
- $foundEmail = false;
-
- // Search in contacts
- //@todo Pagination missing
- $addressBookContacts = $this->contactsManager->search($search, ['FN', 'EMAIL']);
- foreach ($addressBookContacts as $contact) {
- if (!isset($contact['EMAIL'])) {
- continue;
- }
-
- $emails = $contact['EMAIL'];
- if (!is_array($emails)) {
- $emails = [$emails];
- }
-
- foreach ($emails as $email) {
- if (strtolower($search) === strtolower($contact['FN']) ||
- strtolower($search) === strtolower($email)
- ) {
- if (strtolower($search) === strtolower($email)) {
- $foundEmail = true;
- }
-
- $this->result['exact']['emails'][] = [
- 'label' => $contact['FN'],
- 'value' => [
- 'shareType' => Share::SHARE_TYPE_EMAIL,
- 'shareWith' => $email,
- ],
- ];
- } else if ($this->shareeEnumeration) {
- $this->result['emails'][] = [
- 'label' => $contact['FN'],
- 'value' => [
- 'shareType' => Share::SHARE_TYPE_EMAIL,
- 'shareWith' => $email,
- ],
- ];
- }
- }
- }
-
- if (!$foundEmail && substr_count($search, '@') >= 1 && $this->offset === 0) {
- $this->result['exact']['emails'][] = [
- 'label' => $search,
- 'value' => [
- 'shareType' => Share::SHARE_TYPE_EMAIL,
- 'shareWith' => $search,
- ],
- ];
- }
-
- $this->reachedEndFor[] = 'emails';
- }
-
- /**
* @NoAdminRequired
*
* @param string $search
@@ -487,17 +427,16 @@ class ShareesAPIController extends OCSController {
$shareTypes = [
Share::SHARE_TYPE_USER,
+ Share::SHARE_TYPE_REMOTE,
+ Share::SHARE_TYPE_EMAIL
];
if ($this->shareManager->allowGroupSharing()) {
$shareTypes[] = Share::SHARE_TYPE_GROUP;
}
- $shareTypes[] = Share::SHARE_TYPE_EMAIL;
- $shareTypes[] = Share::SHARE_TYPE_REMOTE;
-
- if (is_array($shareType)) {
- $shareTypes = array_intersect($shareTypes, $shareType);
+ if (isset($_GET['shareType']) && is_array($_GET['shareType'])) {
+ $shareTypes = array_intersect($shareTypes, $_GET['shareType']);
sort($shareTypes);
} else if (is_numeric($shareType)) {
$shareTypes = array_intersect($shareTypes, [(int) $shareType]);
@@ -509,6 +448,11 @@ class ShareesAPIController extends OCSController {
$shareTypes = array_diff($shareTypes, [Share::SHARE_TYPE_REMOTE]);
}
+ if (!$this->shareManager->shareProviderExists(Share::SHARE_TYPE_EMAIL)) {
+ // Remove mail shares from type array, because the share provider is not loaded
+ $shareTypes = array_diff($shareTypes, [Share::SHARE_TYPE_EMAIL]);
+ }
+
$this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
$this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
$this->limit = (int) $perPage;
@@ -560,13 +504,30 @@ class ShareesAPIController extends OCSController {
}
// Get remote
+ $remoteResults = ['results' => [], 'exact' => [], 'exactIdMatch' => false];
if (in_array(Share::SHARE_TYPE_REMOTE, $shareTypes)) {
- $this->getRemote($search);
+ $remoteResults = $this->getRemote($search);
}
- // Get email
+ $mailResults = ['results' => [], 'exact' => [], 'exactIdMatch' => false];
if (in_array(Share::SHARE_TYPE_EMAIL, $shareTypes)) {
- $this->getEmails($search);
+ $mailResults = $this->getEmail($search);
+ }
+
+ // if we have a exact match, either for the federated cloud id or for the
+ // email address we only return the exact match. It is highly unlikely
+ // that the exact same email address and federated cloud id exists
+ if ($mailResults['exactIdMatch'] && !$remoteResults['exactIdMatch']) {
+ $this->result['emails'] = $mailResults['results'];
+ $this->result['exact']['emails'] = $mailResults['exact'];
+ } else if (!$mailResults['exactIdMatch'] && $remoteResults['exactIdMatch']) {
+ $this->result['remotes'] = $remoteResults['results'];
+ $this->result['exact']['remotes'] = $remoteResults['exact'];
+ } else {
+ $this->result['remotes'] = $remoteResults['results'];
+ $this->result['exact']['remotes'] = $remoteResults['exact'];
+ $this->result['emails'] = $mailResults['results'];
+ $this->result['exact']['emails'] = $mailResults['exact'];
}
$response = new Http\DataResponse($this->result);
@@ -584,6 +545,70 @@ class ShareesAPIController extends OCSController {
}
/**
+ * @param string $search
+ * @return array
+ */
+ protected function getEmail($search) {
+ $result = ['results' => [], 'exact' => []];
+
+ // Search in contacts
+ //@todo Pagination missing
+ $addressBookContacts = $this->contactsManager->search($search, ['EMAIL', 'FN']);
+ $result['exactIdMatch'] = false;
+ foreach ($addressBookContacts as $contact) {
+ if (isset($contact['isLocalSystemBook'])) {
+ continue;
+ }
+ if (isset($contact['EMAIL'])) {
+ $emailAddresses = $contact['EMAIL'];
+ if (!is_array($emailAddresses)) {
+ $emailAddresses = [$emailAddresses];
+ }
+ foreach ($emailAddresses as $emailAddress) {
+ if (strtolower($contact['FN']) === strtolower($search) || strtolower($emailAddress) === strtolower($search)) {
+ if (strtolower($emailAddress) === strtolower($search)) {
+ $result['exactIdMatch'] = true;
+ }
+ $result['exact'][] = [
+ 'label' => $contact['FN'] . " ($emailAddress)",
+ 'value' => [
+ 'shareType' => Share::SHARE_TYPE_EMAIL,
+ 'shareWith' => $emailAddress,
+ ],
+ ];
+ } else {
+ $result['results'][] = [
+ 'label' => $contact['FN'] . " ($emailAddress)",
+ 'value' => [
+ 'shareType' => Share::SHARE_TYPE_EMAIL,
+ 'shareWith' => $emailAddress,
+ ],
+ ];
+ }
+ }
+ }
+ }
+
+ if (!$this->shareeEnumeration) {
+ $result['results'] = [];
+ }
+
+ if (!$result['exactIdMatch'] && filter_var($search, FILTER_VALIDATE_EMAIL)) {
+ $result['exact'][] = [
+ 'label' => $search,
+ 'value' => [
+ 'shareType' => Share::SHARE_TYPE_EMAIL,
+ 'shareWith' => $search,
+ ],
+ ];
+ }
+
+ $this->reachedEndFor[] = 'emails';
+
+ return $result;
+ }
+
+ /**
* Generates a bunch of pagination links for the current page
*
* @param int $page Current page
diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php
index 6ab0cb4e1a6..540905a7dc9 100644
--- a/apps/files_sharing/tests/ApiTest.php
+++ b/apps/files_sharing/tests/ApiTest.php
@@ -234,6 +234,7 @@ class ApiTest extends TestCase {
function testEnfoceLinkPassword() {
+ $password = md5(time());
$appConfig = \OC::$server->getAppConfig();
$appConfig->setValue('core', 'shareapi_enforce_links_password', 'yes');
@@ -257,14 +258,14 @@ class ApiTest extends TestCase {
// share with password should succeed
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'bar');
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', $password);
$ocs->cleanup();
$data = $result->getData();
// setting new password should succeed
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $ocs->updateShare($data['id'], null, 'bar');
+ $ocs->updateShare($data['id'], null, $password);
$ocs->cleanup();
// removing password should fail
@@ -887,6 +888,9 @@ class ApiTest extends TestCase {
* @depends testCreateShareLink
*/
function testUpdateShare() {
+
+ $password = md5(time());
+
$node1 = $this->userFolder->get($this->filename);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
@@ -915,7 +919,7 @@ class ApiTest extends TestCase {
$this->assertNull($share2->getPassword());
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $ocs->updateShare($share2->getId(), null, 'foo');
+ $ocs->updateShare($share2->getId(), null, $password);
$ocs->cleanup();
$share2 = $this->shareManager->getShareById('ocinternal:' . $share2->getId());
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index 6ad0576b6fa..890fdb6eda0 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -23,8 +23,10 @@
*/
namespace OCA\Files_Sharing\Tests\Controller;
+use OC\ContactsManager;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSNotFoundException;
+use OCP\Contacts;
use OCP\Files\Folder;
use OCP\IL10N;
use OCA\Files_Sharing\Controller\ShareAPIController;
diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
index 6ee1ff596e4..e8ee55d1845 100644
--- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
@@ -771,28 +771,44 @@ class ShareesAPIControllerTest extends TestCase {
$this->assertCount((int) $reachedEnd, $this->invokePrivate($this->sharees, 'reachedEndFor'));
}
+ /**
+ * @dataProvider dataGetRemote
+ *
+ * @param string $searchTerm
+ * @param array $contacts
+ * @param bool $shareeEnumeration
+ * @param array $expected
+ * @param bool $reachedEnd
+ */
+ public function testGetRemote($searchTerm, $contacts, $shareeEnumeration, $expected, $reachedEnd) {
+ $this->invokePrivate($this->sharees, 'shareeEnumeration', [$shareeEnumeration]);
+ $this->contactsManager->expects($this->any())
+ ->method('search')
+ ->with($searchTerm, ['CLOUD', 'FN'])
+ ->willReturn($contacts);
+
+ $result = $this->invokePrivate($this->sharees, 'getRemote', [$searchTerm]);
+
+ $this->assertEquals($expected, $result);
+ $this->assertCount((int) $reachedEnd, $this->invokePrivate($this->sharees, 'reachedEndFor'));
+ }
+
public function dataGetRemote() {
return [
- ['test', [], true, [], [], true],
- ['test', [], false, [], [], true],
+ ['test', [], true, ['results' => [], 'exact' => [], 'exactIdMatch' => false], true],
+ ['test', [], false, ['results' => [], 'exact' => [], 'exactIdMatch' => false], true],
[
'test@remote',
[],
true,
- [
- ['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']],
- ],
- [],
+ ['results' => [], 'exact' => [['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']]], 'exactIdMatch' => false],
true,
],
[
'test@remote',
[],
false,
- [
- ['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']],
- ],
- [],
+ ['results' => [], 'exact' => [['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']]], 'exactIdMatch' => false],
true,
],
[
@@ -814,10 +830,7 @@ class ShareesAPIControllerTest extends TestCase {
],
],
true,
- [],
- [
- ['label' => 'User @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']],
- ],
+ ['results' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => [], 'exactIdMatch' => false],
true,
],
[
@@ -839,8 +852,7 @@ class ShareesAPIControllerTest extends TestCase {
],
],
false,
- [],
- [],
+ ['results' => [], 'exact' => [], 'exactIdMatch' => false],
true,
],
[
@@ -862,12 +874,7 @@ class ShareesAPIControllerTest extends TestCase {
],
],
true,
- [
- ['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']],
- ],
- [
- ['label' => 'User @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']],
- ],
+ ['results' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => [['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']]], 'exactIdMatch' => false],
true,
],
[
@@ -889,10 +896,7 @@ class ShareesAPIControllerTest extends TestCase {
],
],
false,
- [
- ['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']],
- ],
- [],
+ ['results' => [], 'exact' => [['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']]], 'exactIdMatch' => false],
true,
],
[
@@ -914,10 +918,7 @@ class ShareesAPIControllerTest extends TestCase {
],
],
true,
- [
- ['label' => 'User @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']],
- ],
- [],
+ ['results' => [], 'exact' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exactIdMatch' => true],
true,
],
[
@@ -939,10 +940,7 @@ class ShareesAPIControllerTest extends TestCase {
],
],
false,
- [
- ['label' => 'User @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']],
- ],
- [],
+ ['results' => [], 'exact' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exactIdMatch' => true],
true,
],
// contact with space
@@ -965,10 +963,7 @@ class ShareesAPIControllerTest extends TestCase {
],
],
false,
- [
- ['label' => 'User Name @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user name@localhost', 'server' => 'localhost']],
- ],
- [],
+ ['results' => [], 'exact' => [['label' => 'User Name @ Localhost (user name@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user name@localhost', 'server' => 'localhost']]], 'exactIdMatch' => true],
true,
],
// remote with space, no contact
@@ -991,62 +986,57 @@ class ShareesAPIControllerTest extends TestCase {
],
],
false,
- [
- ['label' => 'user space@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user space@remote']],
- ],
- [],
+ ['results' => [], 'exact' => [['label' => 'user space@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user space@remote']]], 'exactIdMatch' => false],
true,
],
];
}
/**
- * @dataProvider dataGetRemote
+ * @dataProvider dataGetEmail
*
* @param string $searchTerm
* @param array $contacts
* @param bool $shareeEnumeration
- * @param array $exactExpected
* @param array $expected
* @param bool $reachedEnd
*/
- public function testGetRemote($searchTerm, $contacts, $shareeEnumeration, $exactExpected, $expected, $reachedEnd) {
+ public function testGetEmail($searchTerm, $contacts, $shareeEnumeration, $expected, $reachedEnd) {
$this->invokePrivate($this->sharees, 'shareeEnumeration', [$shareeEnumeration]);
$this->contactsManager->expects($this->any())
->method('search')
- ->with($searchTerm, ['CLOUD', 'FN'])
+ ->with($searchTerm, ['EMAIL', 'FN'])
->willReturn($contacts);
- $this->invokePrivate($this->sharees, 'getRemote', [$searchTerm]);
- $result = $this->invokePrivate($this->sharees, 'result');
+ $result = $this->invokePrivate($this->sharees, 'getEmail', [$searchTerm]);
- $this->assertEquals($exactExpected, $result['exact']['remotes']);
- $this->assertEquals($expected, $result['remotes']);
+ $this->assertEquals($expected, $result);
$this->assertCount((int) $reachedEnd, $this->invokePrivate($this->sharees, 'reachedEndFor'));
}
- public function dataGetEmails() {
+ public function dataGetEmail() {
return [
- ['test', [], true, [], [], true],
- ['test', [], false, [], [], true],
+ ['test', [], true, ['results' => [], 'exact' => [], 'exactIdMatch' => false], true],
+ ['test', [], false, ['results' => [], 'exact' => [], 'exactIdMatch' => false], true],
[
'test@remote.com',
[],
true,
- [
- ['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']],
- ],
+ ['results' => [], 'exact' => [['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]], 'exactIdMatch' => false],
+ true,
+ ],
+ [ // no valid email address
+ 'test@remote',
[],
true,
+ ['results' => [], 'exact' => [], 'exactIdMatch' => false],
+ true,
],
[
'test@remote.com',
[],
false,
- [
- ['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']],
- ],
- [],
+ ['results' => [], 'exact' => [['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]], 'exactIdMatch' => false],
true,
],
[
@@ -1063,15 +1053,12 @@ class ShareesAPIControllerTest extends TestCase {
[
'FN' => 'User @ Localhost',
'EMAIL' => [
- 'username@localhost.com',
+ 'username@localhost',
],
],
],
true,
- [],
- [
- ['label' => 'User @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost.com']],
- ],
+ ['results' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => [], 'exactIdMatch' => false],
true,
],
[
@@ -1088,13 +1075,12 @@ class ShareesAPIControllerTest extends TestCase {
[
'FN' => 'User @ Localhost',
'EMAIL' => [
- 'username@localhost.com',
+ 'username@localhost',
],
],
],
false,
- [],
- [],
+ ['results' => [], 'exact' => [], 'exactIdMatch' => false],
true,
],
[
@@ -1111,17 +1097,12 @@ class ShareesAPIControllerTest extends TestCase {
[
'FN' => 'User @ Localhost',
'EMAIL' => [
- 'username@localhost.com',
+ 'username@localhost',
],
],
],
true,
- [
- ['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']],
- ],
- [
- ['label' => 'User @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost.com']],
- ],
+ ['results' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => [['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]], 'exactIdMatch' => false],
true,
],
[
@@ -1138,19 +1119,16 @@ class ShareesAPIControllerTest extends TestCase {
[
'FN' => 'User @ Localhost',
'EMAIL' => [
- 'username@localhost.com',
+ 'username@localhost',
],
],
],
false,
- [
- ['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']],
- ],
- [],
+ ['results' => [], 'exact' => [['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]], 'exactIdMatch' => false],
true,
],
[
- 'username@localhost.com',
+ 'username@localhost',
[
[
'FN' => 'User3 @ Localhost',
@@ -1163,19 +1141,16 @@ class ShareesAPIControllerTest extends TestCase {
[
'FN' => 'User @ Localhost',
'EMAIL' => [
- 'username@localhost.com',
+ 'username@localhost',
],
],
],
true,
- [
- ['label' => 'User @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost.com']],
- ],
- [],
+ ['results' => [], 'exact' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exactIdMatch' => true],
true,
],
[
- 'username@localhost.com',
+ 'username@localhost',
[
[
'FN' => 'User3 @ Localhost',
@@ -1188,20 +1163,40 @@ class ShareesAPIControllerTest extends TestCase {
[
'FN' => 'User @ Localhost',
'EMAIL' => [
- 'username@localhost.com',
+ 'username@localhost',
],
],
],
false,
+ ['results' => [], 'exact' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exactIdMatch' => true],
+ true,
+ ],
+ // contact with space
+ [
+ 'user name@localhost',
[
- ['label' => 'User @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost.com']],
+ [
+ 'FN' => 'User3 @ Localhost',
+ ],
+ [
+ 'FN' => 'User2 @ Localhost',
+ 'EMAIL' => [
+ ],
+ ],
+ [
+ 'FN' => 'User Name @ Localhost',
+ 'EMAIL' => [
+ 'user name@localhost',
+ ],
+ ],
],
- [],
+ false,
+ ['results' => [], 'exact' => [['label' => 'User Name @ Localhost (user name@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'user name@localhost']]], 'exactIdMatch' => true],
true,
],
- // Test single email
+ // remote with space, no contact
[
- 'username@localhost.com',
+ 'user space@remote.com',
[
[
'FN' => 'User3 @ Localhost',
@@ -1213,137 +1208,106 @@ class ShareesAPIControllerTest extends TestCase {
],
[
'FN' => 'User @ Localhost',
- 'EMAIL' => 'username@localhost.com',
+ 'EMAIL' => [
+ 'username@localhost',
+ ],
],
],
false,
- [
- ['label' => 'User @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost.com']],
- ],
- [],
+ ['results' => [], 'exact' => [], 'exactIdMatch' => false],
true,
],
];
}
- /**
- * @dataProvider dataGetEmails
- *
- * @param string $searchTerm
- * @param array $contacts
- * @param bool $shareeEnumeration
- * @param array $exactExpected
- * @param array $expected
- * @param bool $reachedEnd
- */
- public function testGetEmails($searchTerm, $contacts, $shareeEnumeration, $exactExpected, $expected, $reachedEnd) {
- $this->invokePrivate($this->sharees, 'shareeEnumeration', [$shareeEnumeration]);
- $this->contactsManager->expects($this->any())
- ->method('search')
- ->with($searchTerm, ['FN', 'EMAIL'])
- ->willReturn($contacts);
-
- $this->invokePrivate($this->sharees, 'getEmails', [$searchTerm]);
- $result = $this->invokePrivate($this->sharees, 'result');
-
- $this->assertEquals($exactExpected, $result['exact']['emails']);
- $this->assertEquals($expected, $result['emails']);
- $this->assertCount((int) $reachedEnd, $this->invokePrivate($this->sharees, 'reachedEndFor'));
- }
-
public function dataSearch() {
- $allTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_EMAIL, Share::SHARE_TYPE_REMOTE];
+ $allTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE, Share::SHARE_TYPE_EMAIL];
return [
- [[], '', 'yes', true, '', null, $allTypes, 1, 200, false, true, true],
+ [[], '', 'yes', true, true, $allTypes, false, true, true],
// Test itemType
[[
'search' => '',
- ], '', 'yes', true, '', null, $allTypes, 1, 200, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
[[
'search' => 'foobar',
- ], '', 'yes', true, 'foobar', null, $allTypes, 1, 200, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
[[
'search' => 0,
- ], '', 'yes', true, '0', null, $allTypes, 1, 200, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
// Test itemType
[[
'itemType' => '',
- ], '', 'yes', true, '', '', $allTypes, 1, 200, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
[[
'itemType' => 'folder',
- ], '', 'yes', true, '', 'folder', $allTypes, 1, 200, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
[[
'itemType' => 0,
- ], '', 'yes', true, '', '0', $allTypes, 1, 200, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
// Test shareType
[[
- ], '', 'yes', true, '', null, $allTypes, 1, 200, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
[[
'shareType' => 0,
- ], '', 'yes', true, '', null, [0], 1, 200, false, true, true],
+ ], '', 'yes', true, false, [0], false, true, true],
[[
'shareType' => '0',
- ], '', 'yes', true, '', null, [0], 1, 200, false, true, true],
+ ], '', 'yes', true, false, [0], false, true, true],
[[
'shareType' => 1,
- ], '', 'yes', true, '', null, [1], 1, 200, false, true, true],
+ ], '', 'yes', true, false, [1], false, true, true],
[[
'shareType' => 12,
- ], '', 'yes', true, '', null, [], 1, 200, false, true, true],
+ ], '', 'yes', true, false, [], false, true, true],
[[
'shareType' => 'foobar',
- ], '', 'yes', true, '', null, $allTypes, 1, 200, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
[[
'shareType' => [0, 1, 2],
- ], '', 'yes', true, '', null, [0, 1], 1, 200, false, true, true],
+ ], '', 'yes', false, false, [0, 1], false, true, true],
[[
'shareType' => [0, 1],
- ], '', 'yes', true, '', null, [0, 1], 1, 200, false, true, true],
+ ], '', 'yes', false, false, [0, 1], false, true, true],
[[
'shareType' => $allTypes,
- ], '', 'yes', true, '', null, $allTypes, 1, 200, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
[[
'shareType' => $allTypes,
- ], '', 'yes', false, '', null, [0, 1, 4], 1, 200, false, true, true],
+ ], '', 'yes', false, false, [0, 1], false, true, true],
[[
'shareType' => $allTypes,
- ], '', 'yes', true, '', null, [0, 4, 6], 1, 200, false, true, false],
+ ], '', 'yes', true, false, [0, 6], false, true, false],
[[
'shareType' => $allTypes,
- ], '', 'yes', false, '', null, [0, 4], 1, 200, false, true, false],
+ ], '', 'yes', false, true, [0, 4], false, true, false],
// Test pagination
[[
'page' => 1,
- ], '', 'yes', true, '', null, $allTypes, 1, 200, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
[[
'page' => 10,
- ], '', 'yes', true, '', null, $allTypes, 10, 200, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
// Test perPage
[[
'perPage' => 1,
- ], '', 'yes', true, '', null, $allTypes, 1, 1, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
[[
'perPage' => 10,
- ], '', 'yes', true, '', null, $allTypes, 1, 10, false, true, true],
+ ], '', 'yes', true, true, $allTypes, false, true, true],
// Test $shareWithGroupOnly setting
- [[], 'no', 'yes', true, '', null, $allTypes, 1, 200, false, true, true],
- [[], 'yes', 'yes', true, '', null, $allTypes, 1, 200, true, true, true],
+ [[], 'no', 'yes', true, true, $allTypes, false, true, true],
+ [[], 'yes', 'yes', true, true, $allTypes, true, true, true],
// Test $shareeEnumeration setting
- [[], 'no', 'yes', true, '', null, $allTypes, 1, 200, false, true, true],
- [[], 'no', 'no', true, '', null, $allTypes, 1, 200, false, false, true],
-
- // Test keep case for search
- [[
- 'search' => 'foo@example.com/ownCloud',
- ], '', 'yes', true, 'foo@example.com/ownCloud', null, $allTypes, 1, 200, false, true, true],
+ [[], 'no', 'yes', true, true, $allTypes, false, true, true],
+ [[], 'no', 'no', true, true, $allTypes, false, false, true],
];
}
@@ -1354,16 +1318,12 @@ class ShareesAPIControllerTest extends TestCase {
* @param string $apiSetting
* @param string $enumSetting
* @param bool $remoteSharingEnabled
- * @param string $search
- * @param string $itemType
* @param array $shareTypes
- * @param int $page
- * @param int $perPage
* @param bool $shareWithGroupOnly
* @param bool $shareeEnumeration
* @param bool $allowGroupSharing
*/
- public function testSearch($getData, $apiSetting, $enumSetting, $remoteSharingEnabled, $search, $itemType, $shareTypes, $page, $perPage, $shareWithGroupOnly, $shareeEnumeration, $allowGroupSharing) {
+ public function testSearch($getData, $apiSetting, $enumSetting, $remoteSharingEnabled, $emailSharingEnabled, $shareTypes, $shareWithGroupOnly, $shareeEnumeration, $allowGroupSharing) {
$search = isset($getData['search']) ? $getData['search'] : '';
$itemType = isset($getData['itemType']) ? $getData['itemType'] : null;
$page = isset($getData['page']) ? $getData['page'] : 1;
@@ -1399,11 +1359,10 @@ class ShareesAPIControllerTest extends TestCase {
$this->getMockBuilder('OCP\ILogger')->disableOriginalConstructor()->getMock(),
$this->shareManager
])
- ->setMethods(array('searchSharees', 'isRemoteSharingAllowed'))
+ ->setMethods(array('searchSharees', 'isRemoteSharingAllowed', 'shareProviderExists'))
->getMock();
$sharees->expects($this->once())
->method('searchSharees')
- ->with($search, $itemType, $shareTypes, $page, $perPage)
->willReturnCallback(function
($isearch, $iitemType, $ishareTypes, $ipage, $iperPage)
use ($search, $itemType, $shareTypes, $page, $perPage) {
@@ -1411,7 +1370,10 @@ class ShareesAPIControllerTest extends TestCase {
// We are doing strict comparisons here, so we can differ 0/'' and null on shareType/itemType
$this->assertSame($search, $isearch);
$this->assertSame($itemType, $iitemType);
- $this->assertSame($shareTypes, $ishareTypes);
+ $this->assertSame(count($shareTypes), count($ishareTypes));
+ foreach($shareTypes as $expected) {
+ $this->assertTrue(in_array($expected, $ishareTypes));
+ }
$this->assertSame($page, $ipage);
$this->assertSame($perPage, $iperPage);
return new Http\DataResponse();
@@ -1421,6 +1383,11 @@ class ShareesAPIControllerTest extends TestCase {
->with($itemType)
->willReturn($remoteSharingEnabled);
+ $this->shareManager->expects($this->any())
+ ->method('shareProviderExists')
+ ->with(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->willReturn($emailSharingEnabled);
+
$this->assertInstanceOf(Http\DataResponse::class, $sharees->search($search, $itemType, $page, $perPage, $shareType));
$this->assertSame($shareWithGroupOnly, $this->invokePrivate($sharees, 'shareWithGroupOnly'));
@@ -1519,7 +1486,7 @@ class ShareesAPIControllerTest extends TestCase {
public function dataSearchSharees() {
return [
- ['test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, false, [], [], [],
+ ['test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, false, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
[
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'emails' => []],
'users' => [],
@@ -1527,7 +1494,7 @@ class ShareesAPIControllerTest extends TestCase {
'remotes' => [],
'emails' => [],
], false],
- ['test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, false, [], [], [],
+ ['test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, false, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
[
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'emails' => []],
'users' => [],
@@ -1541,7 +1508,7 @@ class ShareesAPIControllerTest extends TestCase {
], [
['label' => 'testgroup1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'testgroup1']],
], [
- ['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']],
+ 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false,
],
[
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'emails' => []],
@@ -1562,7 +1529,7 @@ class ShareesAPIControllerTest extends TestCase {
'test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_REMOTE], 1, 2, false, [
['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
], null, [
- ['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']],
+ 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false
],
[
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'emails' => []],
@@ -1660,14 +1627,11 @@ class ShareesAPIControllerTest extends TestCase {
$result['groups'] = $mockedGroupsResult;
$this->invokePrivate($sharees, 'result', [$result]);
});
+
$sharees->expects(($mockedRemotesResult === null) ? $this->never() : $this->once())
->method('getRemote')
->with($searchTerm)
- ->willReturnCallback(function() use ($sharees, $mockedRemotesResult) {
- $result = $this->invokePrivate($sharees, 'result');
- $result['remotes'] = $mockedRemotesResult;
- $this->invokePrivate($sharees, 'result', [$result]);
- });
+ ->willReturn($mockedRemotesResult);
$ocs = $this->invokePrivate($sharees, 'searchSharees', [$searchTerm, $itemType, $shareTypes, $page, $perPage, $shareWithGroupOnly]);
$this->assertInstanceOf('\OCP\AppFramework\Http\DataResponse', $ocs);