From 4b24b185f2594f7f67b949b486d47c7cee6d5515 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 3 Feb 2021 21:40:03 +0100 Subject: [PATCH] admin: fix context not being passed correctly to policy test view --- authentik/admin/views/policies.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/authentik/admin/views/policies.py b/authentik/admin/views/policies.py index 43499991d..a36c6b713 100644 --- a/authentik/admin/views/policies.py +++ b/authentik/admin/views/policies.py @@ -7,7 +7,6 @@ from django.contrib.auth.mixins import ( PermissionRequiredMixin as DjangoPermissionRequiredMixin, ) from django.contrib.messages.views import SuccessMessageMixin -from django.db.models import QuerySet from django.http import HttpResponse from django.urls import reverse_lazy from django.utils.translation import gettext as _ @@ -99,7 +98,7 @@ class PolicyTestView(LoginRequiredMixin, DetailView, PermissionRequiredMixin, Fo template_name = "administration/policy/test.html" object = None - def get_object(self, queryset=None) -> QuerySet: + def get_object(self, queryset=None) -> Policy: return ( Policy.objects.filter(pk=self.kwargs.get("pk")).select_subclasses().first() ) @@ -118,7 +117,7 @@ class PolicyTestView(LoginRequiredMixin, DetailView, PermissionRequiredMixin, Fo p_request = PolicyRequest(user) p_request.http_request = self.request - p_request.context = form.cleaned_data + p_request.context = form.cleaned_data.get("context", {}) proc = PolicyProcess(PolicyBinding(policy=policy), p_request, None) result = proc.execute()