summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2016-11-24 12:40:49 -0500
committerBarry Warsaw2016-11-24 12:40:49 -0500
commit3552dffc343d098c9baa7d4985ca60e4bb13b9f2 (patch)
tree6d209908c6d18fdbd2747d362dbb9f9e5b6b4a8a
parent0a03fce091e190e15e593dd1a7d1fd0cfac44793 (diff)
downloadmailman-3552dffc343d098c9baa7d4985ca60e4bb13b9f2.tar.gz
mailman-3552dffc343d098c9baa7d4985ca60e4bb13b9f2.tar.zst
mailman-3552dffc343d098c9baa7d4985ca60e4bb13b9f2.zip
-rw-r--r--src/mailman/docs/NEWS.rst7
-rw-r--r--src/mailman/runners/lmtp.py17
-rw-r--r--src/mailman/testing/mta.py50
3 files changed, 17 insertions, 57 deletions
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst
index fdde0589f..80cadd1b7 100644
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -145,10 +145,13 @@ Interfaces
* ``ISubscriptionService`` now supports mass unsubscribes. Given by Harshit
Bansal.
-Internal API
-------------
+Internal
+--------
* A handful of unused legacy exceptions have been removed. The redundant
`MailmanException` has been removed; use `MailmanError` everywhere.
+ * Drop the use of the `lazr.smtptest` library, which is based on the
+ asynchat/asyncore-based smtpd.py stdlib module. Instead, use the
+ asyncio-based aiosmtpd package.
Message handling
----------------
diff --git a/src/mailman/runners/lmtp.py b/src/mailman/runners/lmtp.py
index 9dbe07e25..21fb44c5e 100644
--- a/src/mailman/runners/lmtp.py
+++ b/src/mailman/runners/lmtp.py
@@ -35,6 +35,7 @@ so that the peer mail server can provide better diagnostics.
"""
import email
+import socket
import logging
import aiosmtpd
import aiosmtpd.smtp
@@ -215,26 +216,14 @@ class LMTPHandler:
return CRLF.join(status)
-import socket
-import asyncio
-
-
class LMTPController(Controller):
def factory(self):
return LMTP(self.handler)
- def _run(self, ready_event):
+ def make_socket(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
- sock.bind((self.hostname, self.port))
- asyncio.set_event_loop(self.loop)
- server = self.loop.run_until_complete(
- self.loop.create_server(self.factory, sock=sock))
- self.loop.call_soon(ready_event.set)
- self.loop.run_forever()
- server.close()
- self.loop.run_until_complete(server.wait_closed())
- self.loop.close()
+ return sock
@public
diff --git a/src/mailman/testing/mta.py b/src/mailman/testing/mta.py
index 8b273d792..81e4b8a62 100644
--- a/src/mailman/testing/mta.py
+++ b/src/mailman/testing/mta.py
@@ -17,6 +17,7 @@
"""Fake MTA for testing purposes."""
+import socket
import asyncio
import smtplib
@@ -95,28 +96,12 @@ class ConnectionCountingSMTP(SMTP):
yield from self.push('571 Bad authentication')
@asyncio.coroutine
- def smtp_EHLO(self, arg):
- if not arg:
- yield from self.push('501 Syntax: EHLO hostname')
- return
- # See issue #21783 for a discussion of this behavior.
- if self.seen_greeting:
- yield from self.push('503 Duplicate HELO/EHLO')
- return
- self._set_rset_state()
- self.seen_greeting = arg
- self.extended_smtp = True
- yield from self.push('250-%s' % self.hostname)
- if self.data_size_limit:
- yield from self.push('250-SIZE %s' % self.data_size_limit)
- self.command_size_limits['MAIL'] += 26
- if not self._decode_data:
- yield from self.push('250-8BITMIME')
- if self.enable_SMTPUTF8:
- yield from self.push('250-SMTPUTF8')
- self.command_size_limits['MAIL'] += 10
- yield from self.push('250-HELP')
- yield from self.push('250 AUTH PLAIN')
+ def ehlo_hook(self):
+ yield from self.push('250-AUTH PLAIN')
+
+ @asyncio.coroutine
+ def rset_hook(self):
+ self.event_handler.connection_count = 0
@asyncio.coroutine
def smtp_STAT(self, arg):
@@ -126,11 +111,6 @@ class ConnectionCountingSMTP(SMTP):
self._oob_queue.put(self.event_handler.connection_count)
yield from self.push('250 Ok')
- @asyncio.coroutine
- def smtp_RSET(self, arg):
- yield from super().smtp_RSET(arg)
- self.event_handler.connection_count = 0
-
def _next_error(self, command):
"""Return the next error for the SMTP command, if there is one.
@@ -181,10 +161,6 @@ class ConnectionCountingSMTP(SMTP):
yield from self.push('%d Error: SMTPResponseException' % code)
-import socket
-import asyncio
-
-
class ConnectionCountingController(Controller):
"""Count the number of SMTP connections opened."""
@@ -199,18 +175,10 @@ class ConnectionCountingController(Controller):
return ConnectionCountingSMTP(
self.handler, self._oob_queue, self.err_queue)
- def _run(self, ready_event):
+ def make_socket(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
- sock.bind((self.hostname, self.port))
- asyncio.set_event_loop(self.loop)
- server = self.loop.run_until_complete(
- self.loop.create_server(self.factory, sock=sock))
- self.loop.call_soon(ready_event.set)
- self.loop.run_forever()
- server.close()
- self.loop.run_until_complete(server.wait_closed())
- self.loop.close()
+ return sock
def start(self):
super().start()