From c7276a9cb97e8581faccb6c66a6a490e2d400c07 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 11 Jul 2023 10:46:34 +0200 Subject: [PATCH] Refs #34695 -- Added tests for check for CSRF_FAILURE_VIEW signature with valid class-based view. --- tests/check_framework/test_security.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/check_framework/test_security.py b/tests/check_framework/test_security.py index 3e20f35f01..b1839f48c3 100644 --- a/tests/check_framework/test_security.py +++ b/tests/check_framework/test_security.py @@ -4,6 +4,7 @@ from django.core.checks.security import base, csrf, sessions from django.core.management.utils import get_random_secret_key from django.test import SimpleTestCase from django.test.utils import override_settings +from django.views.generic import View class CheckSessionCookieSecureTest(SimpleTestCase): @@ -609,6 +610,9 @@ def failure_view_with_invalid_signature(): pass +good_class_based_csrf_failure_view = View.as_view() + + class CSRFFailureViewTest(SimpleTestCase): @override_settings(CSRF_FAILURE_VIEW="") def test_failure_view_import_error(self): @@ -638,6 +642,14 @@ class CSRFFailureViewTest(SimpleTestCase): [Error(msg, id="security.E101")], ) + @override_settings( + CSRF_FAILURE_VIEW=( + "check_framework.test_security.good_class_based_csrf_failure_view" + ), + ) + def test_failure_view_valid_class_based(self): + self.assertEqual(csrf.check_csrf_failure_view(None), []) + class CheckCrossOriginOpenerPolicyTest(SimpleTestCase): @override_settings(