diff options
| author | Mauricio Aizaga <mauricioaizaga@gmail.com> | 2015-10-22 15:22:09 -0500 |
|---|---|---|
| committer | Mauricio Aizaga <mauricioaizaga@gmail.com> | 2015-10-22 15:22:09 -0500 |
| commit | 139dd05d1589ddcb4f8c9bd1b16b743ee4fcd2f6 (patch) | |
| tree | d9e168653ae3f364d558b571e7422ffab9bf8546 /tests | |
| parent | d3388831042051862f7fd8ba993bf814d341511d (diff) | |
| download | pyjwt-139dd05d1589ddcb4f8c9bd1b16b743ee4fcd2f6.tar.gz | |
Fixed #183 AttributeError: 'NoneType' object has no attribute 'rsplit'
The issue also occurs when payload is int raising:
AttributeError: 'int' object has no attribute 'rsplit'
Test for None and int payload added
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_api_jws.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_api_jws.py b/tests/test_api_jws.py index 2079bef..c08d3e4 100644 --- a/tests/test_api_jws.py +++ b/tests/test_api_jws.py @@ -122,6 +122,24 @@ class TestJWS: exception = context.value assert str(exception) == 'Not enough segments' + def test_decode_invalid_payload_type_is_none(self, jws): + example_jws = None + example_secret = 'secret' + + with pytest.raises(DecodeError) as context: + jws.decode(example_jws, example_secret) + + assert 'Invalid payload type' in str(context.value) + + def test_decode_invalid_payload_type_is_int(self, jws): + example_jws = 123 + example_secret = 'secret' + + with pytest.raises(DecodeError) as context: + jws.decode(example_jws, example_secret) + + assert 'Invalid payload type' in str(context.value) + def test_decode_with_non_mapping_header_throws_exception(self, jws): secret = 'secret' example_jws = ('MQ' # == 1 |
