diff options
Diffstat (limited to 'src/mailman/mta')
| -rw-r--r-- | src/mailman/mta/postfix.py | 10 | ||||
| -rw-r--r-- | src/mailman/mta/tests/test_aliases.py | 19 | ||||
| -rw-r--r-- | src/mailman/mta/tests/test_delivery.py | 5 |
3 files changed, 17 insertions, 17 deletions
diff --git a/src/mailman/mta/postfix.py b/src/mailman/mta/postfix.py index 072581374..ecd71db32 100644 --- a/src/mailman/mta/postfix.py +++ b/src/mailman/mta/postfix.py @@ -34,6 +34,7 @@ from zope.component import getUtility from zope.interface import implementer from mailman.config import config +from mailman.config.config import external_configuration from mailman.interfaces.listmanager import IListManager from mailman.interfaces.mta import ( IMailTransportAgentAliases, IMailTransportAgentLifecycle) @@ -60,6 +61,11 @@ class _FakeList: class LMTP: """Connect Mailman to Postfix via LMTP.""" + def __init__(self): + # Locate and read the Postfix specific configuration file. + mta_config = external_configuration(config.mta.configuration) + self.postmap_command = mta_config.get('postfix', 'postmap_command') + def create(self, mlist): """See `IMailTransportAgentLifecycle`.""" # We can ignore the mlist argument because for LMTP delivery, we just @@ -91,7 +97,7 @@ class LMTP: # one files, still try the other one. errors = [] for path in (lmtp_path, domains_path): - command = config.mta.postfix_map_cmd + ' ' + path + command = self.postmap_command + ' ' + path status = (os.system(command) >> 8) & 0xff if status: msg = 'command failure: %s, %s, %s' @@ -124,7 +130,7 @@ class LMTP: """.format(now().replace(microsecond=0)), file=fp) for domain in sorted(by_domain): print("""\ -# Aliases which are visible only in the @{0} domain.""".format(domain), +# Aliases which are visible only in the @{0} domain.""".format(domain), file=fp) for mlist in sorted(by_domain[domain], key=sort_key): aliases = list(utility.aliases(mlist)) diff --git a/src/mailman/mta/tests/test_aliases.py b/src/mailman/mta/tests/test_aliases.py index cc6b677b3..e22385dcf 100644 --- a/src/mailman/mta/tests/test_aliases.py +++ b/src/mailman/mta/tests/test_aliases.py @@ -37,7 +37,6 @@ from mailman.app.lifecycle import create_list from mailman.interfaces.domain import IDomainManager from mailman.interfaces.mta import IMailTransportAgentAliases from mailman.mta.postfix import LMTP -from mailman.testing.helpers import configuration from mailman.testing.layers import ConfigLayer @@ -145,14 +144,12 @@ class TestPostfix(unittest.TestCase): self.utility = getUtility(IMailTransportAgentAliases) self.mlist = create_list('test@example.com') self.postfix = LMTP() - # Python 2.7 has assertMultiLineEqual. Let this work without bounds. + # Let assertMultiLineEqual work without bounds. self.maxDiff = None - self.eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) def tearDown(self): shutil.rmtree(self.tempdir) - @configuration('mta', postfix_map_cmd='true') def test_aliases(self): # Test the format of the Postfix alias generator. self.postfix.regenerate(self.tempdir) @@ -163,13 +160,13 @@ class TestPostfix(unittest.TestCase): # ignore the file header. with open(os.path.join(self.tempdir, 'postfix_domains')) as fp: contents = _strip_header(fp.read()) - self.eq(contents, """\ + self.assertMultiLineEqual(contents, """\ example.com example.com """) # The lmtp file contains transport mappings to the lmtp server. with open(os.path.join(self.tempdir, 'postfix_lmtp')) as fp: contents = _strip_header(fp.read()) - self.eq(contents, """\ + self.assertMultiLineEqual(contents, """\ # Aliases which are visible only in the @example.com domain. test@example.com lmtp:[127.0.0.1]:9024 test-bounces@example.com lmtp:[127.0.0.1]:9024 @@ -182,7 +179,6 @@ test-subscribe@example.com lmtp:[127.0.0.1]:9024 test-unsubscribe@example.com lmtp:[127.0.0.1]:9024 """) - @configuration('mta', postfix_map_cmd='true') def test_two_lists(self): # Both lists need to show up in the aliases file. LP: #874929. # Create a second list. @@ -195,13 +191,13 @@ test-unsubscribe@example.com lmtp:[127.0.0.1]:9024 # entry in the relays file. with open(os.path.join(self.tempdir, 'postfix_domains')) as fp: contents = _strip_header(fp.read()) - self.eq(contents, """\ + self.assertMultiLineEqual(contents, """\ example.com example.com """) # The transport file contains entries for both lists. with open(os.path.join(self.tempdir, 'postfix_lmtp')) as fp: contents = _strip_header(fp.read()) - self.eq(contents, """\ + self.assertMultiLineEqual(contents, """\ # Aliases which are visible only in the @example.com domain. other@example.com lmtp:[127.0.0.1]:9024 other-bounces@example.com lmtp:[127.0.0.1]:9024 @@ -224,7 +220,6 @@ test-subscribe@example.com lmtp:[127.0.0.1]:9024 test-unsubscribe@example.com lmtp:[127.0.0.1]:9024 """) - @configuration('mta', postfix_map_cmd='true') def test_two_lists_two_domains(self): # Now we have two lists in two different domains. Both lists will # show up in the postfix_lmtp file, and both domains will show up in @@ -239,14 +234,14 @@ test-unsubscribe@example.com lmtp:[127.0.0.1]:9024 # entry in the relays file. with open(os.path.join(self.tempdir, 'postfix_domains')) as fp: contents = _strip_header(fp.read()) - self.eq(contents, """\ + self.assertMultiLineEqual(contents, """\ example.com example.com example.net example.net """) # The transport file contains entries for both lists. with open(os.path.join(self.tempdir, 'postfix_lmtp')) as fp: contents = _strip_header(fp.read()) - self.eq(contents, """\ + self.assertMultiLineEqual(contents, """\ # Aliases which are visible only in the @example.com domain. test@example.com lmtp:[127.0.0.1]:9024 test-bounces@example.com lmtp:[127.0.0.1]:9024 diff --git a/src/mailman/mta/tests/test_delivery.py b/src/mailman/mta/tests/test_delivery.py index fbac0d121..c56058832 100644 --- a/src/mailman/mta/tests/test_delivery.py +++ b/src/mailman/mta/tests/test_delivery.py @@ -95,9 +95,8 @@ options : $user_optionsurl template_dir: {0} """.format(self._template_dir)) self._mlist.footer_uri = 'mailman:///member-footer.txt' - # Python 2.7 has assertMultiLineEqual. Let this work without bounds. + # Let assertMultiLineEqual work without bounds. self.maxDiff = None - self.eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) def tearDown(self): # Free references. @@ -124,7 +123,7 @@ options : $user_optionsurl self.assertEqual(len(refused), 0) self.assertEqual(len(_deliveries), 1) _mlist, _msg, _msgdata, _recipients = _deliveries[0] - self.eq(_msg.as_string(), """\ + self.assertMultiLineEqual(_msg.as_string(), """\ From: anne@example.org To: test@example.com Subject: test |
