summaryrefslogtreecommitdiff
path: root/src/mailman
diff options
context:
space:
mode:
authorBarry Warsaw2015-04-13 13:16:22 -0400
committerBarry Warsaw2015-04-13 13:16:22 -0400
commit6f43b64a27f7e38df80a59f9111b5dedfac0d70f (patch)
treeda1d5948794a6c1dd65d661dc4dbd333631050f6 /src/mailman
parent044a780a7a62fabc4f97975dac2725e8df8cdebe (diff)
downloadmailman-6f43b64a27f7e38df80a59f9111b5dedfac0d70f.tar.gz
mailman-6f43b64a27f7e38df80a59f9111b5dedfac0d70f.tar.zst
mailman-6f43b64a27f7e38df80a59f9111b5dedfac0d70f.zip
Diffstat (limited to 'src/mailman')
-rw-r--r--src/mailman/app/subscriptions.py7
-rw-r--r--src/mailman/app/tests/test_subscriptions.py18
-rw-r--r--src/mailman/interfaces/member.py2
3 files changed, 24 insertions, 3 deletions
diff --git a/src/mailman/app/subscriptions.py b/src/mailman/app/subscriptions.py
index 982c04547..9df85c819 100644
--- a/src/mailman/app/subscriptions.py
+++ b/src/mailman/app/subscriptions.py
@@ -38,10 +38,12 @@ from mailman.core.i18n import _
from mailman.database.transaction import dbconnection
from mailman.email.message import UserNotification
from mailman.interfaces.address import IAddress
+from mailman.interfaces.bans import IBanManager
from mailman.interfaces.listmanager import (
IListManager, ListDeletingEvent, NoSuchListError)
from mailman.interfaces.mailinglist import SubscriptionPolicy
-from mailman.interfaces.member import DeliveryMode, MemberRole
+from mailman.interfaces.member import (
+ DeliveryMode, MemberRole, MembershipIsBannedError)
from mailman.interfaces.pending import IPendable, IPendings
from mailman.interfaces.subscriptions import (
ISubscriptionService, MissingUserError, RequestRecord)
@@ -166,6 +168,9 @@ class SubscriptionWorkflow(Workflow):
self.address = addresses[0]
assert self.user is not None and self.address is not None, (
'Insane sanity check results')
+ # Is this email address banned?
+ if IBanManager(self.mlist).is_banned(self.address.email):
+ raise MembershipIsBannedError(self.mlist, self.address.email)
self.push('verification_checks')
def _step_verification_checks(self):
diff --git a/src/mailman/app/tests/test_subscriptions.py b/src/mailman/app/tests/test_subscriptions.py
index 45e17a9e5..31218d2d7 100644
--- a/src/mailman/app/tests/test_subscriptions.py
+++ b/src/mailman/app/tests/test_subscriptions.py
@@ -29,7 +29,9 @@ import unittest
from mailman.app.lifecycle import create_list
from mailman.app.subscriptions import SubscriptionWorkflow
from mailman.interfaces.address import InvalidEmailAddressError
-from mailman.interfaces.member import MemberRole, MissingPreferredAddressError
+from mailman.interfaces.bans import IBanManager
+from mailman.interfaces.member import (
+ MemberRole, MembershipIsBannedError, MissingPreferredAddressError)
from mailman.interfaces.requests import IListRequests, RequestType
from mailman.interfaces.subscriptions import (
MissingUserError, ISubscriptionService)
@@ -153,6 +155,20 @@ class TestSubscriptionWorkflow(unittest.TestCase):
workflow = SubscriptionWorkflow(self._mlist, user)
self.assertRaises(AssertionError, workflow.run_thru, 'sanity_checks')
+ def test_sanity_checks_globally_banned_address(self):
+ # An exception is raised if the address is globally banned.
+ anne = self._user_manager.create_address(self._anne)
+ IBanManager(None).ban(self._anne)
+ workflow = SubscriptionWorkflow(self._mlist, anne)
+ self.assertRaises(MembershipIsBannedError, list, workflow)
+
+ def test_sanity_checks_banned_address(self):
+ # An exception is raised if the address is banned by the mailing list.
+ anne = self._user_manager.create_address(self._anne)
+ IBanManager(self._mlist).ban(self._anne)
+ workflow = SubscriptionWorkflow(self._mlist, anne)
+ self.assertRaises(MembershipIsBannedError, list, workflow)
+
def test_verification_checks_with_verified_address(self):
# When the address is already verified, we skip straight to the
# confirmation checks.
diff --git a/src/mailman/interfaces/member.py b/src/mailman/interfaces/member.py
index c06cc95b1..4e1ef6d37 100644
--- a/src/mailman/interfaces/member.py
+++ b/src/mailman/interfaces/member.py
@@ -123,7 +123,7 @@ class MembershipIsBannedError(MembershipError):
"""The address is not allowed to subscribe to the mailing list."""
def __init__(self, mlist, address):
- super(MembershipIsBannedError, self).__init__()
+ super().__init__()
self._mlist = mlist
self._address = address