summaryrefslogtreecommitdiff
path: root/src/mailman/rest
diff options
context:
space:
mode:
authorBarry Warsaw2011-09-01 20:04:06 -0400
committerBarry Warsaw2011-09-01 20:04:06 -0400
commita6fcb3e732fbf880e02a94ce8265be6624459ed8 (patch)
tree6a4155de4d0367a47e3393f3bb306fc019144fe2 /src/mailman/rest
parent232ac1d8af1b6d483a1bd7aa2bc5ae15e0450bdf (diff)
downloadmailman-a6fcb3e732fbf880e02a94ce8265be6624459ed8.tar.gz
mailman-a6fcb3e732fbf880e02a94ce8265be6624459ed8.tar.zst
mailman-a6fcb3e732fbf880e02a94ce8265be6624459ed8.zip
* Getting the roster or configuration of a nonexistent list did not give a
404 error (LP: #837676). Given by Stephen A. Goss.
Diffstat (limited to 'src/mailman/rest')
-rw-r--r--src/mailman/rest/lists.py4
-rw-r--r--src/mailman/rest/tests/test_lists.py89
2 files changed, 93 insertions, 0 deletions
diff --git a/src/mailman/rest/lists.py b/src/mailman/rest/lists.py
index 6a6388320..32aa607b6 100644
--- a/src/mailman/rest/lists.py
+++ b/src/mailman/rest/lists.py
@@ -155,11 +155,15 @@ class AList(_ListBase):
@resource.child(roster_matcher)
def roster(self, request, segments, role):
"""Return the collection of all a mailing list's members."""
+ if self._mlist is None:
+ return http.not_found()
return MembersOfList(self._mlist, role)
@resource.child(config_matcher)
def config(self, request, segments, attribute=None):
"""Return a mailing list configuration object."""
+ if self._mlist is None:
+ return http.not_found()
return ListConfiguration(self._mlist, attribute)
diff --git a/src/mailman/rest/tests/test_lists.py b/src/mailman/rest/tests/test_lists.py
new file mode 100644
index 000000000..fe8519404
--- /dev/null
+++ b/src/mailman/rest/tests/test_lists.py
@@ -0,0 +1,89 @@
+# Copyright (C) 2011 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
+
+"""REST list tests."""
+
+from __future__ import absolute_import, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+ 'test_suite',
+ ]
+
+
+import unittest
+
+from urllib2 import HTTPError
+
+from mailman.testing.helpers import call_api
+from mailman.testing.layers import RESTLayer
+
+
+
+class TestLists(unittest.TestCase):
+ layer = RESTLayer
+
+ def test_missing_list_roster_member_404(self):
+ # /lists/<missing>/roster/member gives 404
+ try:
+ # For Python 2.6.
+ call_api('http://localhost:9001/3.0/lists/missing@example.com'
+ '/roster/member')
+ except HTTPError as exc:
+ self.assertEqual(exc.code, 404)
+ else:
+ raise AssertionError('Expected HTTPError')
+
+ def test_missing_list_roster_owner_404(self):
+ # /lists/<missing>/roster/owner gives 404
+ try:
+ # For Python 2.6.
+ call_api('http://localhost:9001/3.0/lists/missing@example.com'
+ '/roster/owner')
+ except HTTPError as exc:
+ self.assertEqual(exc.code, 404)
+ else:
+ raise AssertionError('Expected HTTPError')
+
+ def test_missing_list_roster_moderator_404(self):
+ # /lists/<missing>/roster/member gives 404
+ try:
+ # For Python 2.6.
+ call_api('http://localhost:9001/3.0/lists/missing@example.com'
+ '/roster/moderator')
+ except HTTPError as exc:
+ self.assertEqual(exc.code, 404)
+ else:
+ raise AssertionError('Expected HTTPError')
+
+ def test_missing_list_configuration_404(self):
+ # /lists/<missing>/config gives 404
+ try:
+ # For Python 2.6.
+ call_api(
+ 'http://localhost:9001/3.0/lists/missing@example.com/config')
+ except HTTPError as exc:
+ self.assertEqual(exc.code, 404)
+ else:
+ raise AssertionError('Expected HTTPError')
+
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(TestLists))
+ return suite