Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2021-06-01 13:07:29 +0300
committerGitHub <noreply@github.com>2021-06-01 13:07:29 +0300
commitb29c3aa03f1f5b95b12b51e4f95148f2f01b59d3 (patch)
tree29ab71a2c5a7723fddd34ee2e6ec17f7245e11d9 /tests
parent68a02bbef8dfe47dd4c54023f02fde4e91e212d9 (diff)
parent1c0d975654f71a1ac6a3d30ece915fa6e55397da (diff)
Merge pull request #25658 from nextcloud/dav-respect-disallow-sharing-with-groups
Dav respect disallow sharing with groups
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Collaboration/Collaborators/GroupPluginTest.php105
1 files changed, 60 insertions, 45 deletions
diff --git a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
index 2f7cd1061e9..1cbaa178445 100644
--- a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
@@ -125,13 +125,15 @@ class GroupPluginTest extends TestCase {
return $group;
}
- public function dataGetGroups() {
+ public function dataGetGroups(): array {
return [
- ['test', false, true, [], [], [], [], true, false],
- ['test', false, false, [], [], [], [], true, false],
+ ['test', false, true, false, [], [], [], [], true, false],
+ ['test', false, false, false, [], [], [], [], true, false],
+ // group sharing disabled
+ ['test', false, true, true, [], [], [], [], false, false],
// group without display name
[
- 'test', false, true,
+ 'test', false, true, false,
[$this->getGroupMock('test1')],
[],
[],
@@ -141,7 +143,7 @@ class GroupPluginTest extends TestCase {
],
// group with display name, search by id
[
- 'test', false, true,
+ 'test', false, true, false,
[$this->getGroupMock('test1', 'Test One')],
[],
[],
@@ -151,7 +153,7 @@ class GroupPluginTest extends TestCase {
],
// group with display name, search by display name
[
- 'one', false, true,
+ 'one', false, true, false,
[$this->getGroupMock('test1', 'Test One')],
[],
[],
@@ -161,7 +163,7 @@ class GroupPluginTest extends TestCase {
],
// group with display name, search by display name, exact expected
[
- 'Test One', false, true,
+ 'Test One', false, true, false,
[$this->getGroupMock('test1', 'Test One')],
[],
[['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
@@ -170,7 +172,7 @@ class GroupPluginTest extends TestCase {
false,
],
[
- 'test', false, false,
+ 'test', false, false, false,
[$this->getGroupMock('test1')],
[],
[],
@@ -179,7 +181,7 @@ class GroupPluginTest extends TestCase {
false,
],
[
- 'test', false, true,
+ 'test', false, true, false,
[
$this->getGroupMock('test'),
$this->getGroupMock('test1'),
@@ -191,7 +193,7 @@ class GroupPluginTest extends TestCase {
false,
],
[
- 'test', false, false,
+ 'test', false, false, false,
[
$this->getGroupMock('test'),
$this->getGroupMock('test1'),
@@ -203,7 +205,7 @@ class GroupPluginTest extends TestCase {
false,
],
[
- 'test', false, true,
+ 'test', false, true, false,
[
$this->getGroupMock('test0'),
$this->getGroupMock('test1'),
@@ -218,7 +220,7 @@ class GroupPluginTest extends TestCase {
null,
],
[
- 'test', false, false,
+ 'test', false, false, false,
[
$this->getGroupMock('test0'),
$this->getGroupMock('test1'),
@@ -230,7 +232,7 @@ class GroupPluginTest extends TestCase {
null,
],
[
- 'test', false, true,
+ 'test', false, true, false,
[
$this->getGroupMock('test0'),
$this->getGroupMock('test1'),
@@ -247,7 +249,7 @@ class GroupPluginTest extends TestCase {
$this->getGroupMock('test'),
],
[
- 'test', false, false,
+ 'test', false, false, false,
[
$this->getGroupMock('test0'),
$this->getGroupMock('test1'),
@@ -260,10 +262,10 @@ class GroupPluginTest extends TestCase {
true,
$this->getGroupMock('test'),
],
- ['test', true, true, [], [], [], [], true, false],
- ['test', true, false, [], [], [], [], true, false],
+ ['test', true, true, false, [], [], [], [], true, false],
+ ['test', true, false, false, [], [], [], [], true, false],
[
- 'test', true, true,
+ 'test', true, true, false,
[
$this->getGroupMock('test1'),
$this->getGroupMock('test2'),
@@ -275,7 +277,7 @@ class GroupPluginTest extends TestCase {
false,
],
[
- 'test', true, false,
+ 'test', true, false, false,
[
$this->getGroupMock('test1'),
$this->getGroupMock('test2'),
@@ -287,7 +289,7 @@ class GroupPluginTest extends TestCase {
false,
],
[
- 'test', true, true,
+ 'test', true, true, false,
[
$this->getGroupMock('test'),
$this->getGroupMock('test1'),
@@ -299,7 +301,7 @@ class GroupPluginTest extends TestCase {
false,
],
[
- 'test', true, false,
+ 'test', true, false, false,
[
$this->getGroupMock('test'),
$this->getGroupMock('test1'),
@@ -311,7 +313,7 @@ class GroupPluginTest extends TestCase {
false,
],
[
- 'test', true, true,
+ 'test', true, true, false,
[
$this->getGroupMock('test'),
$this->getGroupMock('test1'),
@@ -323,7 +325,7 @@ class GroupPluginTest extends TestCase {
false,
],
[
- 'test', true, false,
+ 'test', true, false, false,
[
$this->getGroupMock('test'),
$this->getGroupMock('test1'),
@@ -335,7 +337,7 @@ class GroupPluginTest extends TestCase {
false,
],
[
- 'test', true, true,
+ 'test', true, true, false,
[
$this->getGroupMock('test'),
$this->getGroupMock('test1'),
@@ -347,7 +349,7 @@ class GroupPluginTest extends TestCase {
false,
],
[
- 'test', true, false,
+ 'test', true, false, false,
[
$this->getGroupMock('test'),
$this->getGroupMock('test1'),
@@ -359,7 +361,7 @@ class GroupPluginTest extends TestCase {
false,
],
[
- 'test', true, true,
+ 'test', true, true, false,
[
$this->getGroupMock('test0'),
$this->getGroupMock('test1'),
@@ -374,7 +376,7 @@ class GroupPluginTest extends TestCase {
null,
],
[
- 'test', true, false,
+ 'test', true, false, false,
[
$this->getGroupMock('test0'),
$this->getGroupMock('test1'),
@@ -386,7 +388,7 @@ class GroupPluginTest extends TestCase {
null,
],
[
- 'test', true, true,
+ 'test', true, true, false,
[
$this->getGroupMock('test0'),
$this->getGroupMock('test1'),
@@ -403,7 +405,7 @@ class GroupPluginTest extends TestCase {
$this->getGroupMock('test'),
],
[
- 'test', true, false,
+ 'test', true, false, false,
[
$this->getGroupMock('test0'),
$this->getGroupMock('test1'),
@@ -417,7 +419,7 @@ class GroupPluginTest extends TestCase {
$this->getGroupMock('test'),
],
[
- 'test', false, false,
+ 'test', false, false, false,
[
$this->getGroupMock('test', null, true),
$this->getGroupMock('test1'),
@@ -437,6 +439,7 @@ class GroupPluginTest extends TestCase {
* @param string $searchTerm
* @param bool $shareWithGroupOnly
* @param bool $shareeEnumeration
+ * @param bool $groupSharingDisabled
* @param array $groupResponse
* @param array $userGroupsResponse
* @param array $exactExpected
@@ -445,35 +448,45 @@ class GroupPluginTest extends TestCase {
* @param bool|IGroup $singleGroup
*/
public function testSearch(
- $searchTerm,
- $shareWithGroupOnly,
- $shareeEnumeration,
+ string $searchTerm,
+ bool $shareWithGroupOnly,
+ bool $shareeEnumeration,
+ bool $groupSharingDisabled,
array $groupResponse,
array $userGroupsResponse,
array $exactExpected,
array $expected,
- $reachedEnd,
+ bool $reachedEnd,
$singleGroup
) {
$this->config->expects($this->any())
->method('getAppValue')
->willReturnCallback(
- function ($appName, $key, $default) use ($shareWithGroupOnly, $shareeEnumeration) {
- if ($appName === 'core' && $key === 'shareapi_only_share_with_group_members') {
- return $shareWithGroupOnly ? 'yes' : 'no';
- } elseif ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') {
- return $shareeEnumeration ? 'yes' : 'no';
+ function ($appName, $key, $default) use ($shareWithGroupOnly, $shareeEnumeration, $groupSharingDisabled) {
+ if ($appName !== 'core') {
+ return $default;
+ }
+ switch ($key) {
+ case 'shareapi_only_share_with_group_members':
+ return $shareWithGroupOnly ? 'yes' : 'no';
+ case 'shareapi_allow_share_dialog_user_enumeration':
+ return $shareeEnumeration ? 'yes' : 'no';
+ case 'shareapi_allow_group_sharing':
+ return $groupSharingDisabled ? 'no' : 'yes';
+ default:
+ return $default;
}
- return $default;
}
);
$this->instantiatePlugin();
- $this->groupManager->expects($this->once())
- ->method('search')
- ->with($searchTerm, $this->limit, $this->offset)
- ->willReturn($groupResponse);
+ if (!$groupSharingDisabled) {
+ $this->groupManager->expects($this->once())
+ ->method('search')
+ ->with($searchTerm, $this->limit, $this->offset)
+ ->willReturn($groupResponse);
+ }
if ($singleGroup !== false) {
$this->groupManager->expects($this->once())
@@ -497,8 +510,10 @@ class GroupPluginTest extends TestCase {
$moreResults = $this->plugin->search($searchTerm, $this->limit, $this->offset, $this->searchResult);
$result = $this->searchResult->asArray();
- $this->assertEquals($exactExpected, $result['exact']['groups']);
- $this->assertEquals($expected, $result['groups']);
+ if (!$groupSharingDisabled) {
+ $this->assertEquals($exactExpected, $result['exact']['groups']);
+ $this->assertEquals($expected, $result['groups']);
+ }
$this->assertSame($reachedEnd, $moreResults);
}
}