summaryrefslogtreecommitdiff
path: root/tests/test_compat.py
blob: 10beb94e98eade865dc1a805ab56c4818b645bbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from jwt.compat import constant_time_compare
from jwt.utils import force_bytes


class TestCompat:
    def test_constant_time_compare_returns_true_if_same(self):
        assert constant_time_compare(
            force_bytes('abc'), force_bytes('abc')
        )

    def test_constant_time_compare_returns_false_if_diff_lengths(self):
        assert not constant_time_compare(
            force_bytes('abc'), force_bytes('abcd')
        )

    def test_constant_time_compare_returns_false_if_totally_different(self):
        assert not constant_time_compare(
            force_bytes('abcd'), force_bytes('efgh')
        )