Merge pull request #9788 from nextcloud/fix/integration/nextcloud-sharing-groups-restriction
fix(integration): Honor sharing to group members restriction
This commit is contained in:
Коммит
846c85301e
|
@ -43,7 +43,10 @@ class NextcloudGroupService implements IGroupService {
|
|||
}
|
||||
|
||||
public function search(string $term): array {
|
||||
if ($this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') !== 'yes') {
|
||||
$c1 = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes');
|
||||
$c2 = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no');
|
||||
if ($c1 !== 'yes'
|
||||
|| $c2 !== 'no') {
|
||||
return [];
|
||||
}
|
||||
$groups = $this->groupManager->search($term);
|
||||
|
|
|
@ -68,7 +68,7 @@ class NextcloudGroupServiceTest extends TestCase {
|
|||
|
||||
public function dataForTestSearch(): array {
|
||||
return [
|
||||
['yes', [
|
||||
['yes', 'no', [
|
||||
[
|
||||
'id' => 'testgroup',
|
||||
'name' => 'first test group',
|
||||
|
@ -78,7 +78,9 @@ class NextcloudGroupServiceTest extends TestCase {
|
|||
'name' => 'second test group',
|
||||
]
|
||||
]],
|
||||
['no', []]
|
||||
['no', 'yes', []],
|
||||
['no', 'no', []],
|
||||
['yes', 'yes', []],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -88,22 +90,24 @@ class NextcloudGroupServiceTest extends TestCase {
|
|||
* @param string $allowGroupSharing
|
||||
* @param array $expected
|
||||
*/
|
||||
public function testSearch(string $allowGroupSharing, array $expected): void {
|
||||
public function testSearch(string $allowGroupSharing, string $restrictSharingToGroups, array $expected): void {
|
||||
$term = 'te'; // searching for: John Doe
|
||||
$searchResult = [
|
||||
$this->createTestGroup('testgroup', 'first test group'),
|
||||
$this->createTestGroup('testgroup2', 'second test group'),
|
||||
];
|
||||
|
||||
$this->groupsManager->expects($allowGroupSharing === 'yes' ? self::once() : self::never())
|
||||
$this->groupsManager->expects(($allowGroupSharing === 'yes' && $restrictSharingToGroups === 'no') ? self::once() : self::never())
|
||||
->method('search')
|
||||
->with($term)
|
||||
->willReturn($searchResult);
|
||||
|
||||
$this->config->expects(self::once())
|
||||
$this->config->expects(self::exactly(2))
|
||||
->method('getAppValue')
|
||||
->with('core', 'shareapi_allow_group_sharing', 'yes')
|
||||
->willReturn($allowGroupSharing);
|
||||
->willReturnMap([
|
||||
['core', 'shareapi_allow_group_sharing', 'yes', $allowGroupSharing],
|
||||
['core', 'shareapi_only_share_with_group_members', 'no', $restrictSharingToGroups],
|
||||
]);
|
||||
|
||||
|
||||
$actual = $this->groupService->search($term);
|
||||
|
|
Загрузка…
Ссылка в новой задаче