summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2011-10-16 16:15:29 -0400
committerBarry Warsaw2011-10-16 16:15:29 -0400
commit63b338e18c6cf07a3c46a8e9db436c9c10654330 (patch)
tree317647079a4f8bb1447d4c0f0f73255cc938e268
parenta8b8be8ad7510c095c3232c25f2c2e3e54d44352 (diff)
downloadmailman-63b338e18c6cf07a3c46a8e9db436c9c10654330.tar.gz
mailman-63b338e18c6cf07a3c46a8e9db436c9c10654330.tar.zst
mailman-63b338e18c6cf07a3c46a8e9db436c9c10654330.zip
-rw-r--r--src/mailman/docs/NEWS.rst2
-rw-r--r--src/mailman/mta/postfix.py6
-rw-r--r--src/mailman/mta/tests/test_aliases.py37
3 files changed, 41 insertions, 4 deletions
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst
index 5b5518645..accb934bb 100644
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -104,6 +104,8 @@ Other bugs and changes
* Local timezone in X-Mailman-Approved-At caused test failure. (LP: #832404)
* InvalidEmailAddressError no longer repr()'s its value.
* Rewrote a test for compatibility between Python 2.6 and 2.7. (LP: #833208)
+ * Fixed Postfix alias file generation when more than one mailing list
+ exists. (LP: #874929). Given by Vincent Fretin.
3.0 alpha 7 -- "Mission"
diff --git a/src/mailman/mta/postfix.py b/src/mailman/mta/postfix.py
index 242325b9f..004e4c214 100644
--- a/src/mailman/mta/postfix.py
+++ b/src/mailman/mta/postfix.py
@@ -122,6 +122,6 @@ class LMTP:
aliases = list(utility.aliases(mlist))
width = max(len(alias) for alias in aliases) + 3
print >> fp, ALIASTMPL.format(aliases.pop(0), config, width)
- for alias in aliases:
- print >> fp, ALIASTMPL.format(alias, config, width)
- print >> fp
+ for alias in aliases:
+ print >> fp, ALIASTMPL.format(alias, config, width)
+ print >> fp
diff --git a/src/mailman/mta/tests/test_aliases.py b/src/mailman/mta/tests/test_aliases.py
index 96207c943..3ba50cad7 100644
--- a/src/mailman/mta/tests/test_aliases.py
+++ b/src/mailman/mta/tests/test_aliases.py
@@ -31,7 +31,6 @@ from cStringIO import StringIO
from zope.component import getUtility
from mailman.app.lifecycle import create_list
-from mailman.config import config
from mailman.interfaces.mta import IMailTransportAgentAliases
from mailman.mta.postfix import LMTP
from mailman.testing.layers import ConfigLayer
@@ -89,6 +88,8 @@ class TestPostfix(unittest.TestCase):
"""Test the Postfix LMTP alias generator."""
layer = ConfigLayer
+ # For Python 2.7's assertMultiLineEqual
+ maxDiff = None
def setUp(self):
self.utility = getUtility(IMailTransportAgentAliases)
@@ -119,6 +120,40 @@ test-subscribe@example.com lmtp:[127.0.0.1]:9024
test-unsubscribe@example.com lmtp:[127.0.0.1]:9024
""")
+ def test_two_lists(self):
+ # Both lists need to show up in the aliases file. LP: #874929.
+ # Create a second list.
+ create_list('other@example.com')
+ # Python 2.7 has assertMultiLineEqual but Python 2.6 does not.
+ eq = getattr(self, 'assertMultiLineEqual', self.assertEqual)
+ self.postfix.regenerate(self.output)
+ # Strip out the variable and unimportant bits of the output.
+ lines = self.output.getvalue().splitlines()
+ output = NL.join(lines[7:])
+ eq(output, """\
+# 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
+other-confirm@example.com lmtp:[127.0.0.1]:9024
+other-join@example.com lmtp:[127.0.0.1]:9024
+other-leave@example.com lmtp:[127.0.0.1]:9024
+other-owner@example.com lmtp:[127.0.0.1]:9024
+other-request@example.com lmtp:[127.0.0.1]:9024
+other-subscribe@example.com lmtp:[127.0.0.1]:9024
+other-unsubscribe@example.com lmtp:[127.0.0.1]:9024
+
+test@example.com lmtp:[127.0.0.1]:9024
+test-bounces@example.com lmtp:[127.0.0.1]:9024
+test-confirm@example.com lmtp:[127.0.0.1]:9024
+test-join@example.com lmtp:[127.0.0.1]:9024
+test-leave@example.com lmtp:[127.0.0.1]:9024
+test-owner@example.com lmtp:[127.0.0.1]:9024
+test-request@example.com lmtp:[127.0.0.1]:9024
+test-subscribe@example.com lmtp:[127.0.0.1]:9024
+test-unsubscribe@example.com lmtp:[127.0.0.1]:9024
+""")
+
+
def test_suite():