From 7ff7398aff1fd9e01c474bf4345cb83112ec5b48 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 13 Dec 2020 18:06:34 +0100 Subject: [PATCH] admin: add tests for binding creation forms with invalid target --- authentik/admin/tests/test_policy_binding.py | 9 ++++++++- authentik/admin/tests/test_stage_bindings.py | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/authentik/admin/tests/test_policy_binding.py b/authentik/admin/tests/test_policy_binding.py index 5a964bf81..fc508d446 100644 --- a/authentik/admin/tests/test_policy_binding.py +++ b/authentik/admin/tests/test_policy_binding.py @@ -1,4 +1,5 @@ """admin tests""" +from uuid import uuid4 from django.test import TestCase from django.test.client import RequestFactory @@ -18,7 +19,13 @@ class TestPolicyBindingView(TestCase): view = PolicyBindingCreateView(request=request) self.assertEqual(view.get_initial(), {}) - def test_with_param(self): + def test_with_params_invalid(self): + """Test PolicyBindingCreateView with invalid get params""" + request = self.factory.get("/", {"target": uuid4()}) + view = PolicyBindingCreateView(request=request) + self.assertEqual(view.get_initial(), {}) + + def test_with_params(self): """Test PolicyBindingCreateView with get params""" target = Application.objects.create(name="test") request = self.factory.get("/", {"target": target.pk.hex}) diff --git a/authentik/admin/tests/test_stage_bindings.py b/authentik/admin/tests/test_stage_bindings.py index 169048e4f..0bf0b0b14 100644 --- a/authentik/admin/tests/test_stage_bindings.py +++ b/authentik/admin/tests/test_stage_bindings.py @@ -1,4 +1,5 @@ """admin tests""" +from uuid import uuid4 from django.test import TestCase from django.test.client import RequestFactory @@ -18,7 +19,13 @@ class TestStageBindingView(TestCase): view = StageBindingCreateView(request=request) self.assertEqual(view.get_initial(), {}) - def test_with_param(self): + def test_with_params_invalid(self): + """Test StageBindingCreateView with invalid get params""" + request = self.factory.get("/", {"target": uuid4()}) + view = StageBindingCreateView(request=request) + self.assertEqual(view.get_initial(), {}) + + def test_with_params(self): """Test StageBindingCreateView with get params""" target = Flow.objects.create(name="test", slug="test") request = self.factory.get("/", {"target": target.pk.hex})