Barry Warsaw pushed to branch release-3.0 at mailman / Mailman
Commits:
0f2c7888 by Barry Warsaw at 2016-02-16T08:45:03-05:00
Handle AlreadySubscribedError in REST.
When approving a subscription request via the REST API, for a user who is
already a member, return an HTTP 409 Conflict code instead of the previous
server traceback (and resulting HTTP 500 code).
Closes #193
Bump to version 3.0.3
- - - - -
4 changed files:
- src/mailman/docs/NEWS.rst
- src/mailman/rest/sub_moderation.py
- src/mailman/rest/tests/test_moderation.py
- src/mailman/version.py
Changes:
=====================================
src/mailman/docs/NEWS.rst
=====================================
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -8,6 +8,17 @@ Copyright (C) 1998-2016 by the Free Software Foundation, Inc.
Here is a history of user visible changes to Mailman.
+3.0.3 -- "Show Don't Tell"
+==========================
+(2016-XX-XX)
+
+Bugs
+----
+ * When approving a subscription request via the REST API, for a user who is
+ already a member, return an HTTP 409 Conflict code instead of the previous
+ server traceback (and resulting HTTP 500 code). (Closes: #193)
+
+
3.0.2 -- "Show Don't Tell"
==========================
(2016-02-08)
=====================================
src/mailman/rest/sub_moderation.py
=====================================
--- a/src/mailman/rest/sub_moderation.py
+++ b/src/mailman/rest/sub_moderation.py
@@ -24,10 +24,12 @@ __all__ = [
from mailman.app.moderator import send_rejection
from mailman.interfaces.action import Action
+from mailman.interfaces.member import AlreadySubscribedError
from mailman.interfaces.pending import IPendings
from mailman.interfaces.registrar import IRegistrar
from mailman.rest.helpers import (
- CollectionMixin, bad_request, child, etag, no_content, not_found, okay)
+ CollectionMixin, bad_request, child, conflict, etag, no_content,
+ not_found, okay)
from mailman.rest.validator import Validator, enum_validator
from mailman.utilities.i18n import _
from zope.component import getUtility
@@ -91,6 +93,8 @@ class IndividualRequest(_ModerationBase):
self._registrar.confirm(self._token)
except LookupError:
not_found(response)
+ except AlreadySubscribedError:
+ conflict(response, 'Already subscribed')
else:
no_content(response)
elif action is Action.discard:
=====================================
src/mailman/rest/tests/test_moderation.py
=====================================
--- a/src/mailman/rest/tests/test_moderation.py
+++ b/src/mailman/rest/tests/test_moderation.py
@@ -223,6 +223,21 @@ class TestSubscriptionModeration(unittest.TestCase):
))
self.assertEqual(cm.exception.code, 404)
+ def test_accept_already_subscribed(self):
+ # POST to a subscription request, but the user is already subscribed.
+ with transaction():
+ token, token_owner, member = self._registrar.register(self._anne)
+ # Make Anne already a member.
+ self._mlist.subscribe(self._anne)
+ # Accept the pending subscription, which raises an error.
+ url = 'http://localhost:9001/3.0/lists/ant.example.com/requests/{}'
+ with self.assertRaises(HTTPError) as cm:
+ call_api(url.format(token), dict(
+ action='accept',
+ ))
+ self.assertEqual(cm.exception.code, 409)
+ self.assertEqual(cm.exception.reason, b'Already subscribed')
+
def test_accept_bad_token(self):
# Try to accept a request with a bogus token.
with self.assertRaises(HTTPError) as cm:
=====================================
src/mailman/version.py
=====================================
--- a/src/mailman/version.py
+++ b/src/mailman/version.py
@@ -18,7 +18,7 @@
"""Mailman version strings."""
# Mailman version.
-VERSION = '3.0.2'
+VERSION = '3.0.2+'
CODENAME = "Show Don't Tell"
# And as a hex number in the manner of PY_VERSION_HEX.
@@ -31,7 +31,7 @@ FINAL = 0xf
MAJOR_REV = 3
MINOR_REV = 0
-MICRO_REV = 2
+MICRO_REV = 3
REL_LEVEL = FINAL
# At most 15 beta releases!
REL_SERIAL = 0
View it on GitLab:
https://gitlab.com/mailman/mailman/commit/0f2c7888c4360d677cd0887d7ca01037f42ed0f8
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org