From fe77acb5e4dc7c37142bb89a64626bfa1153e9a1 Mon Sep 17 00:00:00 2001 From: James Meakin <12661555+jmsmkn@users.noreply.github.com> Date: Fri, 2 Aug 2024 12:37:52 +0200 Subject: [PATCH] Also catch potential changes in hash_token --- tests/tests.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/tests.py b/tests/tests.py index d09dbf4..d4f2933 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -501,10 +501,13 @@ def test_old_tokens_still_work(self): self.assertEqual(AuthToken.objects.count(), 0) old_token = "02d233c901e7bd38df1dbc486b7e22c5c81b089c40cbb31d35d7b032615f5778" + # Hash generated using crypto.hash_token on 4.2.0 with + # SECURE_HASH_ALGORITHM = 'cryptography.hazmat.primitives.hashes.SHA512' + old_hash = "c7f9f2904decf77e0fa0341bc3eb96daa1437649825f4bfdd38cdad64d69c4be55938d71f1734131c656f9bbbfc5d991bef295accd268921b23d9cdd0d9d60d0" AuthToken( token_key=old_token[: 8], # 8 was the key length prior to 3a1bc58 - digest=crypto.hash_token(old_token), + digest=old_hash, user=self.user, expiry=None, ).save()