summaryrefslogtreecommitdiff
path: root/tests/messages_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-07-31 20:56:33 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-08-04 09:35:24 +0200
commitd907371ef99a1e4ca6bc1660f57d81f265750984 (patch)
treec71660e797eba97a3a6a6fa48ebc3f1bfa64441b /tests/messages_tests
parentbce4a53670668d6fd1e34685197151c17fd1b378 (diff)
downloaddjango-d907371ef99a1e4ca6bc1660f57d81f265750984.tar.gz
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.
Diffstat (limited to 'tests/messages_tests')
-rw-r--r--tests/messages_tests/test_cookie.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/messages_tests/test_cookie.py b/tests/messages_tests/test_cookie.py
index f1428fdf32..5d5fb42d67 100644
--- a/tests/messages_tests/test_cookie.py
+++ b/tests/messages_tests/test_cookie.py
@@ -7,6 +7,8 @@ from django.contrib.messages.storage.cookie import (
CookieStorage, MessageDecoder, MessageEncoder,
)
from django.test import SimpleTestCase, override_settings
+from django.test.utils import ignore_warnings
+from django.utils.deprecation import RemovedInDjango40Warning
from django.utils.safestring import SafeData, mark_safe
from .base import BaseTests
@@ -169,3 +171,14 @@ class CookieTests(BaseTests, SimpleTestCase):
encoded_messages = '%s$%s' % (storage._legacy_hash(value), value)
decoded_messages = storage._decode(encoded_messages)
self.assertEqual(messages, decoded_messages)
+
+ @ignore_warnings(category=RemovedInDjango40Warning)
+ def test_default_hashing_algorithm(self):
+ messages = Message(constants.DEBUG, ['this', 'that'])
+ with self.settings(DEFAULT_HASHING_ALGORITHM='sha1'):
+ storage = self.get_storage()
+ encoded = storage._encode(messages)
+ decoded = storage._decode(encoded)
+ self.assertEqual(decoded, messages)
+ storage_default = self.get_storage()
+ self.assertNotEqual(encoded, storage_default._encode(messages))