|
6 | 6 | from jwt.algorithms import Algorithm |
7 | 7 | from jwt.api_jws import PyJWS |
8 | 8 | from jwt.exceptions import ( |
9 | | - DecodeError, InvalidAlgorithmError |
| 9 | + DecodeError, InvalidAlgorithmError, InvalidTokenError |
10 | 10 | ) |
11 | 11 | from jwt.utils import base64url_decode |
12 | 12 |
|
@@ -381,7 +381,7 @@ def test_get_unverified_header_fails_on_bad_header_types(self, jws, payload): |
381 | 381 | '.eyJzdWIiOiIxMjM0NTY3ODkwIn0' |
382 | 382 | '.vs2WY54jfpKP3JGC73Vq5YlMsqM5oTZ1ZydT77SiZSk') |
383 | 383 |
|
384 | | - with pytest.raises(TypeError) as exc: |
| 384 | + with pytest.raises(InvalidTokenError) as exc: |
385 | 385 | jws.get_unverified_header(example_jws) |
386 | 386 |
|
387 | 387 | assert 'Key ID header parameter must be a string' == str(exc.value) |
@@ -611,12 +611,12 @@ def test_encode_headers_parameter_adds_headers(self, jws, payload): |
611 | 611 | assert header_obj['testheader'] == headers['testheader'] |
612 | 612 |
|
613 | 613 | def test_encode_fails_on_invalid_kid_types(self, jws, payload): |
614 | | - with pytest.raises(TypeError) as exc: |
| 614 | + with pytest.raises(InvalidTokenError) as exc: |
615 | 615 | jws.encode(payload, 'secret', headers={'kid': 123}) |
616 | 616 |
|
617 | 617 | assert 'Key ID header parameter must be a string' == str(exc.value) |
618 | 618 |
|
619 | | - with pytest.raises(TypeError) as exc: |
| 619 | + with pytest.raises(InvalidTokenError) as exc: |
620 | 620 | jws.encode(payload, 'secret', headers={'kid': None}) |
621 | 621 |
|
622 | 622 | assert 'Key ID header parameter must be a string' == str(exc.value) |
0 commit comments