Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-03-17 11:02:37 +0300
committerJoas Schilling <coding@schilljs.com>2021-03-17 11:51:31 +0300
commit9a189bc710a971bea5edb4807914a3978356e66b (patch)
treec9451bc47f58b1eb61459b1d7a7b6006ec65d095 /tests/lib/Collaboration
parentf82edda9c190462132f5042a177e7fa413291330 (diff)
Improve search results when only phonebook-matches can we autocompleted
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/Collaboration')
-rw-r--r--tests/lib/Collaboration/Collaborators/UserPluginTest.php55
1 files changed, 47 insertions, 8 deletions
diff --git a/tests/lib/Collaboration/Collaborators/UserPluginTest.php b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
index f2e0e7e274b..43bbffc9b6a 100644
--- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
@@ -104,17 +104,19 @@ class UserPluginTest extends TestCase {
);
}
- public function mockConfig($shareWithGroupOnly, $shareeEnumeration, $shareeEnumerationLimitToGroup) {
+ public function mockConfig($shareWithGroupOnly, $shareeEnumeration, $shareeEnumerationLimitToGroup, $shareeEnumerationPhone = false) {
$this->config->expects($this->any())
->method('getAppValue')
->willReturnCallback(
- function ($appName, $key, $default) use ($shareWithGroupOnly, $shareeEnumeration, $shareeEnumerationLimitToGroup) {
+ function ($appName, $key, $default) use ($shareWithGroupOnly, $shareeEnumeration, $shareeEnumerationLimitToGroup, $shareeEnumerationPhone) {
if ($appName === 'core' && $key === 'shareapi_only_share_with_group_members') {
return $shareWithGroupOnly ? 'yes' : 'no';
} elseif ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') {
return $shareeEnumeration ? 'yes' : 'no';
} elseif ($appName === 'core' && $key === 'shareapi_restrict_user_enumeration_to_group') {
return $shareeEnumerationLimitToGroup ? 'yes' : 'no';
+ } elseif ($appName === 'core' && $key === 'shareapi_restrict_user_enumeration_to_phone') {
+ return $shareeEnumerationPhone ? 'yes' : 'no';
}
return $default;
}
@@ -269,6 +271,28 @@ class UserPluginTest extends TestCase {
[
'test',
false,
+ true,
+ [],
+ [
+ $this->getUserMock('test0', 'Test'),
+ $this->getUserMock('test1', 'Test One'),
+ $this->getUserMock('test2', 'Test Two'),
+ ],
+ [
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test0'], 'icon' => 'icon-user', 'subline' => null, 'status' => [], 'shareWithDisplayNameUnique' => 'test0'],
+ ],
+ [
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1'], 'icon' => 'icon-user', 'subline' => null, 'status' => [], 'shareWithDisplayNameUnique' => 'test1'],
+ ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2'], 'icon' => 'icon-user', 'subline' => null, 'status' => [], 'shareWithDisplayNameUnique' => 'test2'],
+ ],
+ false,
+ false,
+ [],
+ true,
+ ],
+ [
+ 'test',
+ false,
false,
[],
[
@@ -443,9 +467,10 @@ class UserPluginTest extends TestCase {
array $expected,
$reachedEnd,
$singleUser,
- array $users = []
+ array $users = [],
+ $shareeEnumerationPhone = false
) {
- $this->mockConfig($shareWithGroupOnly, $shareeEnumeration, false);
+ $this->mockConfig($shareWithGroupOnly, $shareeEnumeration, false, $shareeEnumerationPhone);
$this->instantiatePlugin();
$this->session->expects($this->any())
@@ -453,10 +478,24 @@ class UserPluginTest extends TestCase {
->willReturn($this->user);
if (!$shareWithGroupOnly) {
- $this->userManager->expects($this->once())
- ->method('searchDisplayName')
- ->with($searchTerm, $this->limit, $this->offset)
- ->willReturn($userResponse);
+ if ($shareeEnumerationPhone) {
+ $this->userManager->expects($this->once())
+ ->method('searchKnownUsersByDisplayName')
+ ->with($this->user->getUID(), $searchTerm, $this->limit, $this->offset)
+ ->willReturn($userResponse);
+
+ $this->knownUserService->method('isKnownToUser')
+ ->willReturnMap([
+ [$this->user->getUID(), 'test0', true],
+ [$this->user->getUID(), 'test1', true],
+ [$this->user->getUID(), 'test2', true],
+ ]);
+ } else {
+ $this->userManager->expects($this->once())
+ ->method('searchDisplayName')
+ ->with($searchTerm, $this->limit, $this->offset)
+ ->willReturn($userResponse);
+ }
} else {
$this->groupManager->method('getUserGroupIds')
->with($this->user)