summaryrefslogtreecommitdiff
path: root/tests/test_server.py
diff options
context:
space:
mode:
authorSimeon Simeonov2020-04-03 00:00:52 +0200
committerSimeon Simeonov2020-04-03 00:00:52 +0200
commit097aaa49fa99cffec9db74432d7025457c34199e (patch)
tree1af3ab2ec494b71610d299468c818f7ac144ce59 /tests/test_server.py
parent2a6299c32e0baf3df06f8e6d6bc8695b951d630d (diff)
Implement OTPStore container class in the server module
Diffstat (limited to 'tests/test_server.py')
-rw-r--r--tests/test_server.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_server.py b/tests/test_server.py
index c7cdb12..8d24cb8 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -24,6 +24,8 @@
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26"""Tests for otp2289.server""" 26"""Tests for otp2289.server"""
27import json
28
27import pytest 29import pytest
28 30
29import otp2289 31import otp2289
@@ -82,3 +84,26 @@ def test_state_validation_sha1():
82 assert state.response_validates('0xbb9e6ae1979d8ff4') is True 84 assert state.response_validates('0xbb9e6ae1979d8ff4') is True
83 assert state.response_validates('MILT VARY MAST OK SEES WENT') is True 85 assert state.response_validates('MILT VARY MAST OK SEES WENT') is True
84 assert state.validated is True 86 assert state.validated is True
87
88
89def test_store():
90 """Tests the OTPStore functionality"""
91 store_data = {'sgs': {'ot_hex': '0x7965e05436f5029f',
92 'current_step': 1,
93 'seed': 'TeSt',
94 'hash_algo': 'md5'},
95 'blackmore': {'ot_hex': '0x63d936639734385b',
96 'current_step': 1,
97 'seed': 'TeSt',
98 'hash_algo': 'sha1'}}
99 store = otp2289.OTPStore(store_data)
100 assert len(store) == 2
101 assert isinstance(json.dumps(store.to_dict()), str) # serializable?
102 assert store.response_validates('sgs', '0x9e876134d90499dd') is True
103 assert store.response_validates('sgs', '0x9e876134d90499dd') is False
104 sgs_state = store.get('sgs')
105 assert sgs_state in store
106 store.pop_state('sgs')
107 assert bool(store) is True
108 store.pop_state('blackmore')
109 assert bool(store) is False