aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/api/sharees.php20
-rw-r--r--apps/files_sharing/css/sharetabview.css6
-rw-r--r--apps/files_sharing/js/public.js24
-rw-r--r--apps/files_sharing/lib/activity.php8
-rw-r--r--apps/files_sharing/lib/capabilities.php42
-rw-r--r--apps/files_sharing/lib/mountprovider.php3
-rw-r--r--apps/files_sharing/lib/sharedstorage.php21
-rw-r--r--apps/files_sharing/tests/api/shareestest.php438
-rw-r--r--apps/files_sharing/tests/capabilities.php37
9 files changed, 519 insertions, 80 deletions
diff --git a/apps/files_sharing/api/sharees.php b/apps/files_sharing/api/sharees.php
index 9e324078dad..734c267020f 100644
--- a/apps/files_sharing/api/sharees.php
+++ b/apps/files_sharing/api/sharees.php
@@ -62,6 +62,9 @@ class Sharees {
/** @var bool */
protected $shareWithGroupOnly = false;
+ /** @var bool */
+ protected $shareeEnumeration = true;
+
/** @var int */
protected $offset = 0;
@@ -134,7 +137,7 @@ class Sharees {
}
}
- if (sizeof($users) < $this->limit) {
+ if (!$this->shareeEnumeration || sizeof($users) < $this->limit) {
$this->reachedEndFor[] = 'users';
}
@@ -176,6 +179,10 @@ class Sharees {
]);
}
}
+
+ if (!$this->shareeEnumeration) {
+ $this->result['users'] = [];
+ }
}
/**
@@ -187,7 +194,7 @@ class Sharees {
$groups = $this->groupManager->search($search, $this->limit, $this->offset);
$groups = array_map(function (IGroup $group) { return $group->getGID(); }, $groups);
- if (sizeof($groups) < $this->limit) {
+ if (!$this->shareeEnumeration || sizeof($groups) < $this->limit) {
$this->reachedEndFor[] = 'groups';
}
@@ -233,6 +240,10 @@ class Sharees {
]);
}
}
+
+ if (!$this->shareeEnumeration) {
+ $this->result['groups'] = [];
+ }
}
/**
@@ -273,6 +284,10 @@ class Sharees {
}
}
+ if (!$this->shareeEnumeration) {
+ $this->result['remotes'] = [];
+ }
+
if (!$foundRemoteById && substr_count($search, '@') >= 1 && substr_count($search, ' ') === 0 && $this->offset === 0) {
$this->result['exact']['remotes'][] = [
'label' => $search,
@@ -322,6 +337,7 @@ class Sharees {
}
$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;
$this->offset = $perPage * ($page - 1);
diff --git a/apps/files_sharing/css/sharetabview.css b/apps/files_sharing/css/sharetabview.css
index fe7a1947502..1745eba5846 100644
--- a/apps/files_sharing/css/sharetabview.css
+++ b/apps/files_sharing/css/sharetabview.css
@@ -73,5 +73,9 @@
}
.shareTabView .icon-loading-small {
- margin-left: -30px;
+ position: absolute;
+ display: inline-block;
+ z-index: 1;
+ background-color: white;
+ padding: 2px;
}
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index 1993efe7d73..4908968a937 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -159,9 +159,18 @@ OCA.Sharing.PublicApp = {
};
this.fileList.generatePreviewUrl = function (urlSpec) {
+ urlSpec = urlSpec || {};
+ if (!urlSpec.x) {
+ urlSpec.x = 36;
+ }
+ if (!urlSpec.y) {
+ urlSpec.y = 36;
+ }
+ urlSpec.x *= window.devicePixelRatio;
+ urlSpec.y *= window.devicePixelRatio;
+ urlSpec.x = Math.floor(urlSpec.x);
+ urlSpec.y = Math.floor(urlSpec.y);
urlSpec.t = $('#dirToken').val();
- urlSpec.y = Math.floor(36 * window.devicePixelRatio);
- urlSpec.x = Math.floor(36 * window.devicePixelRatio);
return OC.generateUrl('/apps/files_sharing/ajax/publicpreview.php?') + $.param(urlSpec);
};
@@ -293,15 +302,8 @@ $(document).ready(function () {
if (window.Files) {
// HACK: for oc-dialogs previews that depends on Files:
- Files.lazyLoadPreview = function (path, mime, ready, width, height, etag) {
- return App.fileList.lazyLoadPreview({
- path: path,
- mime: mime,
- callback: ready,
- width: width,
- height: height,
- etag: etag
- });
+ Files.generatePreviewUrl = function (urlSpec) {
+ return App.fileList.generatePreviewUrl(urlSpec);
};
}
});
diff --git a/apps/files_sharing/lib/activity.php b/apps/files_sharing/lib/activity.php
index 1257e7a445c..63ac2e90b2a 100644
--- a/apps/files_sharing/lib/activity.php
+++ b/apps/files_sharing/lib/activity.php
@@ -58,6 +58,7 @@ class Activity implements IExtension {
const SUBJECT_RESHARED_GROUP_BY = 'reshared_group_by';
const SUBJECT_RESHARED_LINK_BY = 'reshared_link_by';
const SUBJECT_RESHARED_USER_BY = 'reshared_user_by';
+ const SUBJECT_SHARED_EMAIL = 'shared_with_email';
const SUBJECT_SHARED_WITH_BY = 'shared_with_by';
/** @var IFactory */
@@ -182,6 +183,8 @@ class Activity implements IExtension {
return (string) $l->t('%2$s shared %1$s with you', $params);
case self::SUBJECT_SHARED_LINK_SELF:
return (string) $l->t('You shared %1$s via link', $params);
+ case self::SUBJECT_SHARED_EMAIL:
+ return (string) $l->t('You shared %1$s with %2$s', $params);
}
}
@@ -227,6 +230,11 @@ class Activity implements IExtension {
1 => 'username',
2 => '',
];
+ case self::SUBJECT_SHARED_EMAIL:
+ return array(
+ 0 => 'file',
+ 1 => '',// 'email' is neither supported nor planned for now
+ );
case self::SUBJECT_SHARED_USER_SELF:
case self::SUBJECT_SHARED_WITH_BY:
diff --git a/apps/files_sharing/lib/capabilities.php b/apps/files_sharing/lib/capabilities.php
index b24eb8d61f0..c8ba1273281 100644
--- a/apps/files_sharing/lib/capabilities.php
+++ b/apps/files_sharing/lib/capabilities.php
@@ -45,28 +45,36 @@ class Capabilities implements ICapability {
public function getCapabilities() {
$res = [];
- $public = [];
- $public['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes';
- if ($public['enabled']) {
- $public['password'] = [];
- $public['password']['enforced'] = ($this->config->getAppValue('core', 'shareapi_enforce_links_password', 'no') === 'yes');
+ if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
+ $res['api_enabled'] = false;
+ $res['public'] = ['enabled' => false];
+ $res['user'] = ['send_mail' => false];
+ $res['resharing'] = false;
+ } else {
+ $res['api_enabled'] = true;
- $public['expire_date'] = [];
- $public['expire_date']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes';
- if ($public['expire_date']['enabled']) {
- $public['expire_date']['days'] = $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
- $public['expire_date']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes';
- }
+ $public = [];
+ $public['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes';
+ if ($public['enabled']) {
+ $public['password'] = [];
+ $public['password']['enforced'] = ($this->config->getAppValue('core', 'shareapi_enforce_links_password', 'no') === 'yes');
- $public['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no') === 'yes';
- $public['upload'] = $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === 'yes';
- }
- $res["public"] = $public;
+ $public['expire_date'] = [];
+ $public['expire_date']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes';
+ if ($public['expire_date']['enabled']) {
+ $public['expire_date']['days'] = $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
+ $public['expire_date']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes';
+ }
- $res['user']['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'no') === 'yes';
+ $public['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no') === 'yes';
+ $public['upload'] = $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === 'yes';
+ }
+ $res["public"] = $public;
- $res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes';
+ $res['user']['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'no') === 'yes';
+ $res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes';
+ }
//Federated sharing
$res['federation'] = [
diff --git a/apps/files_sharing/lib/mountprovider.php b/apps/files_sharing/lib/mountprovider.php
index 14a79625993..458e7f2619b 100644
--- a/apps/files_sharing/lib/mountprovider.php
+++ b/apps/files_sharing/lib/mountprovider.php
@@ -69,12 +69,11 @@ class MountProvider implements IMountProvider {
// for updating etags for the share owner when we make changes to this share.
$ownerPropagator = $this->propagationManager->getChangePropagator($share['uid_owner']);
- // for updating our etags when changes are made to the share from the owners side (probably indirectly by us trough another share)
- $this->propagationManager->listenToOwnerChanges($share['uid_owner'], $user->getUID());
return new SharedMount(
'\OC\Files\Storage\Shared',
'/' . $user->getUID() . '/' . $share['file_target'],
array(
+ 'propagationManager' => $this->propagationManager,
'propagator' => $ownerPropagator,
'share' => $share,
'user' => $user->getUID()
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 1ac401f3cf8..27dd2f1e485 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -50,13 +50,34 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
*/
private $ownerView;
+ /**
+ * @var \OCA\Files_Sharing\Propagation\PropagationManager
+ */
+ private $propagationManager;
+
+ /**
+ * @var string
+ */
+ private $user;
+
+ private $initialized = false;
+
public function __construct($arguments) {
$this->share = $arguments['share'];
$this->ownerView = $arguments['ownerView'];
+ $this->propagationManager = $arguments['propagationManager'];
+ $this->user = $arguments['user'];
}
private function init() {
+ if ($this->initialized) {
+ return;
+ }
+ $this->initialized = true;
Filesystem::initMountPoints($this->share['uid_owner']);
+
+ // for updating our etags when changes are made to the share from the owners side (probably indirectly by us trough another share)
+ $this->propagationManager->listenToOwnerChanges($this->share['uid_owner'], $this->user);
}
/**
diff --git a/apps/files_sharing/tests/api/shareestest.php b/apps/files_sharing/tests/api/shareestest.php
index 5c5d5b0d309..91b8b1c7e66 100644
--- a/apps/files_sharing/tests/api/shareestest.php
+++ b/apps/files_sharing/tests/api/shareestest.php
@@ -110,16 +110,30 @@ class ShareesTest extends TestCase {
public function dataGetUsers() {
return [
- ['test', false, [], [], [], [], true, false],
- ['test', true, [], [], [], [], true, false],
+ ['test', false, true, [], [], [], [], true, false],
+ ['test', false, false, [], [], [], [], true, false],
+ ['test', true, true, [], [], [], [], true, false],
+ ['test', true, false, [], [], [], [], true, false],
[
- 'test', false, [], [],
+ 'test', false, true, [], [],
[
['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
], [], true, $this->getUserMock('test', 'Test')
],
[
- 'test', true, [], [],
+ 'test', false, false, [], [],
+ [
+ ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ], [], true, $this->getUserMock('test', 'Test')
+ ],
+ [
+ 'test', true, true, [], [],
+ [
+ ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ], [], true, $this->getUserMock('test', 'Test')
+ ],
+ [
+ 'test', true, false, [], [],
[
['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
], [], true, $this->getUserMock('test', 'Test')
@@ -127,6 +141,7 @@ class ShareesTest extends TestCase {
[
'test',
false,
+ true,
[],
[
$this->getUserMock('test1', 'Test One'),
@@ -141,6 +156,20 @@ class ShareesTest extends TestCase {
[
'test',
false,
+ false,
+ [],
+ [
+ $this->getUserMock('test1', 'Test One'),
+ ],
+ [],
+ [],
+ true,
+ false,
+ ],
+ [
+ 'test',
+ false,
+ true,
[],
[
$this->getUserMock('test1', 'Test One'),
@@ -157,6 +186,21 @@ class ShareesTest extends TestCase {
[
'test',
false,
+ false,
+ [],
+ [
+ $this->getUserMock('test1', 'Test One'),
+ $this->getUserMock('test2', 'Test Two'),
+ ],
+ [],
+ [],
+ true,
+ false,
+ ],
+ [
+ 'test',
+ false,
+ true,
[],
[
$this->getUserMock('test0', 'Test'),
@@ -175,6 +219,24 @@ class ShareesTest extends TestCase {
],
[
'test',
+ false,
+ false,
+ [],
+ [
+ $this->getUserMock('test0', 'Test'),
+ $this->getUserMock('test1', 'Test One'),
+ $this->getUserMock('test2', 'Test Two'),
+ ],
+ [
+ ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test0']],
+ ],
+ [],
+ true,
+ false,
+ ],
+ [
+ 'test',
+ true,
true,
['abc', 'xyz'],
[
@@ -191,6 +253,21 @@ class ShareesTest extends TestCase {
[
'test',
true,
+ false,
+ ['abc', 'xyz'],
+ [
+ ['abc', 'test', 2, 0, ['test1' => 'Test One']],
+ ['xyz', 'test', 2, 0, []],
+ ],
+ [],
+ [],
+ true,
+ false,
+ ],
+ [
+ 'test',
+ true,
+ true,
['abc', 'xyz'],
[
['abc', 'test', 2, 0, [
@@ -213,6 +290,27 @@ class ShareesTest extends TestCase {
[
'test',
true,
+ false,
+ ['abc', 'xyz'],
+ [
+ ['abc', 'test', 2, 0, [
+ 'test1' => 'Test One',
+ 'test2' => 'Test Two',
+ ]],
+ ['xyz', 'test', 2, 0, [
+ 'test1' => 'Test One',
+ 'test2' => 'Test Two',
+ ]],
+ ],
+ [],
+ [],
+ true,
+ false,
+ ],
+ [
+ 'test',
+ true,
+ true,
['abc', 'xyz'],
[
['abc', 'test', 2, 0, [
@@ -231,6 +329,26 @@ class ShareesTest extends TestCase {
false,
false,
],
+ [
+ 'test',
+ true,
+ false,
+ ['abc', 'xyz'],
+ [
+ ['abc', 'test', 2, 0, [
+ 'test' => 'Test One',
+ ]],
+ ['xyz', 'test', 2, 0, [
+ 'test2' => 'Test Two',
+ ]],
+ ],
+ [
+ ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ],
+ [],
+ true,
+ false,
+ ],
];
}
@@ -239,6 +357,7 @@ class ShareesTest extends TestCase {
*
* @param string $searchTerm
* @param bool $shareWithGroupOnly
+ * @param bool $shareeEnumeration
* @param array $groupResponse
* @param array $userResponse
* @param array $exactExpected
@@ -246,10 +365,11 @@ class ShareesTest extends TestCase {
* @param bool $reachedEnd
* @param mixed $singleUser
*/
- public function testGetUsers($searchTerm, $shareWithGroupOnly, $groupResponse, $userResponse, $exactExpected, $expected, $reachedEnd, $singleUser) {
+ public function testGetUsers($searchTerm, $shareWithGroupOnly, $shareeEnumeration, $groupResponse, $userResponse, $exactExpected, $expected, $reachedEnd, $singleUser) {
$this->invokePrivate($this->sharees, 'limit', [2]);
$this->invokePrivate($this->sharees, 'offset', [0]);
$this->invokePrivate($this->sharees, 'shareWithGroupOnly', [$shareWithGroupOnly]);
+ $this->invokePrivate($this->sharees, 'shareeEnumeration', [$shareeEnumeration]);
$user = $this->getUserMock('admin', 'Administrator');
$this->session->expects($this->any())
@@ -290,9 +410,10 @@ class ShareesTest extends TestCase {
public function dataGetGroups() {
return [
- ['test', false, [], [], [], [], true, false],
+ ['test', false, true, [], [], [], [], true, false],
+ ['test', false, false, [], [], [], [], true, false],
[
- 'test', false,
+ 'test', false, true,
[$this->getGroupMock('test1')],
[],
[],
@@ -301,7 +422,16 @@ class ShareesTest extends TestCase {
false,
],
[
- 'test', false,
+ 'test', false, false,
+ [$this->getGroupMock('test1')],
+ [],
+ [],
+ [],
+ true,
+ false,
+ ],
+ [
+ 'test', false, true,
[
$this->getGroupMock('test'),
$this->getGroupMock('test1'),
@@ -313,7 +443,19 @@ class ShareesTest extends TestCase {
false,
],
[
- 'test', false,
+ 'test', false, false,
+ [
+ $this->getGroupMock('test'),
+ $this->getGroupMock('test1'),
+ ],
+ [],
+ [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
+ [],
+ true,
+ false,
+ ],
+ [
+ 'test', false, true,
[
$this->getGroupMock('test0'),
$this->getGroupMock('test1'),
@@ -328,7 +470,19 @@ class ShareesTest extends TestCase {
null,
],
[
- 'test', false,
+ 'test', false, false,
+ [
+ $this->getGroupMock('test0'),
+ $this->getGroupMock('test1'),
+ ],
+ [],
+ [],
+ [],
+ true,
+ null,
+ ],
+ [
+ 'test', false, true,
[
$this->getGroupMock('test0'),
$this->getGroupMock('test1'),
@@ -344,9 +498,24 @@ class ShareesTest extends TestCase {
false,
$this->getGroupMock('test'),
],
- ['test', true, [], [], [], [], true, false],
[
- 'test', true,
+ 'test', false, false,
+ [
+ $this->getGroupMock('test0'),
+ $this->getGroupMock('test1'),
+ ],
+ [],
+ [
+ ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']],
+ ],
+ [],
+ true,
+ $this->getGroupMock('test'),
+ ],
+ ['test', true, true, [], [], [], [], true, false],
+ ['test', true, false, [], [], [], [], true, false],
+ [
+ 'test', true, true,
[
$this->getGroupMock('test1'),
$this->getGroupMock('test2'),
@@ -358,7 +527,19 @@ class ShareesTest extends TestCase {
false,
],
[
- 'test', true,
+ 'test', true, false,
+ [
+ $this->getGroupMock('test1'),
+ $this->getGroupMock('test2'),
+ ],
+ [$this->getGroupMock('test1')],
+ [],
+ [],
+ true,
+ false,
+ ],
+ [
+ 'test', true, true,
[
$this->getGroupMock('test'),
$this->getGroupMock('test1'),
@@ -370,7 +551,19 @@ class ShareesTest extends TestCase {
false,
],
[
- 'test', true,
+ 'test', true, false,
+ [
+ $this->getGroupMock('test'),
+ $this->getGroupMock('test1'),
+ ],
+ [$this->getGroupMock('test')],
+ [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
+ [],
+ true,
+ false,
+ ],
+ [
+ 'test', true, true,
[
$this->getGroupMock('test'),
$this->getGroupMock('test1'),
@@ -382,7 +575,19 @@ class ShareesTest extends TestCase {
false,
],
[
- 'test', true,
+ 'test', true, false,
+ [
+ $this->getGroupMock('test'),
+ $this->getGroupMock('test1'),
+ ],
+ [$this->getGroupMock('test1')],
+ [],
+ [],
+ true,
+ false,
+ ],
+ [
+ 'test', true, true,
[
$this->getGroupMock('test'),
$this->getGroupMock('test1'),
@@ -394,7 +599,19 @@ class ShareesTest extends TestCase {
false,
],
[
- 'test', true,
+ 'test', true, false,
+ [
+ $this->getGroupMock('test'),
+ $this->getGroupMock('test1'),
+ ],
+ [$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
+ [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
+ [],
+ true,
+ false,
+ ],
+ [
+ 'test', true, true,
[
$this->getGroupMock('test0'),
$this->getGroupMock('test1'),
@@ -409,7 +626,19 @@ class ShareesTest extends TestCase {
null,
],
[
- 'test', true,
+ 'test', true, false,
+ [
+ $this->getGroupMock('test0'),
+ $this->getGroupMock('test1'),
+ ],
+ [$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
+ [],
+ [],
+ true,
+ null,
+ ],
+ [
+ 'test', true, true,
[
$this->getGroupMock('test0'),
$this->getGroupMock('test1'),
@@ -425,6 +654,20 @@ class ShareesTest extends TestCase {
false,
$this->getGroupMock('test'),
],
+ [
+ 'test', true, false,
+ [
+ $this->getGroupMock('test0'),
+ $this->getGroupMock('test1'),
+ ],
+ [$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
+ [
+ ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']],
+ ],
+ [],
+ true,
+ $this->getGroupMock('test'),
+ ],
];
}
@@ -433,6 +676,7 @@ class ShareesTest extends TestCase {
*
* @param string $searchTerm
* @param bool $shareWithGroupOnly
+ * @param bool $shareeEnumeration
* @param array $groupResponse
* @param array $userGroupsResponse
* @param array $exactExpected
@@ -440,10 +684,11 @@ class ShareesTest extends TestCase {
* @param bool $reachedEnd
* @param mixed $singleGroup
*/
- public function testGetGroups($searchTerm, $shareWithGroupOnly, $groupResponse, $userGroupsResponse, $exactExpected, $expected, $reachedEnd, $singleGroup) {
+ public function testGetGroups($searchTerm, $shareWithGroupOnly, $shareeEnumeration, $groupResponse, $userGroupsResponse, $exactExpected, $expected, $reachedEnd, $singleGroup) {
$this->invokePrivate($this->sharees, 'limit', [2]);
$this->invokePrivate($this->sharees, 'offset', [0]);
$this->invokePrivate($this->sharees, 'shareWithGroupOnly', [$shareWithGroupOnly]);
+ $this->invokePrivate($this->sharees, 'shareeEnumeration', [$shareeEnumeration]);
$this->groupManager->expects($this->once())
->method('search')
@@ -480,10 +725,22 @@ class ShareesTest extends TestCase {
public function dataGetRemote() {
return [
- ['test', [], [], [], true],
+ ['test', [], true, [], [], true],
+ ['test', [], false, [], [], true],
+ [
+ 'test@remote',
+ [],
+ true,
+ [
+ ['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']],
+ ],
+ [],
+ true,
+ ],
[
'test@remote',
[],
+ false,
[
['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']],
],
@@ -508,6 +765,7 @@ class ShareesTest extends TestCase {
],
],
],
+ true,
[],
[
['label' => 'User @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost']],
@@ -515,6 +773,29 @@ class ShareesTest extends TestCase {
true,
],
[
+ 'test',
+ [
+ [
+ 'FN' => 'User3 @ Localhost',
+ ],
+ [
+ 'FN' => 'User2 @ Localhost',
+ 'CLOUD' => [
+ ],
+ ],
+ [
+ 'FN' => 'User @ Localhost',
+ 'CLOUD' => [
+ 'username@localhost',
+ ],
+ ],
+ ],
+ false,
+ [],
+ [],
+ true,
+ ],
+ [
'test@remote',
[
[
@@ -532,6 +813,7 @@ class ShareesTest extends TestCase {
],
],
],
+ true,
[
['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']],
],
@@ -541,6 +823,31 @@ class ShareesTest extends TestCase {
true,
],
[
+ 'test@remote',
+ [
+ [
+ 'FN' => 'User3 @ Localhost',
+ ],
+ [
+ 'FN' => 'User2 @ Localhost',
+ 'CLOUD' => [
+ ],
+ ],
+ [
+ 'FN' => 'User @ Localhost',
+ 'CLOUD' => [
+ 'username@localhost',
+ ],
+ ],
+ ],
+ false,
+ [
+ ['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']],
+ ],
+ [],
+ true,
+ ],
+ [
'username@localhost',
[
[
@@ -558,11 +865,36 @@ class ShareesTest extends TestCase {
],
],
],
+ true,
[
['label' => 'User @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost']],
],
+ [],
+ true,
+ ],
+ [
+ 'username@localhost',
[
+ [
+ 'FN' => 'User3 @ Localhost',
+ ],
+ [
+ 'FN' => 'User2 @ Localhost',
+ 'CLOUD' => [
+ ],
+ ],
+ [
+ 'FN' => 'User @ Localhost',
+ 'CLOUD' => [
+ 'username@localhost',
+ ],
+ ],
],
+ false,
+ [
+ ['label' => 'User @ Localhost', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost']],
+ ],
+ [],
true,
],
];
@@ -573,11 +905,13 @@ class ShareesTest extends TestCase {
*
* @param string $searchTerm
* @param array $contacts
+ * @param bool $shareeEnumeration
* @param array $exactExpected
* @param array $expected
* @param bool $reachedEnd
*/
- public function testGetRemote($searchTerm, $contacts, $exactExpected, $expected, $reachedEnd) {
+ public function testGetRemote($searchTerm, $contacts, $shareeEnumeration, $exactExpected, $expected, $reachedEnd) {
+ $this->invokePrivate($this->sharees, 'shareeEnumeration', [$shareeEnumeration]);
$this->contactsManager->expects($this->any())
->method('search')
->with($searchTerm, ['CLOUD', 'FN'])
@@ -595,80 +929,84 @@ class ShareesTest extends TestCase {
$allTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE];
return [
- [[], '', true, '', null, $allTypes, 1, 200, false],
+ [[], '', 'yes', true, '', null, $allTypes, 1, 200, false, true],
// Test itemType
[[
'search' => '',
- ], '', true, '', null, $allTypes, 1, 200, false],
+ ], '', 'yes', true, '', null, $allTypes, 1, 200, false, true],
[[
'search' => 'foobar',
- ], '', true, 'foobar', null, $allTypes, 1, 200, false],
+ ], '', 'yes', true, 'foobar', null, $allTypes, 1, 200, false, true],
[[
'search' => 0,
- ], '', true, '0', null, $allTypes, 1, 200, false],
+ ], '', 'yes', true, '0', null, $allTypes, 1, 200, false, true],
// Test itemType
[[
'itemType' => '',
- ], '', true, '', '', $allTypes, 1, 200, false],
+ ], '', 'yes', true, '', '', $allTypes, 1, 200, false, true],
[[
'itemType' => 'folder',
- ], '', true, '', 'folder', $allTypes, 1, 200, false],
+ ], '', 'yes', true, '', 'folder', $allTypes, 1, 200, false, true],
[[
'itemType' => 0,
- ], '', true, '', '0', $allTypes, 1, 200, false],
+ ], '', 'yes', true, '', '0', $allTypes, 1, 200, false, true],
// Test shareType
[[
- ], '', true, '', null, $allTypes, 1, 200, false],
+ ], '', 'yes', true, '', null, $allTypes, 1, 200, false, true],
[[
'shareType' => 0,
- ], '', true, '', null, [0], 1, 200, false],
+ ], '', 'yes', true, '', null, [0], 1, 200, false, true],
[[
'shareType' => '0',
- ], '', true, '', null, [0], 1, 200, false],
+ ], '', 'yes', true, '', null, [0], 1, 200, false, true],
[[
'shareType' => 1,
- ], '', true, '', null, [1], 1, 200, false],
+ ], '', 'yes', true, '', null, [1], 1, 200, false, true],
[[
'shareType' => 12,
- ], '', true, '', null, [], 1, 200, false],
+ ], '', 'yes', true, '', null, [], 1, 200, false, true],
[[
'shareType' => 'foobar',
- ], '', true, '', null, $allTypes, 1, 200, false],
+ ], '', 'yes', true, '', null, $allTypes, 1, 200, false, true],
[[
'shareType' => [0, 1, 2],
- ], '', true, '', null, [0, 1], 1, 200, false],
+ ], '', 'yes', true, '', null, [0, 1], 1, 200, false, true],
[[
'shareType' => [0, 1],
- ], '', true, '', null, [0, 1], 1, 200, false],
+ ], '', 'yes', true, '', null, [0, 1], 1, 200, false, true],
[[
'shareType' => $allTypes,
- ], '', true, '', null, $allTypes, 1, 200, false],
+ ], '', 'yes', true, '', null, $allTypes, 1, 200, false, true],
[[
'shareType' => $allTypes,
- ], '', false, '', null, [0, 1], 1, 200, false],
+ ], '', 'yes', false, '', null, [0, 1], 1, 200, false, true],
// Test pagination
[[
'page' => 1,
- ], '', true, '', null, $allTypes, 1, 200, false],
+ ], '', 'yes', true, '', null, $allTypes, 1, 200, false, true],
[[
'page' => 10,
- ], '', true, '', null, $allTypes, 10, 200, false],
+ ], '', 'yes', true, '', null, $allTypes, 10, 200, false, true],
// Test perPage
[[
'perPage' => 1,
- ], '', true, '', null, $allTypes, 1, 1, false],
+ ], '', 'yes', true, '', null, $allTypes, 1, 1, false, true],
[[
'perPage' => 10,
- ], '', true, '', null, $allTypes, 1, 10, false],
+ ], '', 'yes', true, '', null, $allTypes, 1, 10, false, true],
// Test $shareWithGroupOnly setting
- [[], 'no', true, '', null, $allTypes, 1, 200, false],
- [[], 'yes', true, '', null, $allTypes, 1, 200, true],
+ [[], 'no', 'yes', true, '', null, $allTypes, 1, 200, false, true],
+ [[], 'yes', 'yes', true, '', null, $allTypes, 1, 200, true, true],
+
+ // Test $shareeEnumeration setting
+ [[], 'no', 'yes', true, '', null, $allTypes, 1, 200, false, true],
+ [[], 'no', 'no', true, '', null, $allTypes, 1, 200, false, false],
];
}
@@ -678,6 +1016,7 @@ class ShareesTest extends TestCase {
*
* @param array $getData
* @param string $apiSetting
+ * @param string $enumSetting
* @param bool $remoteSharingEnabled
* @param string $search
* @param string $itemType
@@ -685,18 +1024,22 @@ class ShareesTest extends TestCase {
* @param int $page
* @param int $perPage
* @param bool $shareWithGroupOnly
+ * @param bool $shareeEnumeration
*/
- public function testSearch($getData, $apiSetting, $remoteSharingEnabled, $search, $itemType, $shareTypes, $page, $perPage, $shareWithGroupOnly) {
+ public function testSearch($getData, $apiSetting, $enumSetting, $remoteSharingEnabled, $search, $itemType, $shareTypes, $page, $perPage, $shareWithGroupOnly, $shareeEnumeration) {
$oldGet = $_GET;
$_GET = $getData;
$config = $this->getMockBuilder('OCP\IConfig')
->disableOriginalConstructor()
->getMock();
- $config->expects($this->once())
+ $config->expects($this->exactly(2))
->method('getAppValue')
- ->with('core', 'shareapi_only_share_with_group_members', 'no')
- ->willReturn($apiSetting);
+ ->with('core', $this->anything(), $this->anything())
+ ->willReturnMap([
+ ['core', 'shareapi_only_share_with_group_members', 'no', $apiSetting],
+ ['core', 'shareapi_allow_share_dialog_user_enumeration', 'yes', $enumSetting],
+ ]);
$sharees = $this->getMockBuilder('\OCA\Files_Sharing\API\Sharees')
->setConstructorArgs([
@@ -735,6 +1078,7 @@ class ShareesTest extends TestCase {
$this->assertInstanceOf('\OC_OCS_Result', $sharees->search());
$this->assertSame($shareWithGroupOnly, $this->invokePrivate($sharees, 'shareWithGroupOnly'));
+ $this->assertSame($shareeEnumeration, $this->invokePrivate($sharees, 'shareeEnumeration'));
$_GET = $oldGet;
}
diff --git a/apps/files_sharing/tests/capabilities.php b/apps/files_sharing/tests/capabilities.php
index f1a9626db9b..cff7bdf1fe8 100644
--- a/apps/files_sharing/tests/capabilities.php
+++ b/apps/files_sharing/tests/capabilities.php
@@ -56,8 +56,31 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
return $result;
}
+ public function testEnabledSharingAPI() {
+ $map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
+ ];
+ $result = $this->getResults($map);
+ $this->assertTrue($result['api_enabled']);
+ $this->assertContains('public', $result);
+ $this->assertContains('user', $result);
+ $this->assertContains('resharing', $result);
+ }
+
+ public function testDisabledSharingAPI() {
+ $map = [
+ ['core', 'shareapi_enabled', 'yes', 'no'],
+ ];
+ $result = $this->getResults($map);
+ $this->assertFalse($result['api_enabled']);
+ $this->assertNotContains('public', $result);
+ $this->assertNotContains('user', $result);
+ $this->assertNotContains('resharing', $result);
+ }
+
public function testNoLinkSharing() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'no'],
];
$result = $this->getResults($map);
@@ -67,6 +90,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testOnlyLinkSharing() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
];
$result = $this->getResults($map);
@@ -76,6 +100,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testLinkPassword() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
['core', 'shareapi_enforce_links_password', 'no', 'yes'],
];
@@ -87,6 +112,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testLinkNoPassword() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
['core', 'shareapi_enforce_links_password', 'no', 'no'],
];
@@ -98,6 +124,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testLinkNoExpireDate() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
['core', 'shareapi_default_expire_date', 'no', 'no'],
];
@@ -109,6 +136,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testLinkExpireDate() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
['core', 'shareapi_default_expire_date', 'no', 'yes'],
['core', 'shareapi_expire_after_n_days', '7', '7'],
@@ -124,6 +152,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testLinkExpireDateEnforced() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
['core', 'shareapi_default_expire_date', 'no', 'yes'],
['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
@@ -136,6 +165,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testLinkSendMail() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
['core', 'shareapi_allow_public_notification', 'no', 'yes'],
];
@@ -145,6 +175,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testLinkNoSendMail() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
['core', 'shareapi_allow_public_notification', 'no', 'no'],
];
@@ -154,6 +185,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testUserSendMail() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_mail_notification', 'no', 'yes'],
];
$result = $this->getResults($map);
@@ -162,6 +194,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testUserNoSendMail() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_mail_notification', 'no', 'no'],
];
$result = $this->getResults($map);
@@ -170,6 +203,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testResharing() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_resharing', 'yes', 'yes'],
];
$result = $this->getResults($map);
@@ -178,6 +212,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testNoResharing() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_resharing', 'yes', 'no'],
];
$result = $this->getResults($map);
@@ -186,6 +221,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testLinkPublicUpload() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
['core', 'shareapi_allow_public_upload', 'yes', 'yes'],
];
@@ -195,6 +231,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
public function testLinkNoPublicUpload() {
$map = [
+ ['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
['core', 'shareapi_allow_public_upload', 'yes', 'no'],
];