diff options
Diffstat (limited to 'tests/check_framework/test_security.py')
-rw-r--r-- | tests/check_framework/test_security.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/check_framework/test_security.py b/tests/check_framework/test_security.py index 8225b99995..9bf9bb2a0a 100644 --- a/tests/check_framework/test_security.py +++ b/tests/check_framework/test_security.py @@ -1,4 +1,5 @@ from django.conf import settings +from django.core.checks.messages import Error from django.core.checks.security import base, csrf, sessions from django.core.management.utils import get_random_secret_key from django.test import SimpleTestCase @@ -471,3 +472,35 @@ class CheckReferrerPolicyTest(SimpleTestCase): ) def test_with_invalid_referrer_policy(self): self.assertEqual(base.check_referrer_policy(None), [base.E023]) + + +def failure_view_with_invalid_signature(): + pass + + +class CSRFFailureViewTest(SimpleTestCase): + @override_settings(CSRF_FAILURE_VIEW='') + def test_failure_view_import_error(self): + self.assertEqual( + csrf.check_csrf_failure_view(None), + [ + Error( + "The CSRF failure view '' could not be imported.", + id='security.E025', + ) + ], + ) + + @override_settings( + CSRF_FAILURE_VIEW=f'{__name__}.failure_view_with_invalid_signature', + ) + def test_failure_view_invalid_signature(self): + msg = ( + "The CSRF failure view " + "'check_framework.test_security.failure_view_with_invalid_signature' " + "does not take the correct number of arguments." + ) + self.assertEqual( + csrf.check_csrf_failure_view(None), + [Error(msg, id='security.E024')], + ) |