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:
authorMorris Jobke <hey@morrisjobke.de>2021-05-21 16:35:39 +0300
committerGitHub <noreply@github.com>2021-05-21 16:35:39 +0300
commitf1dbabd9109c08e62d6f82124c63201c96ad2203 (patch)
treeea6b862c1fa97ec5ad03895c120268bd25d1d35e /tests
parentb1ad3faf14140e3c85a7eec1dade88cd551cc747 (diff)
parent8d7fae8fae054eaa08635fea3ba092196c6f8b84 (diff)
Merge pull request #26727 from nextcloud/group-exclude-link-share
Add option to exclude groups from creating link shares
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Share20/ManagerTest.php33
-rw-r--r--tests/lib/UtilTest.php49
2 files changed, 23 insertions, 59 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index d5094341eeb..117adc95186 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -45,6 +45,7 @@ use OCP\IServerContainer;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
use OCP\Security\Events\ValidatePasswordPolicyEvent;
@@ -104,6 +105,7 @@ class ManagerTest extends \Test\TestCase {
protected $urlGenerator;
/** @var \OC_Defaults|MockObject */
protected $defaults;
+ protected $userSession;
protected function setUp(): void {
$this->logger = $this->createMock(ILogger::class);
@@ -119,6 +121,7 @@ class ManagerTest extends \Test\TestCase {
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->defaults = $this->createMock(\OC_Defaults::class);
$this->dispatcher = $this->createMock(IEventDispatcher::class);
+ $this->userSession = $this->createMock(IUserSession::class);
$this->l10nFactory = $this->createMock(IFactory::class);
$this->l = $this->createMock(IL10N::class);
@@ -149,7 +152,8 @@ class ManagerTest extends \Test\TestCase {
$this->mailer,
$this->urlGenerator,
$this->defaults,
- $this->dispatcher
+ $this->dispatcher,
+ $this->userSession
);
$this->defaultProvider = $this->createMock(DefaultShareProvider::class);
@@ -178,7 +182,8 @@ class ManagerTest extends \Test\TestCase {
$this->mailer,
$this->urlGenerator,
$this->defaults,
- $this->dispatcher
+ $this->dispatcher,
+ $this->userSession
]);
}
@@ -2690,7 +2695,8 @@ class ManagerTest extends \Test\TestCase {
$this->mailer,
$this->urlGenerator,
$this->defaults,
- $this->dispatcher
+ $this->dispatcher,
+ $this->userSession
);
$share = $this->createMock(IShare::class);
@@ -2734,7 +2740,8 @@ class ManagerTest extends \Test\TestCase {
$this->mailer,
$this->urlGenerator,
$this->defaults,
- $this->dispatcher
+ $this->dispatcher,
+ $this->userSession
);
$share = $this->createMock(IShare::class);
@@ -2785,7 +2792,8 @@ class ManagerTest extends \Test\TestCase {
$this->mailer,
$this->urlGenerator,
$this->defaults,
- $this->dispatcher
+ $this->dispatcher,
+ $this->userSession
);
$share = $this->createMock(IShare::class);
@@ -4123,7 +4131,8 @@ class ManagerTest extends \Test\TestCase {
$this->mailer,
$this->urlGenerator,
$this->defaults,
- $this->dispatcher
+ $this->dispatcher,
+ $this->userSession
);
$this->assertSame($expected,
$manager->shareProviderExists($shareType)
@@ -4156,7 +4165,8 @@ class ManagerTest extends \Test\TestCase {
$this->mailer,
$this->urlGenerator,
$this->defaults,
- $this->dispatcher
+ $this->dispatcher,
+ $this->userSession
);
$factory->setProvider($this->defaultProvider);
@@ -4220,7 +4230,8 @@ class ManagerTest extends \Test\TestCase {
$this->mailer,
$this->urlGenerator,
$this->defaults,
- $this->dispatcher
+ $this->dispatcher,
+ $this->userSession
);
$factory->setProvider($this->defaultProvider);
@@ -4336,7 +4347,8 @@ class ManagerTest extends \Test\TestCase {
$this->mailer,
$this->urlGenerator,
$this->defaults,
- $this->dispatcher
+ $this->dispatcher,
+ $this->userSession
);
$factory->setProvider($this->defaultProvider);
@@ -4461,7 +4473,8 @@ class ManagerTest extends \Test\TestCase {
$this->mailer,
$this->urlGenerator,
$this->defaults,
- $this->dispatcher
+ $this->dispatcher,
+ $this->userSession
);
$factory->setProvider($this->defaultProvider);
diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php
index 6e25ce16e75..e21a5323b1b 100644
--- a/tests/lib/UtilTest.php
+++ b/tests/lib/UtilTest.php
@@ -10,8 +10,6 @@ namespace Test;
use OC_Util;
use OCP\App\IAppManager;
-use OCP\IConfig;
-use OCP\IUser;
/**
* Class UtilTest
@@ -172,53 +170,6 @@ class UtilTest extends \Test\TestCase {
}
/**
- * @dataProvider dataProviderForTestIsSharingDisabledForUser
- * @param array $groups existing groups
- * @param array $membership groups the user belong to
- * @param array $excludedGroups groups which should be excluded from sharing
- * @param bool $expected expected result
- */
- public function testIsSharingDisabledForUser($groups, $membership, $excludedGroups, $expected) {
- $config = $this->getMockBuilder(IConfig::class)->disableOriginalConstructor()->getMock();
- $groupManager = $this->getMockBuilder('OCP\IGroupManager')->disableOriginalConstructor()->getMock();
- $user = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
-
- $config
- ->expects($this->at(0))
- ->method('getAppValue')
- ->with('core', 'shareapi_exclude_groups', 'no')
- ->willReturn('yes');
- $config
- ->expects($this->at(1))
- ->method('getAppValue')
- ->with('core', 'shareapi_exclude_groups_list')
- ->willReturn(json_encode($excludedGroups));
-
- $groupManager
- ->expects($this->at(0))
- ->method('getUserGroupIds')
- ->with($user)
- ->willReturn($membership);
-
- $result = \OC_Util::isSharingDisabledForUser($config, $groupManager, $user);
-
- $this->assertSame($expected, $result);
- }
-
- public function dataProviderForTestIsSharingDisabledForUser() {
- return [
- // existing groups, groups the user belong to, groups excluded from sharing, expected result
- [['g1', 'g2', 'g3'], [], ['g1'], false],
- [['g1', 'g2', 'g3'], [], [], false],
- [['g1', 'g2', 'g3'], ['g2'], ['g1'], false],
- [['g1', 'g2', 'g3'], ['g2'], [], false],
- [['g1', 'g2', 'g3'], ['g1', 'g2'], ['g1'], false],
- [['g1', 'g2', 'g3'], ['g1', 'g2'], ['g1', 'g2'], true],
- [['g1', 'g2', 'g3'], ['g1', 'g2'], ['g1', 'g2', 'g3'], true],
- ];
- }
-
- /**
* Test default apps
*
* @dataProvider defaultAppsProvider