Skip to content

Commit

Permalink
Also catch potential changes in hash_token
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsmkn committed Aug 2, 2024
1 parent 3ba5aa5 commit 2409c3a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,16 @@ 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 = (
"c7f9f2904decf77e0fa0341bc3eb96daa1437649825f4bfdd38cdad64d69c4be55938d71f17"
"34131c656f9bbbfc5d991bef295accd268921b23d9cdd0d9d60d0"
)

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()
Expand Down

0 comments on commit 2409c3a

Please sign in to comment.