diff options
author | Joas Schilling <coding@schilljs.com> | 2021-03-17 10:26:21 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-03-17 11:20:30 +0100 |
commit | cf434d5107acc95d8a6afad15707e3e4fc33bbc9 (patch) | |
tree | 04901fa8e58eb76a16914812fea18331b9a55682 /tests | |
parent | 3379e69ecc092da6897f38a0be30e917a38f5439 (diff) | |
download | nextcloud-server-cf434d5107acc95d8a6afad15707e3e4fc33bbc9.tar.gz nextcloud-server-cf434d5107acc95d8a6afad15707e3e4fc33bbc9.zip |
Also limit to user group in case enumeration is enabled for groups and phonenumbers
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Collaboration/Collaborators/UserPluginTest.php | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/lib/Collaboration/Collaborators/UserPluginTest.php b/tests/lib/Collaboration/Collaborators/UserPluginTest.php index 43bbffc9b6a..acbcd42f04f 100644 --- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/UserPluginTest.php @@ -659,9 +659,10 @@ class UserPluginTest extends TestCase { public function testSearchEnumerationLimit($search, $userGroups, $matchingUsers, $result) { $this->mockConfig(false, true, true); - $userResults = array_map(function ($user) { - return $this->getUserMock($user['uid'], $user['uid']); - }, $matchingUsers); + $userResults = []; + foreach ($matchingUsers as $user) { + $userResults[$user['uid']] = $user['uid']; + } $mappedResultExact = array_map(function ($user) { return ['label' => $user, 'value' => ['shareType' => 0, 'shareWith' => $user], 'icon' => 'icon-user', 'subline' => null, 'status' => [], 'shareWithDisplayNameUnique' => $user]; @@ -670,9 +671,19 @@ class UserPluginTest extends TestCase { return ['label' => $user, 'value' => ['shareType' => 0, 'shareWith' => $user], 'icon' => 'icon-user', 'subline' => null, 'status' => [], 'shareWithDisplayNameUnique' => $user]; }, $result['wide']); - $this->userManager->expects($this->once()) - ->method('searchDisplayName') + $this->userManager + ->method('get') + ->willReturnCallback(function ($userId) use ($userResults) { + if (isset($userResults[$userId])) { + return $this->getUserMock($userId, $userId); + } + return null; + }); + + $this->groupManager->method('displayNamesInGroup') ->willReturn($userResults); + + $this->session->expects($this->any()) ->method('getUser') ->willReturn($this->getUserMock('test', 'foo')); |