-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18205 from nextcloud/stable17-backport/18120
[stable17] Backport #18120
- Loading branch information
Showing
10 changed files
with
125 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,21 +65,26 @@ class PrincipalTest extends TestCase { | |
/** @var ProxyMapper | \PHPUnit_Framework_MockObject_MockObject */ | ||
private $proxyMapper; | ||
|
||
/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */ | ||
private $config; | ||
|
||
public function setUp() { | ||
$this->userManager = $this->createMock(IUserManager::class); | ||
$this->groupManager = $this->createMock(IGroupManager::class); | ||
$this->shareManager = $this->createMock(IManager::class); | ||
$this->userSession = $this->createMock(IUserSession::class); | ||
$this->appManager = $this->createMock(IAppManager::class); | ||
$this->proxyMapper = $this->createMock(ProxyMapper::class); | ||
$this->config = $this->createMock(IConfig::class); | ||
|
||
$this->connector = new \OCA\DAV\Connector\Sabre\Principal( | ||
$this->userManager, | ||
$this->groupManager, | ||
$this->shareManager, | ||
$this->userSession, | ||
$this->appManager, | ||
$this->proxyMapper | ||
$this->proxyMapper, | ||
$this->config | ||
); | ||
parent::setUp(); | ||
} | ||
|
@@ -403,11 +408,6 @@ public function testSetGroupMembershipProxy() { | |
$this->connector->setGroupMemberSet('principals/users/foo/calendar-proxy-write', ['principals/users/bar']); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
public function testUpdatePrincipal() { | ||
$this->assertSame(0, $this->connector->updatePrincipal('foo', new PropPatch(array()))); | ||
} | ||
|
@@ -430,6 +430,11 @@ public function testSearchPrincipals($sharingEnabled, $groupsOnly, $test, $resul | |
->will($this->returnValue($sharingEnabled)); | ||
|
||
if ($sharingEnabled) { | ||
$this->config->expects($this->once()) | ||
->method('getAppValue') | ||
->with('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') | ||
->willReturn('yes'); | ||
|
||
$this->shareManager->expects($this->once()) | ||
->method('shareWithGroupMembersOnly') | ||
->will($this->returnValue($groupsOnly)); | ||
|
@@ -446,6 +451,8 @@ public function testSearchPrincipals($sharingEnabled, $groupsOnly, $test, $resul | |
->will($this->returnValue(['group1', 'group2', 'group5'])); | ||
} | ||
} else { | ||
$this->config->expects($this->never()) | ||
->method('getAppValue'); | ||
$this->shareManager->expects($this->never()) | ||
->method('shareWithGroupMembersOnly'); | ||
$this->groupManager->expects($this->never()) | ||
|
@@ -518,6 +525,11 @@ public function testSearchPrincipalByCalendarUserAddressSet() { | |
->method('shareAPIEnabled') | ||
->will($this->returnValue(true)); | ||
|
||
$this->config->expects($this->exactly(2)) | ||
->method('getAppValue') | ||
->with('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') | ||
->willReturn('yes'); | ||
|
||
$this->shareManager->expects($this->exactly(2)) | ||
->method('shareWithGroupMembersOnly') | ||
->will($this->returnValue(false)); | ||
|
@@ -539,6 +551,78 @@ public function testSearchPrincipalByCalendarUserAddressSet() { | |
['{urn:ietf:params:xml:ns:caldav}calendar-user-address-set' => '[email protected]'])); | ||
} | ||
|
||
public function testSearchPrincipalWithEnumerationDisabledDisplayname() { | ||
$this->shareManager->expects($this->once()) | ||
->method('shareAPIEnabled') | ||
->will($this->returnValue(true)); | ||
|
||
$this->config->expects($this->once()) | ||
->method('getAppValue') | ||
->with('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') | ||
->willReturn('no'); | ||
|
||
$this->shareManager->expects($this->once()) | ||
->method('shareWithGroupMembersOnly') | ||
->will($this->returnValue(false)); | ||
|
||
$user2 = $this->createMock(IUser::class); | ||
$user2->method('getUID')->will($this->returnValue('user2')); | ||
$user2->method('getDisplayName')->will($this->returnValue('User 2')); | ||
$user2->method('getEMailAddress')->will($this->returnValue('[email protected]')); | ||
$user3 = $this->createMock(IUser::class); | ||
$user3->method('getUID')->will($this->returnValue('user3')); | ||
$user2->method('getDisplayName')->will($this->returnValue('User 22')); | ||
$user2->method('getEMailAddress')->will($this->returnValue('[email protected]')); | ||
$user4 = $this->createMock(IUser::class); | ||
$user4->method('getUID')->will($this->returnValue('user4')); | ||
$user2->method('getDisplayName')->will($this->returnValue('User 222')); | ||
$user2->method('getEMailAddress')->will($this->returnValue('[email protected]')); | ||
|
||
$this->userManager->expects($this->at(0)) | ||
->method('searchDisplayName') | ||
->with('User 2') | ||
->will($this->returnValue([$user2, $user3, $user4])); | ||
|
||
$this->assertEquals(['principals/users/user2'], $this->connector->searchPrincipals('principals/users', | ||
['{DAV:}displayname' => 'User 2'])); | ||
} | ||
|
||
public function testSearchPrincipalWithEnumerationDisabledEmail() { | ||
$this->shareManager->expects($this->once()) | ||
->method('shareAPIEnabled') | ||
->will($this->returnValue(true)); | ||
|
||
$this->config->expects($this->once()) | ||
->method('getAppValue') | ||
->with('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') | ||
->willReturn('no'); | ||
|
||
$this->shareManager->expects($this->once()) | ||
->method('shareWithGroupMembersOnly') | ||
->will($this->returnValue(false)); | ||
|
||
$user2 = $this->createMock(IUser::class); | ||
$user2->method('getUID')->will($this->returnValue('user2')); | ||
$user2->method('getDisplayName')->will($this->returnValue('User 2')); | ||
$user2->method('getEMailAddress')->will($this->returnValue('[email protected]')); | ||
$user3 = $this->createMock(IUser::class); | ||
$user3->method('getUID')->will($this->returnValue('user3')); | ||
$user2->method('getDisplayName')->will($this->returnValue('User 22')); | ||
$user2->method('getEMailAddress')->will($this->returnValue('[email protected]')); | ||
$user4 = $this->createMock(IUser::class); | ||
$user4->method('getUID')->will($this->returnValue('user4')); | ||
$user2->method('getDisplayName')->will($this->returnValue('User 222')); | ||
$user2->method('getEMailAddress')->will($this->returnValue('[email protected]')); | ||
|
||
$this->userManager->expects($this->at(0)) | ||
->method('getByEmail') | ||
->with('[email protected]') | ||
->will($this->returnValue([$user2, $user3, $user4])); | ||
|
||
$this->assertEquals(['principals/users/user2'], $this->connector->searchPrincipals('principals/users', | ||
['{http://sabredav.org/ns}email-address' => '[email protected]'])); | ||
} | ||
|
||
public function testFindByUriSharingApiDisabled() { | ||
$this->shareManager->expects($this->once()) | ||
->method('shareApiEnabled') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters