aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman_pgp/mta/personalized.py10
-rw-r--r--src/mailman_pgp/mta/tests/test_personalized.py18
2 files changed, 25 insertions, 3 deletions
diff --git a/src/mailman_pgp/mta/personalized.py b/src/mailman_pgp/mta/personalized.py
index d05cc4b..2b6d228 100644
--- a/src/mailman_pgp/mta/personalized.py
+++ b/src/mailman_pgp/mta/personalized.py
@@ -49,10 +49,10 @@ class PGPIndividualMixin:
recipient = msgdata['recipient']
pgp_address = PGPAddress.for_email(recipient)
if pgp_address is None:
- # TODO: log failure here
+ msgdata['no_deliver'] = True
return
if pgp_address.key is None or not pgp_address.key_confirmed:
- # TODO: log failure here?
+ msgdata['no_deliver'] = True
return
key = pgp_address.key
@@ -84,3 +84,9 @@ class PGPPersonalizedDelivery(IndividualDelivery, VERPMixin, DecoratingMixin,
self.personalize_to,
self.sign_encrypt
])
+
+ def _deliver_to_recipients(self, mlist, msg, msgdata, recipients):
+ if msgdata.get('no_deliver', False):
+ return dict((recipient, (444, BaseException)) for recipient in
+ recipients)
+ return super()._deliver_to_recipients(mlist, msg, msgdata, recipients)
diff --git a/src/mailman_pgp/mta/tests/test_personalized.py b/src/mailman_pgp/mta/tests/test_personalized.py
index d9d0132..9200a3b 100644
--- a/src/mailman_pgp/mta/tests/test_personalized.py
+++ b/src/mailman_pgp/mta/tests/test_personalized.py
@@ -162,4 +162,20 @@ Subject: test
refused = agent.deliver(ordinary_list, self.msg, msgdata)
self.assertEqual(len(refused), 0)
- self.assertEqual(len(agent.deliveries), 1) \ No newline at end of file
+ self.assertEqual(len(agent.deliveries), 1)
+
+ def test_no_pgp_address(self):
+ msgdata = dict(recipients=['someone@example.org'])
+ agent = PGPPersonalizedDelivery()
+ refused = agent.deliver(self.mlist, self.msg, msgdata)
+
+ self.assertEqual(len(refused), 1)
+
+ def test_no_key(self):
+ with transaction():
+ self.pgp_anne.key = None
+ msgdata = dict(recipients=['anne@example.org'])
+ agent = PGPPersonalizedDelivery()
+ refused = agent.deliver(self.mlist, self.msg, msgdata)
+
+ self.assertEqual(len(refused), 1)