← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/mailman-deny-suspended into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/mailman-deny-suspended into lp:launchpad.

Commit message:
Fix MailingListAPIView.isRegisteredInLaunchpad to reject suspended accounts.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/mailman-deny-suspended/+merge/292147

Fix MailingListAPIView.isRegisteredInLaunchpad to reject suspended accounts.

Suspension should revoke all privileges, as it's often used as an anti-spam measure.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/mailman-deny-suspended into lp:launchpad.
=== modified file 'lib/lp/registry/tests/test_mailinglistapi.py'
--- lib/lp/registry/tests/test_mailinglistapi.py	2012-09-28 06:15:58 +0000
+++ lib/lp/registry/tests/test_mailinglistapi.py	2016-04-18 13:08:54 +0000
@@ -31,10 +31,11 @@
     MailingListAPIView,
     )
 from lp.services.config import config
+from lp.services.identity.interfaces.account import AccountStatus
 from lp.services.identity.interfaces.emailaddress import EmailAddressStatus
 from lp.services.messages.interfaces.message import IMessageSet
 from lp.testing import (
-    celebrity_logged_in,
+    admin_logged_in,
     person_logged_in,
     TestCaseWithFactory,
     )
@@ -132,11 +133,12 @@
         self.factory.makeTeam(email='me@xxxxxxxxx')
         self.assertFalse(self.api.isRegisteredInLaunchpad('me@xxxxxxxxx'))
 
-    def test_isTeamPublic(self):
-        self.factory.makeTeam(
-            name='team-b', visibility=PersonVisibility.PRIVATE)
-        self.assertIs(True, self.api.isTeamPublic('team-a'))
-        self.assertIs(False, self.api.isTeamPublic('team-b'))
+    def test_isRegisteredInLaunchpad_suspended(self):
+        person = self.factory.makePerson(email='me@xxxxxxxxx')
+        self.assertTrue(self.api.isRegisteredInLaunchpad('me@xxxxxxxxx'))
+        with admin_logged_in():
+            person.setAccountStatus(AccountStatus.SUSPENDED, None, 'Spammer!')
+        self.assertFalse(self.api.isRegisteredInLaunchpad('me@xxxxxxxxx'))
 
     def test_isTeamPublic_fault(self):
         self.assertIsInstance(
@@ -145,7 +147,7 @@
     def test_inGoodStanding(self):
         self.factory.makePerson(email='no@xxxxxx')
         yes_person = self.factory.makePerson(email='yes@xxxxxx')
-        with celebrity_logged_in('admin'):
+        with admin_logged_in():
             yes_person.personal_standing = PersonalStanding.GOOD
         self.assertIs(True, self.api.inGoodStanding('yes@xxxxxx'))
         self.assertIs(False, self.api.inGoodStanding('no@xxxxxx'))

=== modified file 'lib/lp/registry/xmlrpc/mailinglist.py'
--- lib/lp/registry/xmlrpc/mailinglist.py	2015-07-08 16:05:11 +0000
+++ lib/lp/registry/xmlrpc/mailinglist.py	2016-04-18 13:08:54 +0000
@@ -29,6 +29,9 @@
     )
 from lp.services.config import config
 from lp.services.encoding import escape_nonascii_uniquely
+from lp.services.identity.interfaces.account import (
+    INACTIVE_ACCOUNT_STATUSES,
+    )
 from lp.services.identity.interfaces.emailaddress import (
     EmailAddressStatus,
     IEmailAddressSet,
@@ -223,8 +226,11 @@
             # discarded.
             return False
         email_address = getUtility(IEmailAddressSet).getByEmail(address)
-        return (email_address is not None and
-                not email_address.person.is_team and
+        if email_address is None:
+            return False
+        person = email_address.person
+        return (not person.is_team and
+                person.account_status not in INACTIVE_ACCOUNT_STATUSES and
                 email_address.status in (EmailAddressStatus.VALIDATED,
                                          EmailAddressStatus.PREFERRED))
 


Follow ups