-
-
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.
respect shareapi_allow_share_dialog_user_enumeration in Principal bac…
…kend for Sabre/DAV Signed-off-by: Georg Ehrke <[email protected]>
- Loading branch information
1 parent
9fce87b
commit c3748cf
Showing
10 changed files
with
128 additions
and
15 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; | ||
|
||
protected function setUp(): void { | ||
$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(); | ||
} | ||
|
@@ -209,7 +214,7 @@ public function testGetGroupMemberSet() { | |
$this->assertSame([], $response); | ||
} | ||
|
||
|
||
public function testGetGroupMemberSetEmpty() { | ||
$this->expectException(\Sabre\DAV\Exception::class); | ||
$this->expectExceptionMessage('Principal not found'); | ||
|
@@ -334,7 +339,7 @@ public function testGetGroupMembership() { | |
$this->assertSame($expectedResponse, $response); | ||
} | ||
|
||
|
||
public function testGetGroupMembershipEmpty() { | ||
$this->expectException(\Sabre\DAV\Exception::class); | ||
$this->expectExceptionMessage('Principal not found'); | ||
|
@@ -348,7 +353,7 @@ public function testGetGroupMembershipEmpty() { | |
$this->connector->getGroupMembership('principals/users/foo'); | ||
} | ||
|
||
|
||
public function testSetGroupMembership() { | ||
$this->expectException(\Sabre\DAV\Exception::class); | ||
$this->expectExceptionMessage('Setting members of the group is not supported yet'); | ||
|
@@ -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