This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/authentik/policies/dummy/tests.py
Jens Langhammer 77ed25ae34 root: reformat to 100 line width
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
2021-08-03 17:45:16 +02:00

22 lines
687 B
Python

"""dummy policy tests"""
from django.test import TestCase
from guardian.shortcuts import get_anonymous_user
from authentik.policies.dummy.models import DummyPolicy
from authentik.policies.engine import PolicyRequest
class TestDummyPolicy(TestCase):
"""Test dummy policy"""
def setUp(self):
super().setUp()
self.request = PolicyRequest(user=get_anonymous_user())
def test_policy(self):
"""test policy .passes"""
policy: DummyPolicy = DummyPolicy.objects.create(name="dummy", wait_min=1, wait_max=2)
result = policy.passes(self.request)
self.assertFalse(result.passing)
self.assertEqual(result.messages, ("dummy",))