-
-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/mdns-device-map
- Loading branch information
Showing
14 changed files
with
90 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
sudo: false | ||
language: python | ||
python: | ||
- "3.4" | ||
- "3.5" | ||
- "3.6" | ||
install: pip install tox-travis | ||
script: tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from unittest import TestCase | ||
from .. import Message, Utils | ||
|
||
|
||
class TestProtocol(TestCase): | ||
def test_non_bytes_payload(self): | ||
payload = "hello world" | ||
valid_token = 32 * b'0' | ||
with self.assertRaises(TypeError): | ||
Utils.encrypt(payload, valid_token) | ||
with self.assertRaises(TypeError): | ||
Utils.decrypt(payload, valid_token) | ||
|
||
def test_encrypt(self): | ||
payload = b"hello world" | ||
token = 32 * b'0' | ||
|
||
encrypted = Utils.encrypt(payload, token) | ||
decrypted = Utils.decrypt(encrypted, token) | ||
self.assertEquals(payload, decrypted) | ||
|
||
def test_invalid_token(self): | ||
payload = b"hello world" | ||
wrong_type = 1234 | ||
wrong_length = 31 * b'0' | ||
with self.assertRaises(TypeError): | ||
Utils.encrypt(payload, wrong_type) | ||
with self.assertRaises(TypeError): | ||
Utils.decrypt(payload, wrong_type) | ||
|
||
with self.assertRaises(ValueError): | ||
Utils.encrypt(payload, wrong_length) | ||
with self.assertRaises(ValueError): | ||
Utils.decrypt(payload, wrong_length) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters