mirror of
https://github.com/ChristianLight/tutor.git
synced 2025-01-25 22:18:24 +00:00
fix: minor edge case in long_to_base64
utility function.
This was detected by mypy.
This commit is contained in:
parent
59e368a449
commit
de872282b2
@ -4,6 +4,8 @@ Note: Breaking changes between versions are indicated by "💥".
|
||||
|
||||
## Unreleased
|
||||
|
||||
- [Bugfix] Fix minor edge case in `long_to_base64` utility function.
|
||||
|
||||
## v11.2.3 (2021-02-20)
|
||||
|
||||
- [Bugfix] Make LMS celery workers actually process LMS tasks, and not CMS tasks.
|
||||
|
@ -1,3 +1,4 @@
|
||||
import base64
|
||||
import unittest
|
||||
|
||||
from tutor import utils
|
||||
@ -30,3 +31,6 @@ class UtilsTests(unittest.TestCase):
|
||||
self.assertNotEqual(encrypted1, encrypted2)
|
||||
self.assertTrue(utils.verify_encrypted(encrypted1, password))
|
||||
self.assertTrue(utils.verify_encrypted(encrypted2, password))
|
||||
|
||||
def test_long_to_base64(self):
|
||||
self.assertEqual(b"\x00", base64.urlsafe_b64decode(utils.long_to_base64(0) + "=="))
|
||||
|
@ -112,7 +112,7 @@ def long_to_base64(n):
|
||||
bys = long2intarr(n)
|
||||
data = struct.pack("%sB" % len(bys), *bys)
|
||||
if not data:
|
||||
data = "\x00"
|
||||
data = b"\x00"
|
||||
s = base64.urlsafe_b64encode(data).rstrip(b"=")
|
||||
return s.decode("ascii")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user