2014-12-19 15:28:11 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-01-12 17:02:16 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
|
|
* @author Vincent Petry <pvince81@owncloud.com>
|
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2014-12-19 15:28:11 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-05-25 17:04:15 +03:00
|
|
|
namespace OCA\DAV\Tests\unit\Connector\Sabre;
|
2014-12-19 18:50:32 +03:00
|
|
|
|
2017-01-09 23:20:55 +03:00
|
|
|
use OC\User\User;
|
|
|
|
use OCP\IGroup;
|
2016-01-11 19:29:01 +03:00
|
|
|
use OCP\IGroupManager;
|
2017-12-04 17:02:55 +03:00
|
|
|
use OCP\IUser;
|
|
|
|
use OCP\IUserSession;
|
|
|
|
use OCP\Share\IManager;
|
2015-02-12 14:29:01 +03:00
|
|
|
use \Sabre\DAV\PropPatch;
|
2014-12-19 15:28:11 +03:00
|
|
|
use OCP\IUserManager;
|
2016-01-11 22:04:33 +03:00
|
|
|
use Test\TestCase;
|
2014-12-19 15:28:11 +03:00
|
|
|
|
2016-05-25 17:04:15 +03:00
|
|
|
class PrincipalTest extends TestCase {
|
2016-01-11 22:04:33 +03:00
|
|
|
/** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject */
|
2014-12-19 15:28:11 +03:00
|
|
|
private $userManager;
|
2015-08-30 20:13:01 +03:00
|
|
|
/** @var \OCA\DAV\Connector\Sabre\Principal */
|
2014-12-19 15:28:11 +03:00
|
|
|
private $connector;
|
2016-01-11 22:04:33 +03:00
|
|
|
/** @var IGroupManager | \PHPUnit_Framework_MockObject_MockObject */
|
2016-01-11 19:29:01 +03:00
|
|
|
private $groupManager;
|
2017-12-04 17:02:55 +03:00
|
|
|
/** @var IManager | \PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $shareManager;
|
|
|
|
/** @var IUserSession | \PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $userSession;
|
2014-12-19 15:28:11 +03:00
|
|
|
|
|
|
|
public function setUp() {
|
2017-01-09 23:20:55 +03:00
|
|
|
$this->userManager = $this->createMock(IUserManager::class);
|
|
|
|
$this->groupManager = $this->createMock(IGroupManager::class);
|
2017-12-04 17:02:55 +03:00
|
|
|
$this->shareManager = $this->createMock(IManager::class);
|
|
|
|
$this->userSession = $this->createMock(IUserSession::class);
|
2014-12-19 15:28:11 +03:00
|
|
|
|
2016-01-11 19:29:01 +03:00
|
|
|
$this->connector = new \OCA\DAV\Connector\Sabre\Principal(
|
|
|
|
$this->userManager,
|
2017-12-04 17:02:55 +03:00
|
|
|
$this->groupManager,
|
|
|
|
$this->shareManager,
|
|
|
|
$this->userSession);
|
2014-12-19 15:28:11 +03:00
|
|
|
parent::setUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPrincipalsByPrefixWithoutPrefix() {
|
|
|
|
$response = $this->connector->getPrincipalsByPrefix('');
|
|
|
|
$this->assertSame([], $response);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPrincipalsByPrefixWithUsers() {
|
2017-01-09 23:20:55 +03:00
|
|
|
$fooUser = $this->createMock(User::class);
|
2014-12-19 15:28:11 +03:00
|
|
|
$fooUser
|
2015-11-25 01:28:24 +03:00
|
|
|
->expects($this->exactly(1))
|
2015-11-24 13:15:31 +03:00
|
|
|
->method('getUID')
|
|
|
|
->will($this->returnValue('foo'));
|
|
|
|
$fooUser
|
|
|
|
->expects($this->exactly(1))
|
|
|
|
->method('getDisplayName')
|
|
|
|
->will($this->returnValue('Dr. Foo-Bar'));
|
2015-11-25 01:28:24 +03:00
|
|
|
$fooUser
|
|
|
|
->expects($this->exactly(1))
|
|
|
|
->method('getEMailAddress')
|
|
|
|
->will($this->returnValue(''));
|
2017-01-09 23:20:55 +03:00
|
|
|
$barUser = $this->createMock(User::class);
|
2014-12-19 15:28:11 +03:00
|
|
|
$barUser
|
2015-11-25 01:28:24 +03:00
|
|
|
->expects($this->exactly(1))
|
2014-12-19 15:28:11 +03:00
|
|
|
->method('getUID')
|
|
|
|
->will($this->returnValue('bar'));
|
2015-11-25 01:28:24 +03:00
|
|
|
$barUser
|
|
|
|
->expects($this->exactly(1))
|
|
|
|
->method('getEMailAddress')
|
|
|
|
->will($this->returnValue('bar@owncloud.org'));
|
2014-12-19 15:28:11 +03:00
|
|
|
$this->userManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('search')
|
|
|
|
->with('')
|
|
|
|
->will($this->returnValue([$fooUser, $barUser]));
|
|
|
|
|
|
|
|
$expectedResponse = [
|
|
|
|
0 => [
|
2015-11-24 13:15:31 +03:00
|
|
|
'uri' => 'principals/users/foo',
|
|
|
|
'{DAV:}displayname' => 'Dr. Foo-Bar'
|
2014-12-19 15:28:11 +03:00
|
|
|
],
|
|
|
|
1 => [
|
2015-11-24 13:15:31 +03:00
|
|
|
'uri' => 'principals/users/bar',
|
2014-12-19 15:28:11 +03:00
|
|
|
'{DAV:}displayname' => 'bar',
|
|
|
|
'{http://sabredav.org/ns}email-address' => 'bar@owncloud.org'
|
|
|
|
]
|
|
|
|
];
|
2015-11-24 13:15:31 +03:00
|
|
|
$response = $this->connector->getPrincipalsByPrefix('principals/users');
|
2014-12-19 15:28:11 +03:00
|
|
|
$this->assertSame($expectedResponse, $response);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPrincipalsByPrefixEmpty() {
|
|
|
|
$this->userManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('search')
|
|
|
|
->with('')
|
|
|
|
->will($this->returnValue([]));
|
|
|
|
|
2015-11-24 13:15:31 +03:00
|
|
|
$response = $this->connector->getPrincipalsByPrefix('principals/users');
|
2014-12-19 15:28:11 +03:00
|
|
|
$this->assertSame([], $response);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPrincipalsByPathWithoutMail() {
|
2017-01-09 23:20:55 +03:00
|
|
|
$fooUser = $this->createMock(User::class);
|
2014-12-19 15:28:11 +03:00
|
|
|
$fooUser
|
2015-11-25 01:28:24 +03:00
|
|
|
->expects($this->exactly(1))
|
2014-12-19 15:28:11 +03:00
|
|
|
->method('getUID')
|
|
|
|
->will($this->returnValue('foo'));
|
|
|
|
$this->userManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('get')
|
|
|
|
->with('foo')
|
|
|
|
->will($this->returnValue($fooUser));
|
|
|
|
|
|
|
|
$expectedResponse = [
|
2015-11-24 13:15:31 +03:00
|
|
|
'uri' => 'principals/users/foo',
|
2014-12-19 15:28:11 +03:00
|
|
|
'{DAV:}displayname' => 'foo'
|
|
|
|
];
|
2015-11-24 13:15:31 +03:00
|
|
|
$response = $this->connector->getPrincipalByPath('principals/users/foo');
|
2014-12-19 15:28:11 +03:00
|
|
|
$this->assertSame($expectedResponse, $response);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPrincipalsByPathWithMail() {
|
2017-01-09 23:20:55 +03:00
|
|
|
$fooUser = $this->createMock(User::class);
|
2014-12-19 15:28:11 +03:00
|
|
|
$fooUser
|
2015-11-25 01:28:24 +03:00
|
|
|
->expects($this->exactly(1))
|
|
|
|
->method('getEMailAddress')
|
|
|
|
->will($this->returnValue('foo@owncloud.org'));
|
|
|
|
$fooUser
|
|
|
|
->expects($this->exactly(1))
|
|
|
|
->method('getUID')
|
|
|
|
->will($this->returnValue('foo'));
|
2014-12-19 15:28:11 +03:00
|
|
|
$this->userManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('get')
|
|
|
|
->with('foo')
|
|
|
|
->will($this->returnValue($fooUser));
|
|
|
|
|
|
|
|
$expectedResponse = [
|
2015-11-24 13:15:31 +03:00
|
|
|
'uri' => 'principals/users/foo',
|
2014-12-19 15:28:11 +03:00
|
|
|
'{DAV:}displayname' => 'foo',
|
|
|
|
'{http://sabredav.org/ns}email-address' => 'foo@owncloud.org'
|
|
|
|
];
|
2015-11-24 13:15:31 +03:00
|
|
|
$response = $this->connector->getPrincipalByPath('principals/users/foo');
|
2014-12-19 15:28:11 +03:00
|
|
|
$this->assertSame($expectedResponse, $response);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPrincipalsByPathEmpty() {
|
|
|
|
$this->userManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('get')
|
|
|
|
->with('foo')
|
|
|
|
->will($this->returnValue(null));
|
|
|
|
|
2015-11-24 13:15:31 +03:00
|
|
|
$response = $this->connector->getPrincipalByPath('principals/users/foo');
|
2014-12-19 15:28:11 +03:00
|
|
|
$this->assertSame(null, $response);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetGroupMemberSet() {
|
2017-01-09 23:20:55 +03:00
|
|
|
$fooUser = $this->createMock(User::class);
|
2014-12-19 15:28:11 +03:00
|
|
|
$fooUser
|
2015-11-25 01:28:24 +03:00
|
|
|
->expects($this->exactly(1))
|
2014-12-19 15:28:11 +03:00
|
|
|
->method('getUID')
|
|
|
|
->will($this->returnValue('foo'));
|
|
|
|
$this->userManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('get')
|
|
|
|
->with('foo')
|
|
|
|
->will($this->returnValue($fooUser));
|
|
|
|
|
2015-11-24 13:15:31 +03:00
|
|
|
$response = $this->connector->getGroupMemberSet('principals/users/foo');
|
|
|
|
$this->assertSame(['principals/users/foo'], $response);
|
2014-12-19 15:28:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException \Sabre\DAV\Exception
|
|
|
|
* @expectedExceptionMessage Principal not found
|
|
|
|
*/
|
|
|
|
public function testGetGroupMemberSetEmpty() {
|
|
|
|
$this->userManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('get')
|
|
|
|
->with('foo')
|
|
|
|
->will($this->returnValue(null));
|
|
|
|
|
2015-11-24 13:15:31 +03:00
|
|
|
$this->connector->getGroupMemberSet('principals/users/foo');
|
2014-12-19 15:28:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetGroupMembership() {
|
2017-01-09 23:20:55 +03:00
|
|
|
$fooUser = $this->createMock(User::class);
|
|
|
|
$group1 = $this->createMock(IGroup::class);
|
|
|
|
$group1->expects($this->once())
|
2016-02-10 12:43:32 +03:00
|
|
|
->method('getGID')
|
|
|
|
->willReturn('group1');
|
2017-01-09 23:20:55 +03:00
|
|
|
$group2 = $this->createMock(IGroup::class);
|
|
|
|
$group2->expects($this->once())
|
|
|
|
->method('getGID')
|
|
|
|
->willReturn('foo/bar');
|
2014-12-19 15:28:11 +03:00
|
|
|
$this->userManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('get')
|
|
|
|
->with('foo')
|
2016-01-11 22:04:33 +03:00
|
|
|
->willReturn($fooUser);
|
|
|
|
$this->groupManager
|
2016-02-10 12:43:32 +03:00
|
|
|
->expects($this->once())
|
2016-01-11 22:04:33 +03:00
|
|
|
->method('getUserGroups')
|
2017-01-09 23:20:55 +03:00
|
|
|
->with($fooUser)
|
2016-02-10 12:43:32 +03:00
|
|
|
->willReturn([
|
2017-01-09 23:20:55 +03:00
|
|
|
$group1,
|
|
|
|
$group2,
|
2016-02-10 12:43:32 +03:00
|
|
|
]);
|
2014-12-19 15:28:11 +03:00
|
|
|
|
2016-02-10 12:43:32 +03:00
|
|
|
$expectedResponse = [
|
2017-01-09 23:20:55 +03:00
|
|
|
'principals/groups/group1',
|
|
|
|
'principals/groups/foo%2Fbar',
|
2016-02-10 12:43:32 +03:00
|
|
|
];
|
2015-11-24 13:15:31 +03:00
|
|
|
$response = $this->connector->getGroupMembership('principals/users/foo');
|
2014-12-19 15:28:11 +03:00
|
|
|
$this->assertSame($expectedResponse, $response);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException \Sabre\DAV\Exception
|
|
|
|
* @expectedExceptionMessage Principal not found
|
|
|
|
*/
|
|
|
|
public function testGetGroupMembershipEmpty() {
|
|
|
|
$this->userManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('get')
|
|
|
|
->with('foo')
|
|
|
|
->will($this->returnValue(null));
|
|
|
|
|
2015-11-24 13:15:31 +03:00
|
|
|
$this->connector->getGroupMembership('principals/users/foo');
|
2014-12-19 15:28:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException \Sabre\DAV\Exception
|
|
|
|
* @expectedExceptionMessage Setting members of the group is not supported yet
|
|
|
|
*/
|
|
|
|
public function testSetGroupMembership() {
|
2015-11-24 13:15:31 +03:00
|
|
|
$this->connector->setGroupMemberSet('principals/users/foo', ['foo']);
|
2014-12-19 15:28:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testUpdatePrincipal() {
|
2015-02-12 14:29:01 +03:00
|
|
|
$this->assertSame(0, $this->connector->updatePrincipal('foo', new PropPatch(array())));
|
2014-12-19 15:28:11 +03:00
|
|
|
}
|
|
|
|
|
2017-12-04 17:02:55 +03:00
|
|
|
public function testSearchPrincipalsWithEmptySearchProperties() {
|
2015-11-24 13:15:31 +03:00
|
|
|
$this->assertSame([], $this->connector->searchPrincipals('principals/users', []));
|
2014-12-19 15:28:11 +03:00
|
|
|
}
|
2016-05-02 15:19:10 +03:00
|
|
|
|
2017-12-04 17:02:55 +03:00
|
|
|
public function testSearchPrincipalsWithWrongPrefixPath() {
|
|
|
|
$this->assertSame([], $this->connector->searchPrincipals('principals/groups',
|
|
|
|
['{http://sabredav.org/ns}email-address' => 'foo']));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider searchPrincipalsDataProvider
|
|
|
|
*/
|
|
|
|
public function testSearchPrincipals($sharingEnabled, $groupsOnly, $result) {
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
->method('shareAPIEnabled')
|
|
|
|
->will($this->returnValue($sharingEnabled));
|
|
|
|
|
|
|
|
if ($sharingEnabled) {
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
->method('shareWithGroupMembersOnly')
|
|
|
|
->will($this->returnValue($groupsOnly));
|
|
|
|
|
|
|
|
if ($groupsOnly) {
|
|
|
|
$user = $this->createMock(IUser::class);
|
|
|
|
$this->userSession->expects($this->once())
|
|
|
|
->method('getUser')
|
|
|
|
->will($this->returnValue($user));
|
|
|
|
|
|
|
|
$this->groupManager->expects($this->at(0))
|
|
|
|
->method('getUserGroupIds')
|
|
|
|
->with($user)
|
|
|
|
->will($this->returnValue(['group1', 'group2']));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$this->shareManager->expects($this->never())
|
|
|
|
->method('shareWithGroupMembersOnly');
|
|
|
|
$this->groupManager->expects($this->never())
|
|
|
|
->method($this->anything());
|
|
|
|
}
|
|
|
|
|
|
|
|
$user2 = $this->createMock(IUser::class);
|
|
|
|
$user2->method('getUID')->will($this->returnValue('user2'));
|
|
|
|
$user3 = $this->createMock(IUser::class);
|
|
|
|
$user3->method('getUID')->will($this->returnValue('user3'));
|
|
|
|
|
|
|
|
if ($sharingEnabled) {
|
|
|
|
$this->userManager->expects($this->at(0))
|
|
|
|
->method('getByEmail')
|
|
|
|
->with('user')
|
|
|
|
->will($this->returnValue([$user2, $user3]));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($sharingEnabled && $groupsOnly) {
|
|
|
|
$this->groupManager->expects($this->at(1))
|
|
|
|
->method('getUserGroupIds')
|
|
|
|
->with($user2)
|
|
|
|
->will($this->returnValue(['group1', 'group3']));
|
|
|
|
$this->groupManager->expects($this->at(2))
|
|
|
|
->method('getUserGroupIds')
|
|
|
|
->with($user3)
|
|
|
|
->will($this->returnValue(['group3', 'group4']));
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertEquals($result, $this->connector->searchPrincipals('principals/users',
|
|
|
|
['{http://sabredav.org/ns}email-address' => 'user']));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function searchPrincipalsDataProvider() {
|
|
|
|
return [
|
|
|
|
[true, false, ['principals/users/user2', 'principals/users/user3']],
|
|
|
|
[true, true, ['principals/users/user2']],
|
|
|
|
[false, false, []],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testFindByUriSharingApiDisabled() {
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
->method('shareApiEnabled')
|
|
|
|
->will($this->returnValue(false));
|
|
|
|
|
|
|
|
$this->assertEquals(null, $this->connector->findByUri('mailto:user@foo.com', 'principals/users'));
|
|
|
|
}
|
2016-05-02 15:19:10 +03:00
|
|
|
|
2017-12-04 17:02:55 +03:00
|
|
|
/**
|
|
|
|
* @dataProvider findByUriWithGroupRestrictionDataProvider
|
|
|
|
*/
|
|
|
|
public function testFindByUriWithGroupRestriction($uri, $email, $expects) {
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
->method('shareApiEnabled')
|
|
|
|
->will($this->returnValue(true));
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
->method('shareWithGroupMembersOnly')
|
|
|
|
->will($this->returnValue(true));
|
|
|
|
|
|
|
|
$user = $this->createMock(IUser::class);
|
|
|
|
$this->userSession->expects($this->once())
|
|
|
|
->method('getUser')
|
|
|
|
->will($this->returnValue($user));
|
|
|
|
|
|
|
|
$this->groupManager->expects($this->at(0))
|
|
|
|
->method('getUserGroupIds')
|
|
|
|
->with($user)
|
|
|
|
->will($this->returnValue(['group1', 'group2']));
|
|
|
|
|
|
|
|
$user2 = $this->createMock(IUser::class);
|
|
|
|
$user2->method('getUID')->will($this->returnValue('user2'));
|
|
|
|
$user3 = $this->createMock(IUser::class);
|
|
|
|
$user3->method('getUID')->will($this->returnValue('user3'));
|
|
|
|
|
|
|
|
$this->userManager->expects($this->once())
|
|
|
|
->method('getByEmail')
|
|
|
|
->with($email)
|
|
|
|
->will($this->returnValue([$email === 'user2@foo.bar' ? $user2 : $user3]));
|
|
|
|
|
|
|
|
if ($email === 'user2@foo.bar') {
|
|
|
|
$this->groupManager->expects($this->at(1))
|
|
|
|
->method('getUserGroupIds')
|
|
|
|
->with($user2)
|
|
|
|
->will($this->returnValue(['group1', 'group3']));
|
|
|
|
} else {
|
|
|
|
$this->groupManager->expects($this->at(1))
|
|
|
|
->method('getUserGroupIds')
|
|
|
|
->with($user3)
|
|
|
|
->will($this->returnValue(['group3', 'group3']));
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertEquals($expects, $this->connector->findByUri($uri, 'principals/users'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function findByUriWithGroupRestrictionDataProvider() {
|
|
|
|
return [
|
|
|
|
['mailto:user2@foo.bar', 'user2@foo.bar', 'principals/users/user2'],
|
|
|
|
['mailto:user3@foo.bar', 'user3@foo.bar', null],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider findByUriWithoutGroupRestrictionDataProvider
|
|
|
|
*/
|
|
|
|
public function testFindByUriWithoutGroupRestriction($uri, $email, $expects) {
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
->method('shareApiEnabled')
|
|
|
|
->will($this->returnValue(true));
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
->method('shareWithGroupMembersOnly')
|
|
|
|
->will($this->returnValue(false));
|
|
|
|
|
|
|
|
$user2 = $this->createMock(IUser::class);
|
|
|
|
$user2->method('getUID')->will($this->returnValue('user2'));
|
|
|
|
$user3 = $this->createMock(IUser::class);
|
|
|
|
$user3->method('getUID')->will($this->returnValue('user3'));
|
|
|
|
|
|
|
|
$this->userManager->expects($this->once())
|
|
|
|
->method('getByEmail')
|
|
|
|
->with($email)
|
|
|
|
->will($this->returnValue([$email === 'user2@foo.bar' ? $user2 : $user3]));
|
|
|
|
|
|
|
|
$this->assertEquals($expects, $this->connector->findByUri($uri, 'principals/users'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function findByUriWithoutGroupRestrictionDataProvider() {
|
|
|
|
return [
|
|
|
|
['mailto:user2@foo.bar', 'user2@foo.bar', 'principals/users/user2'],
|
|
|
|
['mailto:user3@foo.bar', 'user3@foo.bar', 'principals/users/user3'],
|
|
|
|
];
|
2016-05-02 15:19:10 +03:00
|
|
|
}
|
2014-12-19 15:28:11 +03:00
|
|
|
}
|