summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2018-03-19 11:58:49 +0200
committerYuval Adam <_@yuv.al>2018-03-19 11:58:49 +0200
commitba0b06637bcec3a01d8e6a11884fbad1a0f5d612 (patch)
tree39f86c393722ba56fa497493fa59acb8888514b9 /tests
parent46901c04955ea94c746ae96d09734143af63c51d (diff)
Add support for HMAC signatures, fixes #4
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