diff options
Diffstat (limited to 'tests/test_server.py')
| -rw-r--r-- | tests/test_server.py | 25 |
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""" |
| 27 | import json | ||
| 28 | |||
| 27 | import pytest | 29 | import pytest |
| 28 | 30 | ||
| 29 | import otp2289 | 31 | import 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 | |||
| 89 | def 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 | ||
