Skip to content

Commit fca6d7e

Browse files
committed
Fixed constant time compare tests so that they always use bytes as input.
1 parent b6de2fd commit fca6d7e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tests/test_compat.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
from jwt.compat import constant_time_compare
22

33
from .compat import unittest
4+
from .utils import ensure_bytes
45

56

67
class TestCompat(unittest.TestCase):
78
def setUp(self): # noqa
89
pass
910

1011
def test_constant_time_compare_returns_true_if_same(self):
11-
self.assertTrue(constant_time_compare('abc', 'abc'))
12+
self.assertTrue(constant_time_compare(
13+
ensure_bytes('abc'), ensure_bytes('abc')
14+
))
1215

1316
def test_constant_time_compare_returns_false_if_diff_lengths(self):
14-
self.assertFalse(constant_time_compare('abc', 'abcd'))
17+
self.assertFalse(constant_time_compare(
18+
ensure_bytes('abc'), ensure_bytes('abcd')
19+
))
1520

1621
def test_constant_time_compare_returns_false_if_totally_different(self):
17-
self.assertFalse(constant_time_compare('abcd', 'efgh'))
22+
self.assertFalse(constant_time_compare(
23+
ensure_bytes('abcd'), ensure_bytes('efgh')
24+
))

0 commit comments

Comments
 (0)