-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
27 additions
and
30 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from six.moves.configparser import ConfigParser | ||
from configparser import ConfigParser | ||
from textwrap import dedent | ||
from unittest.mock import Mock | ||
from zeyple import zeyple | ||
|
@@ -22,6 +22,7 @@ | |
TEST_EXPIRED_ID = 'ED97E21F1C7F1AC6' | ||
TEST_EXPIRED_EMAIL = '[email protected]' | ||
|
||
|
||
class ZeypleTest(unittest.TestCase): | ||
def setUp(self): | ||
self.tmpdir = tempfile.mkdtemp() | ||
|
@@ -71,18 +72,19 @@ def assertValidMimeMessage(self, cipher_message, mime_message): | |
|
||
plain_payload = cipher_message.get_payload() | ||
encrypted_envelope = plain_payload[1] | ||
assert encrypted_envelope["Content-Type"] == 'application/octet-stream; name="encrypted.asc"' | ||
assert (encrypted_envelope["Content-Type"] == | ||
'application/octet-stream; name="encrypted.asc"') | ||
|
||
encrypted_payload = encrypted_envelope.get_payload().encode('utf-8') | ||
decrypted_envelope = self.decrypt(encrypted_payload).decode('utf-8').strip() | ||
|
||
boundary = re.match(r'.+boundary="([^"]+)"', decrypted_envelope, re.MULTILINE | re.DOTALL).group(1) | ||
boundary = re.match(r'.+boundary="([^"]+)"', | ||
decrypted_envelope, re.MULTILINE | re.DOTALL).group(1) | ||
# replace auto-generated boundary with one we know | ||
mime_message = mime_message.replace("BOUNDARY", boundary) | ||
|
||
prefix = dedent("""\ | ||
Content-Type: multipart/mixed; boundary=\"""" + \ | ||
boundary + """\" | ||
Content-Type: multipart/mixed; boundary=\"""" + boundary + """\" | ||
""") | ||
mime_message = prefix + mime_message | ||
|
@@ -237,7 +239,7 @@ def test_process_message_with_complex_message(self): | |
with open(filename, 'r') as test_file: | ||
contents = test_file.read() | ||
|
||
self.zeyple.process_message(contents, [TEST1_EMAIL]) # should not raise | ||
self.zeyple.process_message(contents, [TEST1_EMAIL]) # should not raise | ||
|
||
def test_force_encryption(self): | ||
"""Tries to encrypt without key""" | ||
|
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