diff options
| author | Barry Warsaw | 2016-03-22 21:56:53 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2016-03-22 21:56:53 -0400 |
| commit | bc3c325683657d62a1d9864a289023ebccc779c8 (patch) | |
| tree | 1b025f7e91f3d6f4c7515b49ce3d06de4ea6e2be /src/mailman/rest/tests/test_membership.py | |
| parent | 99b8c0bd9fb4282dc2a692e236ebb7d8747af037 (diff) | |
| download | mailman-bc3c325683657d62a1d9864a289023ebccc779c8.tar.gz mailman-bc3c325683657d62a1d9864a289023ebccc779c8.tar.zst mailman-bc3c325683657d62a1d9864a289023ebccc779c8.zip | |
Diffstat (limited to 'src/mailman/rest/tests/test_membership.py')
| -rw-r--r-- | src/mailman/rest/tests/test_membership.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/mailman/rest/tests/test_membership.py b/src/mailman/rest/tests/test_membership.py index 740fe82c5..57f641007 100644 --- a/src/mailman/rest/tests/test_membership.py +++ b/src/mailman/rest/tests/test_membership.py @@ -30,7 +30,10 @@ from mailman.app.lifecycle import create_list from mailman.config import config from mailman.database.transaction import transaction from mailman.interfaces.bans import IBanManager +from mailman.interfaces.mailinglist import SubscriptionPolicy from mailman.interfaces.member import DeliveryMode, MemberRole +from mailman.interfaces.registrar import IRegistrar +from mailman.interfaces.subscriptions import TokenOwner from mailman.interfaces.usermanager import IUserManager from mailman.testing.helpers import ( TestableMaster, call_api, get_lmtp_client, make_testable_runner, @@ -217,6 +220,52 @@ class TestMembership(unittest.TestCase): 'http://localhost:9001/3.0/addresses/anne@example.com') self.assertEqual(entry_0['list_id'], 'test.example.com') + def test_duplicate_pending_subscription(self): + # Issue #199 - a member's subscription is already pending and they try + # to subscribe again. + registrar = IRegistrar(self._mlist) + with transaction(): + self._mlist.subscription_policy = SubscriptionPolicy.moderate + anne = self._usermanager.create_address('anne@example.com') + token, token_owner, member = registrar.register( + anne, pre_verified=True, pre_confirmed=True) + self.assertEqual(token_owner, TokenOwner.moderator) + self.assertIsNone(member) + with self.assertRaises(HTTPError) as cm: + call_api('http://localhost:9001/3.0/members', { + 'list_id': 'test.example.com', + 'subscriber': 'anne@example.com', + 'pre_verified': True, + 'pre_confirmed': True, + }) + self.assertEqual(cm.exception.code, 409) + self.assertEqual(cm.exception.reason, + b'Subscription request already pending') + + def test_duplicate_other_pending_subscription(self): + # Issue #199 - a member's subscription is already pending and they try + # to subscribe again. Unlike above, this pend is waiting for the user + # to confirm their subscription. + registrar = IRegistrar(self._mlist) + with transaction(): + self._mlist.subscription_policy = ( + SubscriptionPolicy.confirm_then_moderate) + anne = self._usermanager.create_address('anne@example.com') + token, token_owner, member = registrar.register( + anne, pre_verified=True) + self.assertEqual(token_owner, TokenOwner.subscriber) + self.assertIsNone(member) + with self.assertRaises(HTTPError) as cm: + call_api('http://localhost:9001/3.0/members', { + 'list_id': 'test.example.com', + 'subscriber': 'anne@example.com', + 'pre_verified': True, + 'pre_confirmed': True, + }) + self.assertEqual(cm.exception.code, 409) + self.assertEqual(cm.exception.reason, + b'Subscription request already pending') + def test_member_changes_preferred_address(self): with transaction(): anne = self._usermanager.create_user('anne@example.com') |
