summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_viewstate.py20
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