summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/commands/eml_confirm.py5
-rw-r--r--src/mailman/commands/eml_membership.py2
-rw-r--r--src/mailman/commands/tests/test_confirm.py32
-rw-r--r--src/mailman/docs/NEWS.rst1
4 files changed, 35 insertions, 5 deletions
diff --git a/src/mailman/commands/eml_confirm.py b/src/mailman/commands/eml_confirm.py
index 089b90848..ddcb81132 100644
--- a/src/mailman/commands/eml_confirm.py
+++ b/src/mailman/commands/eml_confirm.py
@@ -53,7 +53,10 @@ class Confirm:
mlist).confirm(token)
if new_token is None:
assert token_owner is TokenOwner.no_one, token_owner
- assert member is not None, member
+ # We can't assert anything about member. It will be None when
+ # the workflow we're confirming is an unsubscription request,
+ # and non-None when we're confirming a subscription request.
+ # This class doesn't know which is happening.
succeeded = True
elif token_owner is TokenOwner.moderator:
# This must have been a confirm-then-moderator subscription.
diff --git a/src/mailman/commands/eml_membership.py b/src/mailman/commands/eml_membership.py
index 8090c0a2a..d444595c7 100644
--- a/src/mailman/commands/eml_membership.py
+++ b/src/mailman/commands/eml_membership.py
@@ -198,7 +198,7 @@ You may be asked to confirm your request.""")
already_left.add(email)
manager = ISubscriptionManager(mlist)
token, token_owner, member = manager.unregister(user_address)
- person = formataddr((user.display_name, email)) # noqa
+ person = formataddr((user.display_name, email)) # noqa: F841
if member is None:
print(_('$person left $mlist.fqdn_listname'), file=results)
else:
diff --git a/src/mailman/commands/tests/test_confirm.py b/src/mailman/commands/tests/test_confirm.py
index 650d37e29..1ef392b76 100644
--- a/src/mailman/commands/tests/test_confirm.py
+++ b/src/mailman/commands/tests/test_confirm.py
@@ -28,13 +28,15 @@ from mailman.interfaces.mailinglist import SubscriptionPolicy
from mailman.interfaces.subscriptions import ISubscriptionManager
from mailman.interfaces.usermanager import IUserManager
from mailman.runners.command import CommandRunner, Results
-from mailman.testing.helpers import get_queue_messages, make_testable_runner
+from mailman.testing.helpers import (
+ get_queue_messages, make_testable_runner,
+ specialized_message_from_string as mfs, subscribe)
from mailman.testing.layers import ConfigLayer
from zope.component import getUtility
-class TestConfirm(unittest.TestCase):
- """Test the `confirm` command."""
+class TestConfirmJoin(unittest.TestCase):
+ """Test the `confirm` command when joining a mailing list."""
layer = ConfigLayer
@@ -72,6 +74,30 @@ class TestConfirm(unittest.TestCase):
get_queue_messages('virgin', expected_count=0)
+class TestConfirmLeave(unittest.TestCase):
+ """Test the `confirm` command when leaving a mailing list."""
+
+ layer = ConfigLayer
+
+ def setUp(self):
+ self._mlist = create_list('test@example.com')
+ anne = subscribe(self._mlist, 'Anne', email='anne@example.com')
+ self._token, token_owner, member = ISubscriptionManager(
+ self._mlist).unregister(anne.address)
+
+ def test_confirm_leave(self):
+ msg = mfs("""\
+From: Anne Person <anne@example.com>
+To: test-confirm+{token}@example.com
+Subject: Re: confirm {token}
+
+""".format(token=self._token))
+ Confirm().process(self._mlist, msg, {}, (self._token,), Results())
+ # Anne is no longer a member of the mailing list.
+ member = self._mlist.members.get_member('anne@example.com')
+ self.assertIsNone(member)
+
+
class TestEmailResponses(unittest.TestCase):
"""Test the `confirm` command through the command runner."""
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst
index 6849a1191..5736c1354 100644
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -105,6 +105,7 @@ Bugs
Abhilash Raj. (Closes: #214)
* Messages were shunted when non-ASCII characters appeared in a mailing
list's description. Given by Mark Sapiro. (Closes: #215)
+ * Fix confirmation of unsubscription requests. (Closes: #294)
Configuration
-------------