diff options
| author | J08nY | 2017-07-19 18:02:16 +0200 |
|---|---|---|
| committer | J08nY | 2017-07-19 18:02:16 +0200 |
| commit | caefb5542ddde4760b6688e6ea33eb426a9a3099 (patch) | |
| tree | c6e1d2d2ef40f090f2995df4ca1911bc75d11d7a /src/mailman_pgp/mta | |
| parent | bab583cc1b5a6f9447e00aaa06de6733357a139a (diff) | |
| download | mailman-pgp-caefb5542ddde4760b6688e6ea33eb426a9a3099.tar.gz mailman-pgp-caefb5542ddde4760b6688e6ea33eb426a9a3099.tar.zst mailman-pgp-caefb5542ddde4760b6688e6ea33eb426a9a3099.zip | |
Diffstat (limited to 'src/mailman_pgp/mta')
| -rw-r--r-- | src/mailman_pgp/mta/personalized.py | 10 | ||||
| -rw-r--r-- | src/mailman_pgp/mta/tests/test_personalized.py | 18 |
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) |
