diff options
| author | Yuval Adam <_@yuv.al> | 2018-03-19 11:58:49 +0200 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2018-03-19 11:58:49 +0200 |
| commit | ba0b06637bcec3a01d8e6a11884fbad1a0f5d612 (patch) | |
| tree | 39f86c393722ba56fa497493fa59acb8888514b9 /tests | |
| parent | 46901c04955ea94c746ae96d09734143af63c51d (diff) | |
Add support for HMAC signatures, fixes #4
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_viewstate.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_viewstate.py b/tests/test_viewstate.py index ca20167..9cc9285 100644 --- a/tests/test_viewstate.py +++ b/tests/test_viewstate.py @@ -26,3 +26,23 @@ class TestViewState(object): with pytest.raises(ViewStateException): vs = ViewState(raw=b'\x01\x02') vs.decode() + + def test_no_signature(self): + vs = ViewState(raw=b'\xff\x01e') + vs.decode() + assert vs.mac is None + assert vs.signature is None + + def test_macs(self): + MAC_LENGTHS = { + 'hmac_sha1': 20, + 'hmac_sha256': 32, + 'unknown': 5 # could be any other value + } + + for mac, n in MAC_LENGTHS.items(): + sig = b'\x55' * n # not a real signature, just testing length + vs = ViewState(raw=b'\xff\x01d' + sig) + vs.decode() + assert vs.mac == mac + assert vs.signature == sig |
