summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-02-15 17:45:09 +0100
committerCarl Schwan <carl@carlschwan.eu>2022-07-05 17:05:09 +0200
commit3750160d9f820146100243c3e628e6b6a35b031d (patch)
tree0f4119adb08990f47e915669620e2eddde5bfc77 /tests/lib
parent14af5f3c26142abe5087308aff9f6e1d2ac80135 (diff)
downloadnextcloud-server-3750160d9f820146100243c3e628e6b6a35b031d.tar.gz
nextcloud-server-3750160d9f820146100243c3e628e6b6a35b031d.zip
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/lib')
-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'],
]);