EnforcementStateTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. /**
  7. * Created by PhpStorm.
  8. * User: christoph
  9. * Date: 11.10.18
  10. * Time: 13:01
  11. */
  12. namespace Tests\Authentication\TwoFactorAuth;
  13. use OC\Authentication\TwoFactorAuth\EnforcementState;
  14. use Test\TestCase;
  15. class EnforcementStateTest extends TestCase {
  16. public function testIsEnforced(): void {
  17. $state = new EnforcementState(true);
  18. $this->assertTrue($state->isEnforced());
  19. }
  20. public function testGetEnforcedGroups(): void {
  21. $state = new EnforcementState(true, ['twofactorers']);
  22. $this->assertEquals(['twofactorers'], $state->getEnforcedGroups());
  23. }
  24. public function testGetExcludedGroups(): void {
  25. $state = new EnforcementState(true, [], ['yoloers']);
  26. $this->assertEquals(['yoloers'], $state->getExcludedGroups());
  27. }
  28. public function testJsonSerialize(): void {
  29. $state = new EnforcementState(true, ['twofactorers'], ['yoloers']);
  30. $expected = [
  31. 'enforced' => true,
  32. 'enforcedGroups' => ['twofactorers'],
  33. 'excludedGroups' => ['yoloers'],
  34. ];
  35. $json = $state->jsonSerialize();
  36. $this->assertEquals($expected, $json);
  37. }
  38. }