summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/docs/NEWS.rst3
-rw-r--r--src/mailman/rest/members.py4
-rw-r--r--src/mailman/rest/tests/test_membership.py16
3 files changed, 22 insertions, 1 deletions
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst
index 98f8b5d70..0ef59266c 100644
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -65,6 +65,9 @@ Bugs
* In decoration URIs (e.g. ``IMailingList.header_uri`` and ``.footer_uri``)
you should now use the mailing list's List-ID instead of the
fqdn-listname. The latter is deprecated. (Closes #196)
+ * Trying to subscribe an address as a list owner (or moderator or nonmember)
+ which is already subscribed with that role produces a server error.
+ Originally given by Anirudh Dahiya. (Closes #198)
Configuration
-------------
diff --git a/src/mailman/rest/members.py b/src/mailman/rest/members.py
index 5ea5049c7..f9673e4fb 100644
--- a/src/mailman/rest/members.py
+++ b/src/mailman/rest/members.py
@@ -329,7 +329,9 @@ class AllMembers(_MemberBase):
bad_request(response, b'Membership is banned')
return
except AlreadySubscribedError:
- bad_request(response, email+' is already an owner of the list '+ mlist.list_name)
+ bad_request(response,
+ '{} is already an {} of {}'.format(
+ email, role.name, mlist.fqdn_listname))
return
# The subscription completed. Let's get the resulting member
# and return the location to the new member. Member ids are
diff --git a/src/mailman/rest/tests/test_membership.py b/src/mailman/rest/tests/test_membership.py
index 7659969fc..740fe82c5 100644
--- a/src/mailman/rest/tests/test_membership.py
+++ b/src/mailman/rest/tests/test_membership.py
@@ -633,3 +633,19 @@ class TestAPI31Members(unittest.TestCase):
# that's known to the system, in API 3.1. It's not technically a 404
# because that's reserved for URL lookups.
self.assertEqual(cm.exception.code, 400)
+
+ def test_duplicate_owner(self):
+ # Server failure when someone is already an owner.
+ with transaction():
+ anne = getUtility(IUserManager).create_address('anne@example.com')
+ self._mlist.subscribe(anne, MemberRole.owner)
+ with self.assertRaises(HTTPError) as cm:
+ call_api('http://localhost:9001/3.1/members', {
+ 'list_id': 'ant.example.com',
+ 'subscriber': anne.email,
+ 'role': 'owner',
+ })
+ self.assertEqual(cm.exception.code, 400)
+ self.assertEqual(
+ cm.exception.reason,
+ b'anne@example.com is already an owner of ant@example.com')