summaryrefslogtreecommitdiff
path: root/tests/utils_tests
diff options
context:
space:
mode:
authorSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-08-26 13:37:34 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-08-27 10:50:50 +0200
commitd0e4dd5cdd743a5c43c4ccc2c8fa29d3982eaa71 (patch)
treeed64921a0f27e8df1b5ce69b729d34dfbfc9d815 /tests/utils_tests
parentc594574175e379fff356e274893d797f6e6a95fa (diff)
Fixed #36572 -- Revert "Fixed #36546 -- Deprecated django.utils.crypto.constant_time_compare() in favor of hmac.compare_digest()."
This reverts commit 0246f478882c26bc1fe293224653074cd46a90d0.
Diffstat (limited to 'tests/utils_tests')
-rw-r--r--tests/utils_tests/test_crypto.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/tests/utils_tests/test_crypto.py b/tests/utils_tests/test_crypto.py
index bbedb3080d..6fb4bfa453 100644
--- a/tests/utils_tests/test_crypto.py
+++ b/tests/utils_tests/test_crypto.py
@@ -2,34 +2,25 @@ import hashlib
import unittest
from django.test import SimpleTestCase
-from django.test.utils import ignore_warnings
from django.utils.crypto import (
InvalidAlgorithm,
constant_time_compare,
pbkdf2,
salted_hmac,
)
-from django.utils.deprecation import RemovedInDjango70Warning
class TestUtilsCryptoMisc(SimpleTestCase):
- # RemovedInDjango70Warning.
- @ignore_warnings(category=RemovedInDjango70Warning)
def test_constant_time_compare(self):
# It's hard to test for constant time, just test the result.
self.assertTrue(constant_time_compare(b"spam", b"spam"))
self.assertFalse(constant_time_compare(b"spam", b"eggs"))
self.assertTrue(constant_time_compare("spam", "spam"))
self.assertFalse(constant_time_compare("spam", "eggs"))
-
- def test_constant_time_compare_deprecated(self):
- msg = (
- "constant_time_compare() is deprecated. "
- "Use hmac.compare_digest() instead."
- )
- with self.assertWarnsMessage(RemovedInDjango70Warning, msg) as ctx:
- constant_time_compare(b"spam", b"spam")
- self.assertEqual(ctx.filename, __file__)
+ self.assertTrue(constant_time_compare(b"spam", "spam"))
+ self.assertFalse(constant_time_compare("spam", b"eggs"))
+ self.assertTrue(constant_time_compare("ありがとう", "ありがとう"))
+ self.assertFalse(constant_time_compare("ありがとう", "おはよう"))
def test_salted_hmac(self):
tests = [