}
}
+ $searchLimit = $this->config->getSystemValue('sharing.maxAutocompleteResults', null);
foreach ($searchProperties as $prop => $value) {
switch ($prop) {
case '{http://sabredav.org/ns}email-address':
break;
case '{DAV:}displayname':
- $users = $this->userManager->searchDisplayName($value);
+ $users = $this->userManager->searchDisplayName($value, $searchLimit);
if (!$allowEnumeration) {
$users = \array_filter($users, static function (IUser $user) use ($value) {
namespace OCA\DAV\DAV;
+use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
/** @var IShareManager */
private $shareManager;
+ /** @var IConfig */
+ private $config;
/**
* @param IGroupManager $IGroupManager
* @param IUserSession $userSession
* @param IShareManager $shareManager
*/
- public function __construct(IGroupManager $IGroupManager,
- IUserSession $userSession,
- IShareManager $shareManager) {
+ public function __construct(
+ IGroupManager $IGroupManager,
+ IUserSession $userSession,
+ IShareManager $shareManager,
+ IConfig $config
+ ) {
$this->groupManager = $IGroupManager;
$this->userSession = $userSession;
$this->shareManager = $shareManager;
+ $this->config = $config;
}
/**
$restrictGroups = $this->groupManager->getUserGroupIds($user);
}
+ $searchLimit = $this->config->getSystemValue('sharing.maxAutocompleteResults', null);
foreach ($searchProperties as $prop => $value) {
switch ($prop) {
case '{DAV:}displayname':
- $groups = $this->groupManager->search($value);
+ $groups = $this->groupManager->search($value, $searchLimit);
$results[] = array_reduce($groups, function (array $carry, IGroup $group) use ($restrictGroups) {
$gid = $group->getGID();
$proxyMapper,
\OC::$server->getConfig()
);
- $groupPrincipalBackend = new GroupPrincipalBackend($groupManager, $userSession, $shareManager);
+ $groupPrincipalBackend = new GroupPrincipalBackend($groupManager, $userSession, $shareManager, $config);
$calendarResourcePrincipalBackend = new ResourcePrincipalBackend($db, $userSession, $groupManager, $logger, $proxyMapper);
$calendarRoomPrincipalBackend = new RoomPrincipalBackend($db, $userSession, $groupManager, $logger, $proxyMapper);
// as soon as debug mode is enabled we allow listing of principals
use OC\Group\Group;
use OCA\DAV\DAV\GroupPrincipalBackend;
+use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
use Sabre\DAV\PropPatch;
class GroupPrincipalTest extends \Test\TestCase {
+ /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ private $config;
/** @var IGroupManager | \PHPUnit\Framework\MockObject\MockObject */
private $groupManager;
$this->groupManager = $this->createMock(IGroupManager::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->shareManager = $this->createMock(IManager::class);
+ $this->config = $this->createMock(IConfig::class);
$this->connector = new GroupPrincipalBackend(
$this->groupManager,
$this->userSession,
- $this->shareManager);
+ $this->shareManager,
+ $this->config
+ );
parent::setUp();
}
$this->assertSame($expectedResponse, $response);
}
+ public function testGetPrincipalsByPathGroupWithHash() {
+ $group1 = $this->mockGroup('foo#bar');
+ $this->groupManager
+ ->expects($this->once())
+ ->method('get')
+ ->with('foo#bar')
+ ->willReturn($group1);
+
+ $expectedResponse = [
+ 'uri' => 'principals/groups/foo%23bar',
+ '{DAV:}displayname' => 'Group foo#bar',
+ '{urn:ietf:params:xml:ns:caldav}calendar-user-type' => 'GROUP',
+ ];
+ $response = $this->connector->getPrincipalByPath('principals/groups/foo#bar');
+ $this->assertSame($expectedResponse, $response);
+ }
+
public function testGetGroupMemberSet() {
$response = $this->connector->getGroupMemberSet('principals/groups/foo');
$this->assertSame([], $response);