aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php')
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php b/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php
new file mode 100644
index 00000000000..f1d38c10801
--- /dev/null
+++ b/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+/**
+ * Created by PhpStorm.
+ * User: christoph
+ * Date: 11.10.18
+ * Time: 13:01
+ */
+
+namespace Tests\Authentication\TwoFactorAuth;
+
+use OC\Authentication\TwoFactorAuth\EnforcementState;
+use Test\TestCase;
+
+class EnforcementStateTest extends TestCase {
+ public function testIsEnforced(): void {
+ $state = new EnforcementState(true);
+
+ $this->assertTrue($state->isEnforced());
+ }
+
+ public function testGetEnforcedGroups(): void {
+ $state = new EnforcementState(true, ['twofactorers']);
+
+ $this->assertEquals(['twofactorers'], $state->getEnforcedGroups());
+ }
+
+ public function testGetExcludedGroups(): void {
+ $state = new EnforcementState(true, [], ['yoloers']);
+
+ $this->assertEquals(['yoloers'], $state->getExcludedGroups());
+ }
+
+ public function testJsonSerialize(): void {
+ $state = new EnforcementState(true, ['twofactorers'], ['yoloers']);
+ $expected = [
+ 'enforced' => true,
+ 'enforcedGroups' => ['twofactorers'],
+ 'excludedGroups' => ['yoloers'],
+ ];
+
+ $json = $state->jsonSerialize();
+
+ $this->assertEquals($expected, $json);
+ }
+}