policies: ensure binding has a target during unittests

This commit is contained in:
Jens Langhammer 2021-01-05 12:37:52 +01:00
parent cab2942c4e
commit 4743e72e18
1 changed files with 4 additions and 2 deletions

View File

@ -2,7 +2,7 @@
from django.core.cache import cache
from django.test import TestCase
from authentik.core.models import User
from authentik.core.models import Application, User
from authentik.events.models import Event, EventAction
from authentik.policies.dummy.models import DummyPolicy
from authentik.policies.expression.models import ExpressionPolicy
@ -75,7 +75,9 @@ class TestPolicyProcess(TestCase):
policy = DummyPolicy.objects.create(
result=False, wait_min=0, wait_max=1, execution_logging=True
)
binding = PolicyBinding(policy=policy)
binding = PolicyBinding(
policy=policy, target=Application.objects.create(name="test")
)
request = PolicyRequest(self.user)
response = PolicyProcess(binding, request, None).execute()