Skip to content

Commit

Permalink
fix token length check, fixes #54
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Sep 4, 2017
1 parent 4839b51 commit 7d32628
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mirobo/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class Utils:
def verify_token(token: bytes):
if not isinstance(token, bytes):
raise TypeError("Token must be bytes")
if len(token) != 32:
raise ValueError("Token must be of length 32")
if len(token) != 16:
raise ValueError("Wrong token length")

@staticmethod
def md5(data: bytes) -> bytes:
Expand Down
4 changes: 2 additions & 2 deletions mirobo/tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_non_bytes_payload(self):

def test_encrypt(self):
payload = b"hello world"
token = 32 * b'0'
token = bytes.fromhex(32 * '0')

encrypted = Utils.encrypt(payload, token)
decrypted = Utils.decrypt(encrypted, token)
Expand All @@ -22,7 +22,7 @@ def test_encrypt(self):
def test_invalid_token(self):
payload = b"hello world"
wrong_type = 1234
wrong_length = 31 * b'0'
wrong_length = bytes.fromhex(16 * '0')
with self.assertRaises(TypeError):
Utils.encrypt(payload, wrong_type)
with self.assertRaises(TypeError):
Expand Down

0 comments on commit 7d32628

Please sign in to comment.