|
@@ -2,9 +2,8 @@ import datetime
|
|
|
|
|
|
from django.core import signing
|
|
|
from django.test import SimpleTestCase
|
|
|
-from django.test.utils import freeze_time, ignore_warnings
|
|
|
+from django.test.utils import freeze_time
|
|
|
from django.utils.crypto import InvalidAlgorithm
|
|
|
-from django.utils.deprecation import RemovedInDjango40Warning
|
|
|
|
|
|
|
|
|
class TestSigner(SimpleTestCase):
|
|
@@ -53,14 +52,6 @@ class TestSigner(SimpleTestCase):
|
|
|
'VzO9_jVu7R-VkqknHYNvw',
|
|
|
)
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango40Warning)
|
|
|
- def test_default_hashing_algorithm(self):
|
|
|
- signer = signing.Signer('predictable-secret', algorithm='sha1')
|
|
|
- signature_sha1 = signer.signature('hello')
|
|
|
- with self.settings(DEFAULT_HASHING_ALGORITHM='sha1'):
|
|
|
- signer = signing.Signer('predictable-secret')
|
|
|
- self.assertEqual(signer.signature('hello'), signature_sha1)
|
|
|
-
|
|
|
def test_invalid_algorithm(self):
|
|
|
signer = signing.Signer('predictable-secret', algorithm='whatever')
|
|
|
msg = "'whatever' is not an algorithm accepted by the hashlib module."
|
|
@@ -143,13 +134,6 @@ class TestSigner(SimpleTestCase):
|
|
|
self.assertNotEqual(o, signing.dumps(o, compress=True))
|
|
|
self.assertEqual(o, signing.loads(signing.dumps(o, compress=True)))
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango40Warning)
|
|
|
- def test_dumps_loads_default_hashing_algorithm_sha1(self):
|
|
|
- value = 'a string \u2020'
|
|
|
- with self.settings(DEFAULT_HASHING_ALGORITHM='sha1'):
|
|
|
- signed = signing.dumps(value)
|
|
|
- self.assertEqual(signing.loads(signed), value)
|
|
|
-
|
|
|
def test_decode_detects_tampering(self):
|
|
|
"loads should raise exception for tampered objects"
|
|
|
transforms = (
|