From b9005640877047f5167533e20f5b7d14bef9e9c9 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Goncalves Date: Thu, 21 Aug 2014 12:44:29 -0300 Subject: On the mac, the tempdir is not created at /tmp, so checking the tempdir format instead --- src/leap/mail/smtp/tests/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/mail/smtp') diff --git a/src/leap/mail/smtp/tests/__init__.py b/src/leap/mail/smtp/tests/__init__.py index 1459cea..85419cb 100644 --- a/src/leap/mail/smtp/tests/__init__.py +++ b/src/leap/mail/smtp/tests/__init__.py @@ -148,7 +148,7 @@ class TestCaseWithKeyManager(BaseLeapTest): os.environ["PATH"] = self.old_path os.environ["HOME"] = self.old_home # safety check - assert self.tempdir.startswith('/tmp/leap_tests-') + assert 'leap_tests-' in self.tempdir shutil.rmtree(self.tempdir) -- cgit v1.2.3 From 8a987bd846a060cbc12c7ac11a17afafb91b162c Mon Sep 17 00:00:00 2001 From: Bruno Wagner Goncalves Date: Thu, 21 Aug 2014 12:54:10 -0300 Subject: Find the gpg binary on the system, even through symlinks --- src/leap/mail/smtp/tests/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/leap/mail/smtp') diff --git a/src/leap/mail/smtp/tests/__init__.py b/src/leap/mail/smtp/tests/__init__.py index 85419cb..5dc7465 100644 --- a/src/leap/mail/smtp/tests/__init__.py +++ b/src/leap/mail/smtp/tests/__init__.py @@ -21,6 +21,7 @@ Base classes and keys for SMTP gateway tests. """ import os +import distutils.spawn import shutil import tempfile from mock import Mock @@ -39,9 +40,14 @@ from leap.keymanager import ( from leap.common.testing.basetest import BaseLeapTest +def _find_gpg(): + gpg_path = distutils.spawn.find_executable('gpg') + return os.path.realpath(gpg_path) + + class TestCaseWithKeyManager(BaseLeapTest): - GPG_BINARY_PATH = '/usr/bin/gpg' + GPG_BINARY_PATH = _find_gpg() def setUp(self): # mimic BaseLeapTest.setUpClass behaviour, because this is deprecated -- cgit v1.2.3 From 53861af18ecf36dfebb9ae56c5b412dd1be0dd78 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Goncalves Date: Thu, 21 Aug 2014 15:05:33 -0300 Subject: Added fallback in case the gpg binary is not found on the PATH --- src/leap/mail/smtp/tests/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/leap/mail/smtp') diff --git a/src/leap/mail/smtp/tests/__init__.py b/src/leap/mail/smtp/tests/__init__.py index 5dc7465..dc24293 100644 --- a/src/leap/mail/smtp/tests/__init__.py +++ b/src/leap/mail/smtp/tests/__init__.py @@ -42,8 +42,8 @@ from leap.common.testing.basetest import BaseLeapTest def _find_gpg(): gpg_path = distutils.spawn.find_executable('gpg') - return os.path.realpath(gpg_path) - + return os.path.realpath(gpg_path) if gpg_path is not None else "/usr/bin/gpg" + class TestCaseWithKeyManager(BaseLeapTest): -- cgit v1.2.3 From 915f0096215a98a33b599c11855f33adeb0bd851 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 26 Aug 2014 15:53:00 -0500 Subject: remove unneeded imports --- src/leap/mail/smtp/tests/test_gateway.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/leap/mail/smtp') diff --git a/src/leap/mail/smtp/tests/test_gateway.py b/src/leap/mail/smtp/tests/test_gateway.py index 88ee5f7..466677f 100644 --- a/src/leap/mail/smtp/tests/test_gateway.py +++ b/src/leap/mail/smtp/tests/test_gateway.py @@ -23,13 +23,9 @@ SMTP gateway tests. import re from datetime import datetime -from gnupg._util import _make_binary_stream from twisted.test import proto_helpers -from twisted.mail.smtp import ( - User, - Address, - SMTPBadRcpt, -) +from twisted.mail.smtp import User, Address + from mock import Mock from leap.mail.smtp.gateway import ( @@ -137,7 +133,7 @@ class TestSmtpGateway(TestCaseWithKeyManager): self._config['port'], self._config['cert'], self._config['key']) for line in self.EMAIL_DATA[4:12]: m.lineReceived(line) - #m.eomReceived() # this includes a defer, so we avoid calling it here + # m.eomReceived() # this includes a defer, so we avoid calling it here m.lines.append('') # add a trailing newline # we need to call the following explicitelly because it was deferred # inside the previous method @@ -181,7 +177,7 @@ class TestSmtpGateway(TestCaseWithKeyManager): for line in self.EMAIL_DATA[4:12]: m.lineReceived(line) # trigger encryption and signing - #m.eomReceived() # this includes a defer, so we avoid calling it here + # m.eomReceived() # this includes a defer, so we avoid calling it here m.lines.append('') # add a trailing newline # we need to call the following explicitelly because it was deferred # inside the previous method @@ -229,7 +225,7 @@ class TestSmtpGateway(TestCaseWithKeyManager): for line in self.EMAIL_DATA[4:12]: m.lineReceived(line) # trigger signing - #m.eomReceived() # this includes a defer, so we avoid calling it here + # m.eomReceived() # this includes a defer, so we avoid calling it here m.lines.append('') # add a trailing newline # we need to call the following explicitelly because it was deferred # inside the previous method -- cgit v1.2.3 From 1f7b0f2b0e2ba0ef8e09be678ab452951532bd37 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 9 Sep 2014 10:18:09 -0500 Subject: return the deferred from sendMessage in this way we allow to add more callbacks to the chain. --- src/leap/mail/smtp/gateway.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/leap/mail/smtp') diff --git a/src/leap/mail/smtp/gateway.py b/src/leap/mail/smtp/gateway.py index ef398d1..13d3bbf 100644 --- a/src/leap/mail/smtp/gateway.py +++ b/src/leap/mail/smtp/gateway.py @@ -463,13 +463,13 @@ class EncryptedMessage(object): """ Sends the message. - :return: A deferred with callbacks for error and success of this - #message send. + :return: A deferred with callback and errback for + this #message send. :rtype: twisted.internet.defer.Deferred """ d = deferToThread(self._route_msg) d.addCallbacks(self.sendQueued, self.sendError) - return + return d def _route_msg(self): """ -- cgit v1.2.3