summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2011-09-13 18:46:15 -0400
committerBarry Warsaw2011-09-13 18:46:15 -0400
commite4b34fefabd2ae3f14db83e96076fe741aa7c5b8 (patch)
treefe270eab386ca1d8c1f62fd6de25398628bd0ac4 /src
parent04346ba3154f94775f9cd693a73209848ab26dfc (diff)
downloadmailman-e4b34fefabd2ae3f14db83e96076fe741aa7c5b8.tar.gz
mailman-e4b34fefabd2ae3f14db83e96076fe741aa7c5b8.tar.zst
mailman-e4b34fefabd2ae3f14db83e96076fe741aa7c5b8.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/docs/NEWS.rst2
-rw-r--r--src/mailman/rest/addresses.py2
-rw-r--r--src/mailman/rest/tests/test_addresses.py62
-rw-r--r--src/mailman/rest/tests/test_users.py3
4 files changed, 66 insertions, 3 deletions
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst
index 548632a85..3c175d0ed 100644
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -60,6 +60,8 @@ REST
404 error (LP: #837676). Given by Stephen A. Goss.
* PATCHing an invalid attribute on a member did not give a 400 error
(LP: #833376). Given by Stephen A. Goss.
+ * Getting the memberships for a non-existent address did not give a 404 error
+ (LP: #848103). Given by Stephen A. Goss.
Commands
--------
diff --git a/src/mailman/rest/addresses.py b/src/mailman/rest/addresses.py
index f77dc0a05..a97043e9c 100644
--- a/src/mailman/rest/addresses.py
+++ b/src/mailman/rest/addresses.py
@@ -98,6 +98,8 @@ class AnAddress(_AddressBase):
"""/addresses/<email>/memberships"""
if len(segments) != 0:
return http.bad_request()
+ if self._address is None:
+ return http.not_found()
return AddressMemberships(self._address)
diff --git a/src/mailman/rest/tests/test_addresses.py b/src/mailman/rest/tests/test_addresses.py
new file mode 100644
index 000000000..113ed1b25
--- /dev/null
+++ b/src/mailman/rest/tests/test_addresses.py
@@ -0,0 +1,62 @@
+# 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 address tests."""
+
+from __future__ import absolute_import, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+ 'test_suite',
+ ]
+
+
+import unittest
+
+from urllib2 import HTTPError
+
+from mailman.app.lifecycle import create_list
+from mailman.config import config
+from mailman.testing.helpers import call_api
+from mailman.testing.layers import RESTLayer
+
+
+
+class TestAddresses(unittest.TestCase):
+ layer = RESTLayer
+
+ def setUp(self):
+ self._mlist = create_list('test@example.com')
+ config.db.commit()
+
+ def test_membership_of_missing_address(self):
+ # Try to get the memberships of a missing address.
+ try:
+ # For Python 2.6.
+ call_api('http://localhost:9001/3.0/addresses/'
+ 'nobody@example.com/memberships')
+ except HTTPError as exc:
+ self.assertEqual(exc.code, 404)
+ else:
+ raise AssertionError('Expected HTTPError')
+
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(TestAddresses))
+ return suite
diff --git a/src/mailman/rest/tests/test_users.py b/src/mailman/rest/tests/test_users.py
index 8b31010f3..72a52af24 100644
--- a/src/mailman/rest/tests/test_users.py
+++ b/src/mailman/rest/tests/test_users.py
@@ -28,11 +28,9 @@ __all__ = [
import unittest
from urllib2 import HTTPError
-from zope.component import getUtility
from mailman.app.lifecycle import create_list
from mailman.config import config
-from mailman.interfaces.usermanager import IUserManager
from mailman.testing.helpers import call_api
from mailman.testing.layers import RESTLayer
@@ -44,7 +42,6 @@ class TestUsers(unittest.TestCase):
def setUp(self):
self._mlist = create_list('test@example.com')
config.db.commit()
- self._usermanager = getUtility(IUserManager)
def test_delete_bogus_user(self):
# Try to delete a user that does not exist.