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:
authorCarl Schwan <carl@carlschwan.eu>2022-02-15 19:45:09 +0300
committernextcloud-command <nextcloud-command@users.noreply.github.com>2022-04-05 20:04:17 +0300
commita29251e02df0157741afaddbc202617e6eb1c840 (patch)
treee6f45cc8f5f69d3358cac3f0b50c058a5cfcb1a3 /tests
parenta99fdf5600c9e4be23b4adb153c33298650e3fc1 (diff)
Allow to disable password policy enforcement for selected groups
Signed-off-by: Carl Schwan <carl@carlschwan.eu> Co-authored-by: Vincent Petry <vincent@nextcloud.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Share20/ManagerTest.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 93f33fe30b9..a5db95638f8 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -505,14 +505,46 @@ class ManagerTest extends \Test\TestCase {
$this->expectExceptionMessage('Passwords are enforced for link and mail shares');
$this->config->method('getAppValue')->willReturnMap([
+ ['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
['core', 'shareapi_enforce_links_password', 'no', 'yes'],
]);
self::invokePrivate($this->manager, 'verifyPassword', [null]);
}
+ public function testVerifyPasswordNotEnforcedGroup() {
+ $this->config->method('getAppValue')->willReturnMap([
+ ['core', 'shareapi_enforce_links_password_excluded_groups', '', '["admin"]'],
+ ['core', 'shareapi_enforce_links_password', 'no', 'yes'],
+ ]);
+
+ // Create admin user
+ $user = $this->createMock(IUser::class);
+ $this->userSession->method('getUser')->willReturn($user);
+ $this->groupManager->method('getUserGroupIds')->with($user)->willReturn(['admin']);
+
+ $result = self::invokePrivate($this->manager, 'verifyPassword', [null]);
+ $this->assertNull($result);
+ }
+
+ public function testVerifyPasswordNotEnforcedMultipleGroups() {
+ $this->config->method('getAppValue')->willReturnMap([
+ ['core', 'shareapi_enforce_links_password_excluded_groups', '', '["admin", "special"]'],
+ ['core', 'shareapi_enforce_links_password', 'no', 'yes'],
+ ]);
+
+ // Create admin user
+ $user = $this->createMock(IUser::class);
+ $this->userSession->method('getUser')->willReturn($user);
+ $this->groupManager->method('getUserGroupIds')->with($user)->willReturn(['special']);
+
+ $result = self::invokePrivate($this->manager, 'verifyPassword', [null]);
+ $this->assertNull($result);
+ }
+
public function testVerifyPasswordNull() {
$this->config->method('getAppValue')->willReturnMap([
+ ['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
['core', 'shareapi_enforce_links_password', 'no', 'no'],
]);
@@ -522,6 +554,7 @@ class ManagerTest extends \Test\TestCase {
public function testVerifyPasswordHook() {
$this->config->method('getAppValue')->willReturnMap([
+ ['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
['core', 'shareapi_enforce_links_password', 'no', 'no'],
]);
@@ -543,6 +576,7 @@ class ManagerTest extends \Test\TestCase {
$this->expectExceptionMessage('password not accepted');
$this->config->method('getAppValue')->willReturnMap([
+ ['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
['core', 'shareapi_enforce_links_password', 'no', 'no'],
]);