diff options
Diffstat (limited to 'src/mailman_pgp/mta')
| -rw-r--r-- | src/mailman_pgp/mta/bulk.py | 11 | ||||
| -rw-r--r-- | src/mailman_pgp/mta/personalized.py | 9 | ||||
| -rw-r--r-- | src/mailman_pgp/mta/tests/test_bulk.py | 27 | ||||
| -rw-r--r-- | src/mailman_pgp/mta/tests/test_personalized.py | 20 |
4 files changed, 27 insertions, 40 deletions
diff --git a/src/mailman_pgp/mta/bulk.py b/src/mailman_pgp/mta/bulk.py index a01b5a7..1c4f213 100644 --- a/src/mailman_pgp/mta/bulk.py +++ b/src/mailman_pgp/mta/bulk.py @@ -24,7 +24,6 @@ from public import public from mailman_pgp.model.address import PGPAddress from mailman_pgp.model.list import PGPMailingList from mailman_pgp.pgp.mime import MIMEWrapper -from mailman_pgp.utils.email import overwrite_message class CallbackBulkDelivery(BulkDelivery): @@ -92,16 +91,14 @@ class PGPBulkMixin: wrapped = MIMEWrapper(msg) if pgp_list.sign_outgoing: if pgp_list.encrypt_outgoing: - out = wrapped.sign_encrypt(pgp_list.key, pgp_list.pubkey, - *keys, throw_keyid=True) + wrapped.sign_encrypt(pgp_list.key, pgp_list.pubkey, + *keys, throw_keyid=True) else: - out = wrapped.sign(pgp_list.key) + wrapped.sign(pgp_list.key) else: # Definitely encrypt here, the case where we don't encrypt or sign # is handled above at the start of the func. - out = wrapped.encrypt(pgp_list.pubkey, *keys, throw_keyid=True) - - overwrite_message(out, msg) + wrapped.encrypt(pgp_list.pubkey, *keys, throw_keyid=True) @public diff --git a/src/mailman_pgp/mta/personalized.py b/src/mailman_pgp/mta/personalized.py index 9fcc282..5c12a0c 100644 --- a/src/mailman_pgp/mta/personalized.py +++ b/src/mailman_pgp/mta/personalized.py @@ -25,7 +25,6 @@ from public import public from mailman_pgp.model.address import PGPAddress from mailman_pgp.model.list import PGPMailingList from mailman_pgp.pgp.mime import MIMEWrapper -from mailman_pgp.utils.email import overwrite_message class PGPIndividualMixin: @@ -63,15 +62,13 @@ class PGPIndividualMixin: if pgp_list.sign_outgoing: if pgp_list.encrypt_outgoing: - out = wrapped.sign_encrypt(pgp_list.key, key, pgp_list.pubkey) + wrapped.sign_encrypt(pgp_list.key, key, pgp_list.pubkey) else: - out = wrapped.sign(pgp_list.key) + wrapped.sign(pgp_list.key) else: # Definitely encrypt here, the case where we don't encrypt or sign # is handled above at the start of the func. - out = wrapped.encrypt(key, pgp_list.pubkey) - - overwrite_message(out, msg) + wrapped.encrypt(key, pgp_list.pubkey) @public diff --git a/src/mailman_pgp/mta/tests/test_bulk.py b/src/mailman_pgp/mta/tests/test_bulk.py index 02c5bf2..e9f77d0 100644 --- a/src/mailman_pgp/mta/tests/test_bulk.py +++ b/src/mailman_pgp/mta/tests/test_bulk.py @@ -99,20 +99,17 @@ Subject: test out_wrapped = PGPWrapper(out_msg) self.assertTrue(out_wrapped.is_encrypted()) - decrypted = out_wrapped.decrypt(self.list_key) - wrapped = PGPWrapper(decrypted) - self.assertTrue(wrapped.is_signed()) - self.assertTrue(verifies(wrapped.verify(self.list_key.pubkey))) + decrypted = out_wrapped.copy().decrypt(self.list_key) + self.assertTrue(decrypted.is_signed()) + self.assertTrue(verifies(decrypted.verify(self.list_key.pubkey))) - decrypted = out_wrapped.decrypt(self.anne_key) - wrapped = PGPWrapper(decrypted) - self.assertTrue(wrapped.is_signed()) - self.assertTrue(verifies(wrapped.verify(self.list_key.pubkey))) + decrypted = out_wrapped.copy().decrypt(self.anne_key) + self.assertTrue(decrypted.is_signed()) + self.assertTrue(verifies(decrypted.verify(self.list_key.pubkey))) - decrypted = out_wrapped.decrypt(self.bart_key) - wrapped = PGPWrapper(decrypted) - self.assertTrue(wrapped.is_signed()) - self.assertTrue(verifies(wrapped.verify(self.list_key.pubkey))) + decrypted = out_wrapped.copy().decrypt(self.bart_key) + self.assertTrue(decrypted.is_signed()) + self.assertTrue(verifies(decrypted.verify(self.list_key.pubkey))) def test_encrypt(self): with transaction(): @@ -129,9 +126,9 @@ Subject: test out_msg = agent.deliveries[0][1] wrapped = PGPWrapper(out_msg) self.assertTrue(wrapped.is_encrypted()) - wrapped.decrypt(self.list_key) - wrapped.decrypt(self.anne_key) - wrapped.decrypt(self.bart_key) + wrapped.copy().decrypt(self.list_key) + wrapped.copy().decrypt(self.anne_key) + wrapped.copy().decrypt(self.bart_key) def test_sign(self): with transaction(): diff --git a/src/mailman_pgp/mta/tests/test_personalized.py b/src/mailman_pgp/mta/tests/test_personalized.py index 7f4caa8..953ef55 100644 --- a/src/mailman_pgp/mta/tests/test_personalized.py +++ b/src/mailman_pgp/mta/tests/test_personalized.py @@ -89,13 +89,11 @@ Subject: test out_wrapped = PGPWrapper(out_msg) self.assertTrue(out_wrapped.is_encrypted()) - decrypted = out_wrapped.decrypt(self.list_key) - wrapped = PGPWrapper(decrypted) - self.assertTrue(wrapped.is_signed()) + decrypted = out_wrapped.copy().decrypt(self.list_key) + self.assertTrue(decrypted.is_signed()) - decrypted = out_wrapped.decrypt(self.anne_key) - wrapped = PGPWrapper(decrypted) - self.assertTrue(wrapped.is_signed()) + decrypted = out_wrapped.copy().decrypt(self.anne_key) + self.assertTrue(decrypted.is_signed()) def test_encrypt(self): with transaction(): @@ -113,13 +111,11 @@ Subject: test out_wrapped = PGPWrapper(out_msg) self.assertTrue(out_wrapped.is_encrypted()) - decrypted = out_wrapped.decrypt(self.list_key) - wrapped = PGPWrapper(decrypted) - self.assertFalse(wrapped.is_signed()) + decrypted = out_wrapped.copy().decrypt(self.list_key) + self.assertFalse(decrypted.is_signed()) - decrypted = out_wrapped.decrypt(self.anne_key) - wrapped = PGPWrapper(decrypted) - self.assertFalse(wrapped.is_signed()) + decrypted = out_wrapped.copy().decrypt(self.anne_key) + self.assertFalse(decrypted.is_signed()) def test_sign(self): with transaction(): |
