From 087e1af7785adfce028296556b1b4cb9a3ecfc4f Mon Sep 17 00:00:00 2001 From: Ian Good Date: Thu, 3 Nov 2016 22:57:10 -0400 Subject: [PATCH] Cannot TLS on server-side without certfile Fix broken test --- slimta/edge/smtp.py | 3 +-- slimta/http/wsgi.py | 1 - slimta/smtp/server.py | 9 ++++----- test/test_slimta_util_deque.py | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/slimta/edge/smtp.py b/slimta/edge/smtp.py index 3d1b0269..1ab3597b 100644 --- a/slimta/edge/smtp.py +++ b/slimta/edge/smtp.py @@ -213,8 +213,7 @@ class SmtpEdge(EdgeServer): also be given as a list of SASL mechanism names to support, e.g. ``['PLAIN', 'LOGIN', 'CRAM-MD5']``. :param tls: Optional dictionary of TLS settings passed directly as - keyword arguments to :class:`gevent.ssl.SSLSocket`. ``False`` - will explicitly disable TLS. + keyword arguments to :class:`gevent.ssl.SSLSocket`. :param tls_immediately: If True, connections will be encrypted immediately before the SMTP banner. :param command_timeout: Seconds before the connection times out waiting diff --git a/slimta/http/wsgi.py b/slimta/http/wsgi.py index 4100c3c8..0a1f167c 100644 --- a/slimta/http/wsgi.py +++ b/slimta/http/wsgi.py @@ -60,7 +60,6 @@ def build_server(self, listener, pool=None, tls=None): use for new greenlets. :param tls: Optional dictionary of TLS settings passed directly as keyword arguments to :class:`gevent.ssl.SSLSocket`. - ``False`` will explicitly disable TLS. :rtype: :class:`gevent.pywsgi.WSGIServer` """ diff --git a/slimta/smtp/server.py b/slimta/smtp/server.py index a67ad980..6663d497 100644 --- a/slimta/smtp/server.py +++ b/slimta/smtp/server.py @@ -80,15 +80,14 @@ class Server(object): also be given as a list of SASL mechanism names to support, e.g. ``['PLAIN', 'LOGIN', 'CRAM-MD5']``. :param tls: Optional dictionary of TLS settings passed directly as - keyword arguments to :class:`gevent.ssl.SSLSocket`. ``False`` - will explicitly disable TLS. + keyword arguments to :class:`gevent.ssl.SSLSocket`. :param tls_immediately: If True, the socket will be encrypted immediately. + :type tls_immediately: True or False :param tls_wrapper: Optional function that takes a socket and the ``tls`` dictionary, creates a new encrypted socket, performs the TLS handshake, and returns it. The default uses :class:`~gevent.ssl.SSLSocket`. - :type tls_immediately: True or False :param command_timeout: Optional timeout waiting for a command to be sent from the client. :param data_timeout: Optional timeout waiting for data to be sent from @@ -117,7 +116,7 @@ def __init__(self, socket, handlers, auth=False, self.extensions.add('PIPELINING') self.extensions.add('ENHANCEDSTATUSCODES') self.extensions.add('SMTPUTF8') - if self.tls is not False and not tls_immediately: + if self.tls and not tls_immediately: self.extensions.add('STARTTLS') if auth: if isinstance(auth, list): @@ -191,7 +190,7 @@ def handle(self): :raises: :class:`~slimta.smtp.ConnectionLost` or unhandled exceptions. """ - if self.tls is not False and self.tls_immediately: + if self.tls and self.tls_immediately: if not self._encrypt_session(): tls_failure.send(self.io, flush=True) return diff --git a/test/test_slimta_util_deque.py b/test/test_slimta_util_deque.py index f881ab6c..6c65e4df 100644 --- a/test/test_slimta_util_deque.py +++ b/test/test_slimta_util_deque.py @@ -12,7 +12,7 @@ class TestBlockingDeque(unittest.TestCase, MoxTestBase): def setUp(self): super(TestBlockingDeque, self).setUp() self.deque = BlockingDeque() - self.deque.sema = self.mox.CreateMock(Semaphore) + self.deque.sema = self.mox.CreateMockAnything() def test_append(self): self.deque.sema.release()