summaryrefslogtreecommitdiff
path: root/src/leap/mail/smtp
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2013-12-06 17:45:21 -0400
committerKali Kaneko <kali@leap.se>2013-12-06 17:45:21 -0400
commit541bd8aec1f67834c42bc2e5df14c1f73c569082 (patch)
tree809e096502a98ca64e85ecebfa86fc8ef9c7ba80 /src/leap/mail/smtp
parent55ec42e4ba92642dac93dc70ee64cd695478d57f (diff)
pep8 cleanup
Diffstat (limited to 'src/leap/mail/smtp')
-rw-r--r--src/leap/mail/smtp/__init__.py6
-rw-r--r--src/leap/mail/smtp/rfc3156.py2
-rw-r--r--src/leap/mail/smtp/tests/test_gateway.py45
3 files changed, 35 insertions, 18 deletions
diff --git a/src/leap/mail/smtp/__init__.py b/src/leap/mail/smtp/__init__.py
index d3eb9e8..bbd4064 100644
--- a/src/leap/mail/smtp/__init__.py
+++ b/src/leap/mail/smtp/__init__.py
@@ -30,7 +30,7 @@ from leap.mail.smtp.gateway import SMTPFactory
def setup_smtp_gateway(port, userid, keymanager, smtp_host, smtp_port,
- smtp_cert, smtp_key, encrypted_only):
+ smtp_cert, smtp_key, encrypted_only):
"""
Setup SMTP gateway to run with Twisted.
@@ -52,8 +52,8 @@ def setup_smtp_gateway(port, userid, keymanager, smtp_host, smtp_port,
:type smtp_cert: str
:param smtp_key: The client key for authentication.
:type smtp_key: str
- :param encrypted_only: Whether the SMTP gateway should send unencrypted mail
- or not.
+ :param encrypted_only: Whether the SMTP gateway should send unencrypted
+ mail or not.
:type encrypted_only: bool
:returns: tuple of SMTPFactory, twisted.internet.tcp.Port
diff --git a/src/leap/mail/smtp/rfc3156.py b/src/leap/mail/smtp/rfc3156.py
index dd48475..b0288b4 100644
--- a/src/leap/mail/smtp/rfc3156.py
+++ b/src/leap/mail/smtp/rfc3156.py
@@ -361,7 +361,7 @@ class PGPSignature(MIMEApplication):
"""
def __init__(self, _data, name='signature.asc'):
MIMEApplication.__init__(self, _data, 'pgp-signature',
- _encoder=lambda x: x, name=name)
+ encoder=lambda x: x, name=name)
self.add_header('Content-Description', 'OpenPGP Digital Signature')
diff --git a/src/leap/mail/smtp/tests/test_gateway.py b/src/leap/mail/smtp/tests/test_gateway.py
index 4c2f04f..5b15b5b 100644
--- a/src/leap/mail/smtp/tests/test_gateway.py
+++ b/src/leap/mail/smtp/tests/test_gateway.py
@@ -101,10 +101,16 @@ class TestSmtpGateway(TestCaseWithKeyManager):
'250 Sender address accepted',
'250 Recipient address accepted',
'354 Continue']
- proto = SMTPFactory(u'anotheruser@leap.se',
- self._km, self._config['host'], self._config['port'],
+
+ # XXX this bit can be refactored away in a helper
+ # method...
+ proto = SMTPFactory(
+ u'anotheruser@leap.se',
+ self._km, self._config['host'],
+ self._config['port'],
self._config['cert'], self._config['key'],
self._config['encrypted_only']).buildProtocol(('127.0.0.1', 0))
+ # snip...
transport = proto_helpers.StringTransport()
proto.makeConnection(transport)
for i, line in enumerate(self.EMAIL_DATA):
@@ -118,8 +124,10 @@ class TestSmtpGateway(TestCaseWithKeyManager):
"""
Test if message gets encrypted to destination email.
"""
- proto = SMTPFactory(u'anotheruser@leap.se',
- self._km, self._config['host'], self._config['port'],
+ proto = SMTPFactory(
+ u'anotheruser@leap.se',
+ self._km, self._config['host'],
+ self._config['port'],
self._config['cert'], self._config['key'],
self._config['encrypted_only']).buildProtocol(('127.0.0.1', 0))
fromAddr = Address(ADDRESS_2)
@@ -158,8 +166,10 @@ class TestSmtpGateway(TestCaseWithKeyManager):
Test if message gets encrypted to destination email and signed with
sender key.
"""
- proto = SMTPFactory(u'anotheruser@leap.se',
- self._km, self._config['host'], self._config['port'],
+ proto = SMTPFactory(
+ u'anotheruser@leap.se',
+ self._km, self._config['host'],
+ self._config['port'],
self._config['cert'], self._config['key'],
self._config['encrypted_only']).buildProtocol(('127.0.0.1', 0))
user = User(ADDRESS, 'gateway.leap.se', proto, ADDRESS)
@@ -202,11 +212,14 @@ class TestSmtpGateway(TestCaseWithKeyManager):
"""
# mock the key fetching
self._km.fetch_keys_from_server = Mock(return_value=[])
- proto = SMTPFactory(u'anotheruser@leap.se',
- self._km, self._config['host'], self._config['port'],
+ proto = SMTPFactory(
+ u'anotheruser@leap.se',
+ self._km, self._config['host'],
+ self._config['port'],
self._config['cert'], self._config['key'],
self._config['encrypted_only']).buildProtocol(('127.0.0.1', 0))
- user = User('ihavenopubkey@nonleap.se', 'gateway.leap.se', proto, ADDRESS)
+ user = User('ihavenopubkey@nonleap.se',
+ 'gateway.leap.se', proto, ADDRESS)
fromAddr = Address(ADDRESS_2)
m = EncryptedMessage(
fromAddr, user, self._km, self._config['host'],
@@ -226,7 +239,7 @@ class TestSmtpGateway(TestCaseWithKeyManager):
self.assertEqual('pgp-sha512', m._msg.get_param('micalg'))
# assert content of message
self.assertEqual(
- '\r\n'.join(self.EMAIL_DATA[9:13])+'\r\n--\r\n' +
+ '\r\n'.join(self.EMAIL_DATA[9:13]) + '\r\n--\r\n' +
'I prefer encrypted email - https://leap.se/key/anotheruser.\r\n',
m._msg.get_payload(0).get_payload(decode=True))
# assert content of signature
@@ -262,8 +275,10 @@ class TestSmtpGateway(TestCaseWithKeyManager):
# mock the key fetching
self._km.fetch_keys_from_server = Mock(return_value=[])
# prepare the SMTP factory
- proto = SMTPFactory(u'anotheruser@leap.se',
- self._km, self._config['host'], self._config['port'],
+ proto = SMTPFactory(
+ u'anotheruser@leap.se',
+ self._km, self._config['host'],
+ self._config['port'],
self._config['cert'], self._config['key'],
self._config['encrypted_only']).buildProtocol(('127.0.0.1', 0))
transport = proto_helpers.StringTransport()
@@ -291,8 +306,10 @@ class TestSmtpGateway(TestCaseWithKeyManager):
# mock the key fetching
self._km.fetch_keys_from_server = Mock(return_value=[])
# prepare the SMTP factory with encrypted only equal to false
- proto = SMTPFactory(u'anotheruser@leap.se',
- self._km, self._config['host'], self._config['port'],
+ proto = SMTPFactory(
+ u'anotheruser@leap.se',
+ self._km, self._config['host'],
+ self._config['port'],
self._config['cert'], self._config['key'],
False).buildProtocol(('127.0.0.1', 0))
transport = proto_helpers.StringTransport()