summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php19
-rw-r--r--apps/files_sharing/lib/Controller/ShareesAPIController.php8
-rw-r--r--apps/files_sharing/tests/ApiTest.php10
-rw-r--r--apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php308
-rw-r--r--build/integration/features/provisioning-v1.feature3
5 files changed, 161 insertions, 187 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index ae8165602a6..4f80b8fc966 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -502,7 +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));
- $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_EMAIL, $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));
}
@@ -822,15 +824,18 @@ class ShareAPIController extends OCSController {
}
try {
- $share = $this->shareManager->getShareById('ocMailShare:' . $id);
- return $share;
- } catch (ShareNotFound $e) {
- if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
- throw new ShareNotFound();
+ 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 06878f04c35..8a9a59d8845 100644
--- a/apps/files_sharing/lib/Controller/ShareesAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php
@@ -427,8 +427,8 @@ class ShareesAPIController extends OCSController {
$shareTypes = [
Share::SHARE_TYPE_USER,
- Share::SHARE_TYPE_EMAIL,
- Share::SHARE_TYPE_REMOTE
+ Share::SHARE_TYPE_REMOTE,
+ Share::SHARE_TYPE_EMAIL
];
if ($this->shareManager->allowGroupSharing()) {
@@ -504,12 +504,12 @@ class ShareesAPIController extends OCSController {
}
// Get remote
- $remoteResults = ['results' => [], 'exact' => []];
+ $remoteResults = ['results' => [], 'exact' => [], 'exactIdMatch' => false];
if (in_array(Share::SHARE_TYPE_REMOTE, $shareTypes)) {
$remoteResults = $this->getRemote($search);
}
- $mailResults = ['results' => [], 'exact' => []];
+ $mailResults = ['results' => [], 'exact' => [], 'exactIdMatch' => false];
if (in_array(Share::SHARE_TYPE_EMAIL, $shareTypes)) {
$mailResults = $this->getEmail($search);
}
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/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);
diff --git a/build/integration/features/provisioning-v1.feature b/build/integration/features/provisioning-v1.feature
index 98bf321dc64..9103a71ab92 100644
--- a/build/integration/features/provisioning-v1.feature
+++ b/build/integration/features/provisioning-v1.feature
@@ -255,7 +255,7 @@ Feature: provisioning
Scenario: Delete a user
Given As an "admin"
And user "brand-new-user" exists
- When sending "DELETE" to "/cloud/users/brand-new-user"
+ When sending "DELETE" to "/cloud/users/brand-new-user"
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "brand-new-user" does not exist
@@ -291,6 +291,7 @@ Feature: provisioning
| files_trashbin |
| files_versions |
| provisioning_api |
+ | sharebymail |
| systemtags |
| theming |
| twofactor_backupcodes |