diff options
| author | Barry Warsaw | 2014-12-15 13:06:58 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2014-12-15 13:06:58 -0500 |
| commit | e94434bf2b3e1cfd34028a7bbc804ec8a8ee3788 (patch) | |
| tree | f2ad4f068538b458616ad8b1f0b9f6d46e781478 /src | |
| parent | d0c53890bf0c8aa531d45958f0e25fdaccbdb133 (diff) | |
| download | mailman-e94434bf2b3e1cfd34028a7bbc804ec8a8ee3788.tar.gz mailman-e94434bf2b3e1cfd34028a7bbc804ec8a8ee3788.tar.zst mailman-e94434bf2b3e1cfd34028a7bbc804ec8a8ee3788.zip | |
Use listid instead of (fqdn) listname in the metadata pickle.
load_external() now always opens in utf-8 mode.
More test repair.
Diffstat (limited to 'src')
31 files changed, 131 insertions, 142 deletions
diff --git a/src/mailman/app/inject.py b/src/mailman/app/inject.py index 4c182657d..584bd7b8f 100644 --- a/src/mailman/app/inject.py +++ b/src/mailman/app/inject.py @@ -66,7 +66,7 @@ def inject_message(mlist, msg, recipients=None, switchboard=None, **kws): msg['Date'] = formatdate(localtime=True) msg.original_size = len(msg.as_string()) msgdata = dict( - listname=mlist.fqdn_listname, + listid=mlist.list_id, original_size=msg.original_size, ) msgdata.update(kws) diff --git a/src/mailman/app/moderator.py b/src/mailman/app/moderator.py index 9a65207a6..2a8c5f8c2 100644 --- a/src/mailman/app/moderator.py +++ b/src/mailman/app/moderator.py @@ -93,7 +93,7 @@ def hold_message(mlist, msg, msgdata=None, reason=None): # Prepare the message metadata with some extra information needed only by # the moderation interface. msgdata['_mod_message_id'] = message_id - msgdata['_mod_fqdn_listname'] = mlist.fqdn_listname + msgdata['_mod_listid'] = mlist.list_id msgdata['_mod_sender'] = msg.sender msgdata['_mod_subject'] = msg.get('subject', _('(no subject)')) msgdata['_mod_reason'] = reason diff --git a/src/mailman/archiving/mailarchive.py b/src/mailman/archiving/mailarchive.py index 7c5235639..140cd0728 100644 --- a/src/mailman/archiving/mailarchive.py +++ b/src/mailman/archiving/mailarchive.py @@ -73,5 +73,5 @@ class MailArchive: if mlist.archive_policy is ArchivePolicy.public: config.switchboards['out'].enqueue( msg, - listname=mlist.fqdn_listname, + listid=mlist.list_id, recipients=[self.recipient]) diff --git a/src/mailman/bin/gate_news.py b/src/mailman/bin/gate_news.py index 9bb1e5f61..275956fc1 100644 --- a/src/mailman/bin/gate_news.py +++ b/src/mailman/bin/gate_news.py @@ -149,7 +149,7 @@ def poll_newsgroup(mlist, conn, first, last, glock): # Post the message to the locked list inq = Switchboard(config.INQUEUE_DIR) inq.enqueue(msg, - listname=mlist.internal_name(), + listid=mlist.list_id, fromusenet=True) log.info('posted to list %s: %7d', listname, num) except nntplib.NNTPError as e: diff --git a/src/mailman/config/config.py b/src/mailman/config/config.py index c6fe2041a..7a9befa83 100644 --- a/src/mailman/config/config.py +++ b/src/mailman/config/config.py @@ -269,7 +269,7 @@ class Configuration: -def load_external(path, encoding=None): +def load_external(path): """Load the configuration file named by path. :param path: A string naming the location of the external configuration @@ -278,22 +278,16 @@ def load_external(path, encoding=None): value must name a ``.cfg`` file located within Python's import path, however the trailing ``.cfg`` suffix is implied (don't provide it here). - :param encoding: The encoding to apply to the data read from path. If - None, then bytes will be returned. - :return: A unicode string or bytes, depending on ``encoding``. + :return: The contents of the configuration file. + :rtype: str """ # Is the context coming from a file system or Python path? if path.startswith('python:'): resource_path = path[7:] package, dot, resource = resource_path.rpartition('.') - raw = resource_bytes(package, resource + '.cfg') - config_string = raw.decode('utf-8') - else: - with open(path, 'r', encoding='utf-8') as fp: - config_string = fp.read() - if encoding is None: - return config_string - return config_string.decode(encoding) + return resource_bytes(package, resource + '.cfg').decode('utf-8') + with open(path, 'r', encoding='utf-8') as fp: + return fp.read() def external_configuration(path): diff --git a/src/mailman/config/tests/test_configuration.py b/src/mailman/config/tests/test_configuration.py index b411f9615..ce2e6bae3 100644 --- a/src/mailman/config/tests/test_configuration.py +++ b/src/mailman/config/tests/test_configuration.py @@ -28,7 +28,6 @@ __all__ = [ import os -import six import mock import tempfile import unittest @@ -66,26 +65,13 @@ class TestConfiguration(unittest.TestCase): class TestExternal(unittest.TestCase): """Test external configuration file loading APIs.""" - def test_load_external_by_filename_as_bytes(self): + def test_load_external_by_filename(self): filename = resource_filename('mailman.config', 'postfix.cfg') contents = load_external(filename) - self.assertIsInstance(contents, bytes) - self.assertEqual(contents[:9], b'[postfix]') - - def test_load_external_by_path_as_bytes(self): - contents = load_external('python:mailman.config.postfix') - self.assertIsInstance(contents, bytes) - self.assertEqual(contents[:9], b'[postfix]') - - def test_load_external_by_filename_as_string(self): - filename = resource_filename('mailman.config', 'postfix.cfg') - contents = load_external(filename, encoding='utf-8') - self.assertIsInstance(contents, six.text_type) self.assertEqual(contents[:9], '[postfix]') - def test_load_external_by_path_as_string(self): - contents = load_external('python:mailman.config.postfix', 'utf-8') - self.assertIsInstance(contents, six.text_type) + def test_load_external_by_path(self): + contents = load_external('python:mailman.config.postfix') self.assertEqual(contents[:9], '[postfix]') def test_external_configuration_by_filename(self): diff --git a/src/mailman/core/docs/runner.rst b/src/mailman/core/docs/runner.rst index e9fd21c57..865635310 100644 --- a/src/mailman/core/docs/runner.rst +++ b/src/mailman/core/docs/runner.rst @@ -55,7 +55,7 @@ on instance variables. ... A test message. ... """) >>> switchboard = config.switchboards['test'] - >>> filebase = switchboard.enqueue(msg, listname=mlist.fqdn_listname, + >>> filebase = switchboard.enqueue(msg, list_id=mlist.list_id, ... foo='yes', bar='no') >>> runner.run() >>> print(runner.msg.as_string()) diff --git a/src/mailman/core/runner.py b/src/mailman/core/runner.py index d6aad2b07..83f1b469c 100644 --- a/src/mailman/core/runner.py +++ b/src/mailman/core/runner.py @@ -219,9 +219,18 @@ class Runner: # Find out which mailing list this message is destined for. mlist = None missing = object() - listname = msgdata.get('listname', missing) - if listname is missing: - mlist = getUtility(IListManager).get(listname.decode('utf-8')) + # First try to dig out the target list by id. If there's no list-id + # in the metadata, fall back to the fqdn list name for backward + # compatibility. + list_manager = getUtility(IListManager) + list_id = msgdata.get('listid', missing) + if list_id is missing: + listname = msgdata.get('listname', missing) + # XXX Deprecate. + if listname is not missing: + mlist = list_manager.get(listname) + else: + mlist = list_manager.get_by_list_id(list_id) if mlist is None: elog.error( '%s runner "%s" shunting message for missing list: %s', diff --git a/src/mailman/core/switchboard.py b/src/mailman/core/switchboard.py index 3375aa1dd..d4884c4c9 100644 --- a/src/mailman/core/switchboard.py +++ b/src/mailman/core/switchboard.py @@ -112,7 +112,7 @@ class Switchboard: # of parallel runner processes. data = _metadata.copy() data.update(_kws) - listname = data.get('listname', '--nolist--') + list_id = data.get('listid', '--nolist--') # Get some data for the input to the sha hash. now = repr(time.time()) if data.get('_plaintext'): @@ -121,8 +121,9 @@ class Switchboard: else: protocol = pickle.HIGHEST_PROTOCOL msgsave = cPickle.dumps(_msg, protocol) - # listname is a str but the input to the hash function must be a bytes. - hashfood = msgsave + listname.encode('utf-8') + now.encode('utf-8') + # The list-id field is a string but the input to the hash function must + # be bytes. + hashfood = msgsave + list_id.encode('utf-8') + now.encode('utf-8') # Encode the current time into the file name for FIFO sorting. The # file name consists of two parts separated by a '+': the received # time for this message (i.e. when it first showed up on this system) diff --git a/src/mailman/core/tests/test_runner.py b/src/mailman/core/tests/test_runner.py index 2875b3b10..a48925b4c 100644 --- a/src/mailman/core/tests/test_runner.py +++ b/src/mailman/core/tests/test_runner.py @@ -68,7 +68,7 @@ To: test@example.com Message-ID: <ant> """) - config.switchboards['in'].enqueue(msg, listname='test@example.com') + config.switchboards['in'].enqueue(msg, listid='test.example.com') with event_subscribers(self._got_event): runner.run() # We should now have exactly one event, which will contain the diff --git a/src/mailman/email/message.py b/src/mailman/email/message.py index 539d151ad..92f5ff846 100644 --- a/src/mailman/email/message.py +++ b/src/mailman/email/message.py @@ -185,7 +185,7 @@ class UserNotification(Message): :param mlist: The mailing list to send the message to. :type mlist: `IMailingList` - :param add_precedence: Flag indicating whether a `Precedence: bulk` + :param add_precedence: Flag indicating whether a `Precedence: bulk` header should be added to the message or not. :type add_precedence: bool @@ -217,7 +217,7 @@ class UserNotification(Message): reduced_list_headers=True, ) if mlist is not None: - enqueue_kws['listname'] = mlist.fqdn_listname + enqueue_kws['listid'] = mlist.list_id enqueue_kws.update(_kws) virginq.enqueue(self, **enqueue_kws) @@ -246,7 +246,7 @@ class OwnerNotification(UserNotification): virginq = config.switchboards['virgin'] # The message metadata better have a `recip' attribute virginq.enqueue(self, - listname=mlist.fqdn_listname, + listid=mlist.list_id, recipients=self.recipients, nodecorate=True, reduced_list_headers=True, diff --git a/src/mailman/handlers/to_digest.py b/src/mailman/handlers/to_digest.py index 9eb5818bb..e2d6657b7 100644 --- a/src/mailman/handlers/to_digest.py +++ b/src/mailman/handlers/to_digest.py @@ -75,7 +75,7 @@ class ToDigest: os.rename(mailbox_path, mailbox_dest) config.switchboards['digest'].enqueue( Message(), - listname=mlist.fqdn_listname, + listid=mlist.list_id, digest_path=mailbox_dest, volume=volume, digest_number=digest_number) diff --git a/src/mailman/handlers/to_outgoing.py b/src/mailman/handlers/to_outgoing.py index 6dfbe88c0..92fb7fee0 100644 --- a/src/mailman/handlers/to_outgoing.py +++ b/src/mailman/handlers/to_outgoing.py @@ -47,5 +47,4 @@ class ToOutgoing: def process(self, mlist, msg, msgdata): """See `IHandler`.""" - config.switchboards['out'].enqueue( - msg, msgdata, listname=mlist.fqdn_listname) + config.switchboards['out'].enqueue(msg, msgdata, listid=mlist.list_id) diff --git a/src/mailman/handlers/to_usenet.py b/src/mailman/handlers/to_usenet.py index d5a946644..28c18c520 100644 --- a/src/mailman/handlers/to_usenet.py +++ b/src/mailman/handlers/to_usenet.py @@ -65,5 +65,4 @@ class ToUsenet: COMMASPACE.join(error)) return # Put the message in the news runner's queue. - config.switchboards['nntp'].enqueue( - msg, msgdata, listname=mlist.fqdn_listname) + config.switchboards['nntp'].enqueue(msg, msgdata, listid=mlist.list_id) diff --git a/src/mailman/runners/command.py b/src/mailman/runners/command.py index f6884de5f..7f8c7f470 100644 --- a/src/mailman/runners/command.py +++ b/src/mailman/runners/command.py @@ -76,7 +76,7 @@ class CommandFinder: # Extract the subject header and do RFC 2047 decoding. raw_subject = msg.get('subject', '') try: - subject = make_header(decode_header(raw_subject)).decode('utf-8') + subject = str(make_header(decode_header(raw_subject))) # Mail commands must be ASCII. self.command_lines.append(subject.encode('us-ascii')) except (HeaderParseError, UnicodeError, LookupError): @@ -98,7 +98,7 @@ class CommandFinder: if part is None: # There was no text/plain part to be found. return - body = part.get_payload(decode=True) + body = part.get_payload() # text/plain parts better have string payloads. assert isinstance(body, six.string_types), 'Non-string decoded payload' lines = body.splitlines() @@ -207,12 +207,12 @@ class CommandRunner(Runner): if status == ContinueProcessing.no: break # All done. Strip blank lines and send the response. - lines = filter(None, (line.strip() for line in finder.command_lines)) + lines = [line.strip() for line in finder.command_lines if line] if len(lines) > 0: print(_('\n- Unprocessed:'), file=results) for line in lines: print(line, file=results) - lines = filter(None, (line.strip() for line in finder.ignored_lines)) + lines = [line.strip() for line in finder.ignored_lines if line] if len(lines) > 0: print(_('\n- Ignored:'), file=results) for line in lines: @@ -231,7 +231,7 @@ class CommandRunner(Runner): # Find a charset for the response body. Try the original message's # charset first, then ascii, then latin-1 and finally falling back to # utf-8. - reply_body = results.decode('utf-8') + reply_body = str(results) for charset in (results.charset, 'us-ascii', 'latin-1'): try: reply_body.encode(charset) diff --git a/src/mailman/runners/digest.py b/src/mailman/runners/digest.py index 628a08e0c..1716d9694 100644 --- a/src/mailman/runners/digest.py +++ b/src/mailman/runners/digest.py @@ -383,9 +383,9 @@ class DigestRunner(Runner): queue = config.switchboards['virgin'] queue.enqueue(mime, recipients=mime_recipients, - listname=mlist.fqdn_listname, + listid=mlist.list_id, isdigest=True) queue.enqueue(rfc1153, recipients=rfc1153_recipients, - listname=mlist.fqdn_listname, + listid=mlist.list_id, isdigest=True) diff --git a/src/mailman/runners/docs/digester.rst b/src/mailman/runners/docs/digester.rst index cd0fba67c..14580c336 100644 --- a/src/mailman/runners/docs/digester.rst +++ b/src/mailman/runners/docs/digester.rst @@ -57,7 +57,7 @@ But the message metadata has a reference to the digest file. _parsemsg : False digest_number: 1 digest_path : .../lists/test@example.com/digest.1.1.mmdf - listname : test@example.com + listid : test.example.com version : 3 volume : 1 @@ -323,7 +323,7 @@ The marker message is sitting in the digest queue. _parsemsg : False digest_number: 2 digest_path : .../lists/test@example.com/digest.1.2.mmdf - listname : test@example.com + listid : test.example.com version : 3 volume : 1 diff --git a/src/mailman/runners/docs/nntp.rst b/src/mailman/runners/docs/nntp.rst index 372fa5744..4bd73cbab 100644 --- a/src/mailman/runners/docs/nntp.rst +++ b/src/mailman/runners/docs/nntp.rst @@ -37,7 +37,7 @@ are prohibited by NNTP servers such as INN. The message gets copied to the NNTP queue for preparation and posting. >>> filebase = config.switchboards['nntp'].enqueue( - ... msg, listname='test@example.com') + ... msg, listid='test.example.com') >>> from mailman.testing.helpers import make_testable_runner >>> from mailman.runners.nntp import NNTPRunner >>> runner = make_testable_runner(NNTPRunner, 'nntp') diff --git a/src/mailman/runners/docs/outgoing.rst b/src/mailman/runners/docs/outgoing.rst index d4a20d497..7c3d1a989 100644 --- a/src/mailman/runners/docs/outgoing.rst +++ b/src/mailman/runners/docs/outgoing.rst @@ -57,7 +57,7 @@ destination mailing list name. Simulate that here too. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, ... tolist=True, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) Running the outgoing runner processes the message, delivering it to the upstream SMTP. @@ -105,7 +105,7 @@ just one. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -147,7 +147,7 @@ A handler can force VERP by setting the ``verp`` key in the message metadata. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, ... verp=True, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -174,7 +174,7 @@ Again, we get three individual messages, with VERP'd ``Sender`` headers. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -215,7 +215,7 @@ VERP'd. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -235,7 +235,7 @@ The second message sent to the list is also not VERP'd. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -254,7 +254,7 @@ The third message though is VERP'd. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -274,7 +274,7 @@ The next one is back to bulk delivery. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -308,7 +308,7 @@ The first message is VERP'd. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -328,7 +328,7 @@ As is the second message. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -348,7 +348,7 @@ And the third message. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -387,7 +387,7 @@ Neither the first message... >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -402,7 +402,7 @@ Neither the first message... >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) diff --git a/src/mailman/runners/lmtp.py b/src/mailman/runners/lmtp.py index cb5b4a017..daa1e7e1c 100644 --- a/src/mailman/runners/lmtp.py +++ b/src/mailman/runners/lmtp.py @@ -206,18 +206,19 @@ class LMTPRunner(Runner, smtpd.SMTPServer): for to in rcpttos: try: to = parseaddr(to)[1].lower() - listname, subaddress, domain = split_recipient(to) + local, subaddress, domain = split_recipient(to) slog.debug('%s to: %s, list: %s, sub: %s, dom: %s', - message_id, to, listname, subaddress, domain) - listname += '@' + domain + message_id, to, local, subaddress, domain) + listname = '{}@{}'.format(local, domain) if listname not in listnames: status.append(ERR_550) continue + listid = '{}.{}'.format(local, domain) # The recipient is a valid mailing list. Find the subaddress # if there is one, and set things up to enqueue to the proper # queue. queue = None - msgdata = dict(listname=listname, + msgdata = dict(listid=listid, original_size=msg.original_size, received_time=received_time) canonical_subaddress = SUBADDRESS_NAMES.get(subaddress) diff --git a/src/mailman/runners/tests/test_archiver.py b/src/mailman/runners/tests/test_archiver.py index e11b6c805..12bdb0edd 100644 --- a/src/mailman/runners/tests/test_archiver.py +++ b/src/mailman/runners/tests/test_archiver.py @@ -110,7 +110,7 @@ First post! # Ensure that the archive runner ends up archiving the message. self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname, + listid=self._mlist.list_id, received_time=now()) self._runner.run() # There should now be a copy of the message in the file system. @@ -126,7 +126,7 @@ First post! self._msg['Date'] = now(strip_tzinfo=False).strftime(RFC822_DATE_FMT) self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname, + listid=self._mlist.list_id, received_time=now()) self._runner.run() # There should now be a copy of the message in the file system. @@ -144,7 +144,7 @@ First post! self._msg['Date'] = now(strip_tzinfo=False).strftime(RFC822_DATE_FMT) self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname, + listid=self._mlist.list_id, received_time=now()) self._runner.run() # There should now be a copy of the message in the file system. @@ -163,7 +163,7 @@ First post! # again), fast forward a few days. self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname, + listid=self._mlist.list_id, received_time=now(strip_tzinfo=False)) self._runner.run() # There should now be a copy of the message in the file system. @@ -182,7 +182,7 @@ First post! # again as will happen in the runner), fast forward a few days. self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname) + listid=self._mlist.list_id) factory.fast_forward(days=4) self._runner.run() # There should now be a copy of the message in the file system. @@ -205,7 +205,7 @@ First post! # again as will happen in the runner), fast forward a few days. self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname) + listid=self._mlist.list_id) factory.fast_forward(days=4) self._runner.run() # There should now be a copy of the message in the file system. @@ -228,7 +228,7 @@ First post! # again as will happen in the runner), fast forward a few days. self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname) + listid=self._mlist.list_id) factory.fast_forward(days=4) self._runner.run() # There should now be a copy of the message in the file system. @@ -249,6 +249,6 @@ First post! config.db.store.commit() self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname) + listid=self._mlist.list_id) self._runner.run() self.assertEqual(os.listdir(config.MESSAGES_DIR), []) diff --git a/src/mailman/runners/tests/test_bounce.py b/src/mailman/runners/tests/test_bounce.py index 315a81c22..b296f4476 100644 --- a/src/mailman/runners/tests/test_bounce.py +++ b/src/mailman/runners/tests/test_bounce.py @@ -69,7 +69,7 @@ To: test-bounces+anne=example.com@example.com Message-Id: <first> """) - self._msgdata = dict(listname='test@example.com') + self._msgdata = dict(listid='test.example.com') self._processor = getUtility(IBounceProcessor) config.push('site owner', """ [mailman] @@ -284,7 +284,7 @@ To: test-bounces+anne=example.com@example.com Message-Id: <first> """) - self._bounceq.enqueue(bounce, dict(listname='test@example.com')) + self._bounceq.enqueue(bounce, dict(listid='test.example.com')) self.assertEqual(len(self._bounceq.files), 1) self._runner.run() self.assertEqual(len(get_queue_messages('bounces')), 0) diff --git a/src/mailman/runners/tests/test_confirm.py b/src/mailman/runners/tests/test_confirm.py index 40fae368f..d387fcfe6 100644 --- a/src/mailman/runners/tests/test_confirm.py +++ b/src/mailman/runners/tests/test_confirm.py @@ -68,7 +68,7 @@ To: test-confirm@example.com """) msg['Subject'] = subject - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() # Anne is now a confirmed member so her user record and email address # should exist in the database. @@ -88,7 +88,7 @@ To: test-confirm@example.com """) msg['Subject'] = subject - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() # Anne is now a confirmed member so her user record and email address # should exist in the database. @@ -144,7 +144,7 @@ Franziskanerstra=C3=9Fe """) msg['Subject'] = subject msg['To'] = to - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() # Anne is now a confirmed member so her user record and email address # should exist in the database. @@ -177,7 +177,7 @@ Franziskanerstra=C3=9Fe """) msg['Subject'] = subject msg['To'] = to - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() # Anne is now a confirmed member so her user record and email address # should exist in the database. @@ -208,7 +208,7 @@ From: Anne Person <anne@example.org> """) msg['Subject'] = subject msg['To'] = to - self._commandq.enqueue(msg, dict(listname='test@example.com', + self._commandq.enqueue(msg, dict(listid='test.example.com', subaddress='confirm')) self._runner.run() # Anne is now a confirmed member so her user record and email address @@ -223,7 +223,7 @@ From: Anne Person <anne@example.org> # one 'Confirmation email' line. confirmation_lines = [] in_results = False - for line in body_line_iterator(messages[0].msg, decode=True): + for line in body_line_iterator(messages[0].msg): line = line.strip() if in_results: if line.startswith('- Done'): @@ -253,7 +253,7 @@ From: Anne Person <anne@example.org> """) msg['Subject'] = subject msg['To'] = to - self._commandq.enqueue(msg, dict(listname='test@example.com', + self._commandq.enqueue(msg, dict(listid='test.example.com', subaddress='confirm')) self._runner.run() # Now there's a email command notification and a welcome message. All diff --git a/src/mailman/runners/tests/test_digest.py b/src/mailman/runners/tests/test_digest.py index 80cf253bc..6cd3c9a01 100644 --- a/src/mailman/runners/tests/test_digest.py +++ b/src/mailman/runners/tests/test_digest.py @@ -65,7 +65,7 @@ message triggering a digest self._process(self._mlist, msg, {}) self._digestq.enqueue( msg, - listname=self._mlist.fqdn_listname, + listid=self._mlist.list_id, digest_path=mbox_path, volume=1, digest_number=1) self._runner.run() @@ -92,7 +92,7 @@ message triggering a digest mbox.add(msg.as_string()) self._digestq.enqueue( msg, - listname=self._mlist.fqdn_listname, + listid=self._mlist.list_id, digest_path=mbox_path, volume=1, digest_number=1) # Use any error logs as the error message if the test fails. diff --git a/src/mailman/runners/tests/test_incoming.py b/src/mailman/runners/tests/test_incoming.py index 9830fedb9..2d49ae550 100644 --- a/src/mailman/runners/tests/test_incoming.py +++ b/src/mailman/runners/tests/test_incoming.py @@ -76,7 +76,7 @@ To: test@example.com def test_posting(self): # A message posted to the list goes through the posting chain. - msgdata = dict(listname='test@example.com') + msgdata = dict(listid='test.example.com') config.switchboards['in'].enqueue(self._msg, msgdata) self._in.run() messages = get_queue_messages('out') @@ -85,7 +85,7 @@ To: test@example.com def test_owner(self): # A message posted to the list goes through the posting chain. - msgdata = dict(listname='test@example.com', + msgdata = dict(listid='test.example.com', to_owner=True) config.switchboards['in'].enqueue(self._msg, msgdata) self._in.run() diff --git a/src/mailman/runners/tests/test_join.py b/src/mailman/runners/tests/test_join.py index fbea9e661..2aa361254 100644 --- a/src/mailman/runners/tests/test_join.py +++ b/src/mailman/runners/tests/test_join.py @@ -72,7 +72,7 @@ subscribe # Adding the subaddress to the metadata dictionary mimics what happens # when the above email message is first processed by the lmtp runner. # For convenience, we skip that step in this test. - self._commandq.enqueue(msg, dict(listname='test@example.com', + self._commandq.enqueue(msg, dict(listid='test.example.com', subaddress='join')) self._runner.run() # There will be two messages in the queue. The first one is a reply @@ -87,7 +87,7 @@ subscribe # one 'Confirmation email' line. confirmation_lines = [] in_results = False - for line in body_line_iterator(messages[0].msg, decode=True): + for line in body_line_iterator(messages[0].msg): line = line.strip() if in_results: if line.startswith('- Done'): @@ -112,7 +112,7 @@ To: test-join@example.com Subject: join """) - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() # There will be one message in the queue - a reply to Anne notifying # her of the status of her command email. Because Anne is already @@ -125,7 +125,7 @@ Subject: join # one 'Confirmation email' line. confirmation_lines = [] in_results = False - for line in body_line_iterator(messages[0].msg, decode=True): + for line in body_line_iterator(messages[0].msg): line = line.strip() if in_results: if line.startswith('- Done'): @@ -181,7 +181,7 @@ To: test-request@example.com join """) - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() anne = self._confirm() self.assertEqual(anne.address.email, 'anne@example.org') @@ -195,7 +195,7 @@ To: test-request@example.com join digest=no """) - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() anne = self._confirm() self.assertEqual(anne.address.email, 'anne@example.org') @@ -209,7 +209,7 @@ To: test-request@example.com join digest=mime """) - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() anne = self._confirm() self.assertEqual(anne.address.email, 'anne@example.org') @@ -223,7 +223,7 @@ To: test-request@example.com join digest=plain """) - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() anne = self._confirm() self.assertEqual(anne.address.email, 'anne@example.org') diff --git a/src/mailman/runners/tests/test_lmtp.py b/src/mailman/runners/tests/test_lmtp.py index 26308548c..ccd27c829 100644 --- a/src/mailman/runners/tests/test_lmtp.py +++ b/src/mailman/runners/tests/test_lmtp.py @@ -142,5 +142,5 @@ Message-ID: <alpha> """) messages = get_queue_messages('in') self.assertEqual(len(messages), 1) - self.assertEqual(messages[0].msgdata['listname'], - 'my-list@example.com') + self.assertEqual(messages[0].msgdata['listid'], + 'my-list.example.com') diff --git a/src/mailman/runners/tests/test_nntp.py b/src/mailman/runners/tests/test_nntp.py index 191dd2657..24db00285 100644 --- a/src/mailman/runners/tests/test_nntp.py +++ b/src/mailman/runners/tests/test_nntp.py @@ -257,7 +257,7 @@ Testing @mock.patch('nntplib.NNTP') def test_connect(self, class_mock): # Test connection to the NNTP server with default values. - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() class_mock.assert_called_once_with( '', 119, user='', password='', readermode=True) @@ -267,7 +267,7 @@ Testing @mock.patch('nntplib.NNTP') def test_connect_with_configuration(self, class_mock): # Test connection to the NNTP server with specific values. - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() class_mock.assert_called_once_with( 'nntp.example.com', 2112, @@ -276,7 +276,7 @@ Testing @mock.patch('nntplib.NNTP') def test_post(self, class_mock): # Test that the message is posted to the NNTP server. - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() # Get the mocked instance, which was used in the runner. conn_mock = class_mock() @@ -295,7 +295,7 @@ Testing def test_connection_got_quit(self, class_mock): # The NNTP connection gets closed after a successful post. # Test that the message is posted to the NNTP server. - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() # Get the mocked instance, which was used in the runner. conn_mock = class_mock() @@ -306,7 +306,7 @@ Testing @mock.patch('nntplib.NNTP', side_effect=nntplib.NNTPTemporaryError) def test_connect_with_nntplib_failure(self, class_mock): - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') mark = LogFileMark('mailman.error') self._runner.run() log_message = mark.readline()[:-1] @@ -315,7 +315,7 @@ Testing @mock.patch('nntplib.NNTP', side_effect=socket.error) def test_connect_with_socket_failure(self, class_mock): - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') mark = LogFileMark('mailman.error') self._runner.run() log_message = mark.readline()[:-1] @@ -330,7 +330,7 @@ Testing # I.e. stop immediately, since the queue will not be empty. return True runner = make_testable_runner(nntp.NNTPRunner, 'nntp', predicate=once) - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') mark = LogFileMark('mailman.error') runner.run() log_message = mark.readline()[:-1] @@ -345,7 +345,7 @@ Testing def test_connection_never_gets_quit_after_failures(self, class_mock): # The NNTP connection doesn't get closed after a unsuccessful # connection, since there's nothing to close. - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() # Get the mocked instance, which was used in the runner. Turn off the # exception raising side effect first though! @@ -362,7 +362,7 @@ Testing # Add a side-effect to the instance mock's .post() method. conn_mock = class_mock() conn_mock.post.side_effect = nntplib.NNTPTemporaryError - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() # The connection object's post() method was called once with a # file-like object containing the message's bytes. Read those bytes diff --git a/src/mailman/runners/tests/test_outgoing.py b/src/mailman/runners/tests/test_outgoing.py index 62f6776b1..68fb75fc3 100644 --- a/src/mailman/runners/tests/test_outgoing.py +++ b/src/mailman/runners/tests/test_outgoing.py @@ -96,7 +96,7 @@ Message-Id: <first> deliver_after = now() + timedelta(days=10) self._msgdata['deliver_after'] = deliver_after self._outq.enqueue(self._msg, self._msgdata, - tolist=True, listname='test@example.com') + tolist=True, listid='test.example.com') self._runner.run() items = get_queue_messages('out') self.assertEqual(len(items), 1) @@ -149,20 +149,20 @@ Message-Id: <first> def test_delivery_callback(self): # Test that the configuration variable calls the appropriate callback. - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() self.assertEqual(captured_mlist, self._mlist) self.assertEqual(captured_msg.as_string(), self._msg.as_string()) # Of course, the message metadata will contain a bunch of keys added # by the processing. We don't really care about the details, so this # test is a good enough stand-in. - self.assertEqual(captured_msgdata['listname'], 'test@example.com') + self.assertEqual(captured_msgdata['listid'], 'test.example.com') def test_verp_in_metadata(self): # Test that if the metadata has a 'verp' key, it is unchanged. marker = 'yepper' msgdata = dict(verp=marker) - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') self._runner.run() self.assertEqual(captured_msgdata['verp'], marker) @@ -171,7 +171,7 @@ Message-Id: <first> # indicates, messages will be VERP'd. msgdata = {} self._mlist.personalize = Personalization.individual - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') with temporary_config('personalize', """ [mta] verp_personalized_deliveries: yes @@ -184,7 +184,7 @@ Message-Id: <first> # indicates, messages will be VERP'd. msgdata = {} self._mlist.personalize = Personalization.full - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') with temporary_config('personalize', """ [mta] verp_personalized_deliveries: yes @@ -197,14 +197,14 @@ Message-Id: <first> # does not indicate, messages will not be VERP'd. msgdata = {} self._mlist.personalize = Personalization.full - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') self._runner.run() self.assertFalse('verp' in captured_msgdata) def test_verp_never(self): # Never VERP when the interval is zero. msgdata = {} - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') with temporary_config('personalize', """ [mta] verp_delivery_interval: 0 @@ -215,7 +215,7 @@ Message-Id: <first> def test_verp_always(self): # Always VERP when the interval is one. msgdata = {} - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') with temporary_config('personalize', """ [mta] verp_delivery_interval: 1 @@ -227,7 +227,7 @@ Message-Id: <first> # VERP every so often, when the post_id matches. self._mlist.post_id = 5 msgdata = {} - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') with temporary_config('personalize', """ [mta] verp_delivery_interval: 5 @@ -239,7 +239,7 @@ Message-Id: <first> # VERP every so often, when the post_id matches. self._mlist.post_id = 4 msgdata = {} - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') with temporary_config('personalize', """ [mta] verp_delivery_interval: 5 @@ -287,7 +287,7 @@ Message-Id: <first> error_log = logging.getLogger('mailman.error') filename = error_log.handlers[0].filename filepos = os.stat(filename).st_size - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') with temporary_config('port 0', """ [mta] smtp_port: 0 @@ -308,7 +308,7 @@ Message-Id: <first> # that is a log message. Start by opening the error log and reading # the current file position. mark = LogFileMark('mailman.error') - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') with temporary_config('port 0', """ [mta] smtp_port: 2112 @@ -369,7 +369,7 @@ Message-Id: <first> token = send_probe(member, self._msg) msgdata = dict(probe_token=token) permanent_failures.append('anne@example.com') - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 1) @@ -390,7 +390,7 @@ Message-Id: <first> getUtility(IPendings).confirm(token) msgdata = dict(probe_token=token) permanent_failures.append('anne@example.com') - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 0) @@ -404,7 +404,7 @@ Message-Id: <first> getUtility(IPendings).confirm(token) msgdata = dict(probe_token=token) temporary_failures.append('anne@example.com') - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 0) @@ -412,7 +412,7 @@ Message-Id: <first> def test_one_permanent_failure(self): # Normal (i.e. non-probe) permanent failures just get registered. permanent_failures.append('anne@example.com') - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 1) @@ -423,7 +423,7 @@ Message-Id: <first> # Two normal (i.e. non-probe) permanent failures just get registered. permanent_failures.append('anne@example.com') permanent_failures.append('bart@example.com') - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 2) @@ -437,7 +437,7 @@ Message-Id: <first> # put in the retry queue, but with some metadata to prevent infinite # retries. temporary_failures.append('cris@example.com') - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 0) @@ -458,7 +458,7 @@ Message-Id: <first> # retries. temporary_failures.append('cris@example.com') temporary_failures.append('dave@example.com') - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 0) @@ -476,7 +476,7 @@ Message-Id: <first> permanent_failures.append('fred@example.com') temporary_failures.append('gwen@example.com') temporary_failures.append('herb@example.com') - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() # Let's look at the permanent failures. events = list(self._processor.unprocessed) @@ -503,7 +503,7 @@ Message-Id: <first> as_timedelta(config.mta.delivery_retry_period)) msgdata = dict(last_recip_count=2, deliver_until=deliver_until) - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') self._runner.run() # The retry queue should have our message waiting to be retried. items = get_queue_messages('retry') @@ -522,7 +522,7 @@ Message-Id: <first> deliver_until = datetime(2005, 8, 1, 7, 49, 23) + retry_period msgdata = dict(last_recip_count=2, deliver_until=deliver_until) - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') # Before the runner runs, several days pass. factory.fast_forward(retry_period.days + 1) mark = LogFileMark('mailman.smtp') diff --git a/src/mailman/runners/tests/test_pipeline.py b/src/mailman/runners/tests/test_pipeline.py index 50ec6cb9a..1eba5cfbf 100644 --- a/src/mailman/runners/tests/test_pipeline.py +++ b/src/mailman/runners/tests/test_pipeline.py @@ -101,7 +101,7 @@ To: test@example.com def test_posting(self): # A message accepted for posting gets processed through the posting # pipeline. - msgdata = dict(listname='test@example.com') + msgdata = dict(listid='test.example.com') config.switchboards['pipeline'].enqueue(self._msg, msgdata) self._pipeline.run() self.assertEqual(len(self._markers), 1) @@ -110,7 +110,7 @@ To: test@example.com def test_owner(self): # A message accepted for posting to a list's owners gets processed # through the owner pipeline. - msgdata = dict(listname='test@example.com', + msgdata = dict(listid='test.example.com', to_owner=True) config.switchboards['pipeline'].enqueue(self._msg, msgdata) self._pipeline.run() diff --git a/src/mailman/runners/tests/test_retry.py b/src/mailman/runners/tests/test_retry.py index 28289bc05..15775e5d8 100644 --- a/src/mailman/runners/tests/test_retry.py +++ b/src/mailman/runners/tests/test_retry.py @@ -54,7 +54,7 @@ To: test@example.com Message-Id: <first> """) - self._msgdata = dict(listname='test@example.com') + self._msgdata = dict(listid='test.example.com') def test_message_put_in_outgoing_queue(self): self._retryq.enqueue(self._msg, self._msgdata) |
