diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-07-31 20:56:33 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-08-04 09:39:29 +0200 |
| commit | 985735265563d4bb0ff44cf6b823446e1813fa34 (patch) | |
| tree | 868c216cb98ead051b9e56fcaf49c862a3382127 /tests/auth_tests/test_middleware.py | |
| parent | acb7866b1fdda7592d9a16f0d0cc98f5d86a0a56 (diff) | |
[3.1.x] Fixed #31842 -- Added DEFAULT_HASHING_ALGORITHM transitional setting.
It's a transitional setting helpful in migrating multiple instance of
the same project to Django 3.1+.
Thanks Markus Holtermann for the report and review, Florian
Apolloner for the implementation idea and review, and Carlton Gibson
for the review.
Backport of d907371ef99a1e4ca6bc1660f57d81f265750984 from master.
Diffstat (limited to 'tests/auth_tests/test_middleware.py')
| -rw-r--r-- | tests/auth_tests/test_middleware.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/auth_tests/test_middleware.py b/tests/auth_tests/test_middleware.py index 5538225acb..f86f8c6b27 100644 --- a/tests/auth_tests/test_middleware.py +++ b/tests/auth_tests/test_middleware.py @@ -2,7 +2,9 @@ from django.contrib.auth import HASH_SESSION_KEY from django.contrib.auth.middleware import AuthenticationMiddleware from django.contrib.auth.models import User from django.http import HttpRequest, HttpResponse -from django.test import TestCase +from django.test import TestCase, override_settings +from django.test.utils import ignore_warnings +from django.utils.deprecation import RemovedInDjango40Warning class TestAuthenticationMiddleware(TestCase): @@ -29,6 +31,12 @@ class TestAuthenticationMiddleware(TestCase): self.assertIsNotNone(self.request.user) self.assertFalse(self.request.user.is_anonymous) + @ignore_warnings(category=RemovedInDjango40Warning) + def test_session_default_hashing_algorithm(self): + hash_session = self.client.session[HASH_SESSION_KEY] + with override_settings(DEFAULT_HASHING_ALGORITHM='sha1'): + self.assertNotEqual(hash_session, self.user.get_session_auth_hash()) + def test_changed_password_invalidates_session(self): # After password change, user should be anonymous self.user.set_password('new_password') |
