diff options
| author | Aurélien Bompard | 2016-09-05 20:35:55 +0200 |
|---|---|---|
| committer | Aurélien Bompard | 2016-11-21 18:53:44 +0100 |
| commit | 30be8bfca274d69ced55e9fdadc8dbff379bf5ab (patch) | |
| tree | c108ea8f3afaeff51925cd8fdbb49c34c3d57bd6 | |
| parent | f516c2bcb2b44aa8e1180a334e055a873af249da (diff) | |
| download | mailman-30be8bfca274d69ced55e9fdadc8dbff379bf5ab.tar.gz mailman-30be8bfca274d69ced55e9fdadc8dbff379bf5ab.tar.zst mailman-30be8bfca274d69ced55e9fdadc8dbff379bf5ab.zip | |
| -rw-r--r-- | src/mailman/app/subscriptions.py | 3 | ||||
| -rw-r--r-- | src/mailman/app/tests/test_subscriptions.py | 37 |
2 files changed, 39 insertions, 1 deletions
diff --git a/src/mailman/app/subscriptions.py b/src/mailman/app/subscriptions.py index 9e8d8dd9d..f88a967c2 100644 --- a/src/mailman/app/subscriptions.py +++ b/src/mailman/app/subscriptions.py @@ -102,7 +102,8 @@ class _SubscriptionWorkflowCommon(Workflow): # For restore. uid = uuid.UUID(hex_key) self.user = getUtility(IUserManager).get_user_by_id(uid) - assert self.user is not None + if self.user is None: + self.user = self.address.user @property def address_key(self): diff --git a/src/mailman/app/tests/test_subscriptions.py b/src/mailman/app/tests/test_subscriptions.py index f7b9b584e..31c34b802 100644 --- a/src/mailman/app/tests/test_subscriptions.py +++ b/src/mailman/app/tests/test_subscriptions.py @@ -675,3 +675,40 @@ approval: self.assertIsNone(workflow.token) self.assertEqual(workflow.token_owner, TokenOwner.no_one) self.assertEqual(workflow.member.address, anne) + + def test_restore_user_absorbed(self): + # The subscribing user is absorbed (and thus deleted) before the + # moderator approves the subscription. + self._mlist.subscription_policy = SubscriptionPolicy.moderate + anne = self._user_manager.create_user(self._anne) + bill = self._user_manager.create_user('bill@example.com') + # anne subscribes. + workflow = SubscriptionWorkflow(self._mlist, anne, pre_verified=True) + list(workflow) + # bill absorbs anne. + bill.absorb(anne) + # anne's subscription request is approved. + approved_workflow = SubscriptionWorkflow(self._mlist) + approved_workflow.token = workflow.token + approved_workflow.restore() + self.assertEqual(approved_workflow.user, bill) + + def test_restore_address_absorbed(self): + # The subscribing user is absorbed (and thus deleted) before the + # moderator approves the subscription. + self._mlist.subscription_policy = SubscriptionPolicy.moderate + anne = self._user_manager.create_user(self._anne) + anne_address = anne.addresses[0] + bill = self._user_manager.create_user('bill@example.com') + # anne subscribes. + workflow = SubscriptionWorkflow( + self._mlist, anne_address, pre_verified=True) + list(workflow) + # bill absorbs anne. + bill.absorb(anne) + self.assertIn(anne_address, bill.addresses) + # anne's subscription request is approved. + approved_workflow = SubscriptionWorkflow(self._mlist) + approved_workflow.token = workflow.token + approved_workflow.restore() + self.assertEqual(approved_workflow.user, bill) |
