summaryrefslogtreecommitdiff
path: root/src/mailman/app/tests/test_lifecycle.py
diff options
context:
space:
mode:
authorBarry Warsaw2017-02-21 14:59:59 +0000
committerBarry Warsaw2017-02-21 14:59:59 +0000
commit1aec5ff6c3558cb5ac6e7f4f5d4a70ea52fa67f2 (patch)
treeead93ea43388b216263eb436068739545eb703d9 /src/mailman/app/tests/test_lifecycle.py
parent2e1ef4b3d3f21a42c49f1a3d5b1e72feca2c92a6 (diff)
parent5d2883cb22e36bc8fe1275ae911b2fd97e6e9da1 (diff)
downloadmailman-1aec5ff6c3558cb5ac6e7f4f5d4a70ea52fa67f2.tar.gz
mailman-1aec5ff6c3558cb5ac6e7f4f5d4a70ea52fa67f2.tar.zst
mailman-1aec5ff6c3558cb5ac6e7f4f5d4a70ea52fa67f2.zip
Diffstat (limited to 'src/mailman/app/tests/test_lifecycle.py')
-rw-r--r--src/mailman/app/tests/test_lifecycle.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/mailman/app/tests/test_lifecycle.py b/src/mailman/app/tests/test_lifecycle.py
index f504e3dfd..dd320c1da 100644
--- a/src/mailman/app/tests/test_lifecycle.py
+++ b/src/mailman/app/tests/test_lifecycle.py
@@ -21,10 +21,12 @@ import os
import shutil
import unittest
-from mailman.app.lifecycle import create_list, remove_list
+from mailman.app.lifecycle import (
+ InvalidListNameError, create_list, remove_list)
from mailman.interfaces.address import InvalidEmailAddressError
from mailman.interfaces.domain import BadDomainSpecificationError
from mailman.interfaces.listmanager import IListManager
+from mailman.testing.helpers import LogFileMark, configuration
from mailman.testing.layers import ConfigLayer
from zope.component import getUtility
@@ -39,6 +41,35 @@ class TestLifecycle(unittest.TestCase):
self.assertRaises(InvalidEmailAddressError,
create_list, 'bogus address')
+ def test_listname_validation(self):
+ # Creating a mailing list with invalid characters in the listname
+ # raises an exception.
+ self.assertRaises(InvalidListNameError,
+ create_list, 'my/list@example.com')
+
+ @configuration('mailman', listname_chars='[a-z0-9-+\]')
+ def test_bad_config_listname_chars(self):
+ mark = LogFileMark('mailman.error')
+ # This list create should succeed but log an error
+ mlist = create_list('test@example.com')
+ # Check the error log.
+ self.assertRegex(
+ mark.readline(),
+ '^.*Bad config\.mailman\.listname_chars setting: '
+ '\[a-z0-9-\+\\\]: '
+ '(unterminated character set|'
+ 'unexpected end of regular expression)$'
+ )
+ # Check that the list was actually created.
+ self.assertIs(os.path.isdir(mlist.data_path), True)
+
+ @configuration('mailman', listname_chars='[a-z]')
+ def test_listname_with_minimal_listname_chars(self):
+ # This only allows letters in the listname. A listname with digits
+ # Raises an exception.
+ self.assertRaises(InvalidListNameError,
+ create_list, 'list1@example.com')
+
def test_unregistered_domain(self):
# Creating a list with an unregistered domain raises an exception.
self.assertRaises(BadDomainSpecificationError,