diff options
| author | J08nY | 2017-08-21 20:57:21 +0200 |
|---|---|---|
| committer | J08nY | 2017-08-21 20:57:21 +0200 |
| commit | 006e63dd02ae03e4e0d29405ba7b8c530a20fc9c (patch) | |
| tree | f9b658cf95d6945ac4c84444d6ac8be345529733 /src/mailman_pgp/rules | |
| parent | 8f105928b6d79a5bd56ae20bec0dd288136ddf9f (diff) | |
| download | mailman-pgp-006e63dd02ae03e4e0d29405ba7b8c530a20fc9c.tar.gz mailman-pgp-006e63dd02ae03e4e0d29405ba7b8c530a20fc9c.tar.zst mailman-pgp-006e63dd02ae03e4e0d29405ba7b8c530a20fc9c.zip | |
Add config option to disable sig hash collecting.
Diffstat (limited to 'src/mailman_pgp/rules')
| -rw-r--r-- | src/mailman_pgp/rules/signature.py | 6 | ||||
| -rw-r--r-- | src/mailman_pgp/rules/tests/test_signature.py | 14 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/mailman_pgp/rules/signature.py b/src/mailman_pgp/rules/signature.py index ae27bb5..2e1728b 100644 --- a/src/mailman_pgp/rules/signature.py +++ b/src/mailman_pgp/rules/signature.py @@ -28,6 +28,7 @@ from zope.component import getUtility from zope.event import classhandler from zope.interface import implementer +from mailman_pgp.config import config from mailman_pgp.database import transaction from mailman_pgp.model.address import PGPAddress from mailman_pgp.model.list import PGPMailingList @@ -133,9 +134,6 @@ class Signature: return True msgdata['pgp_sig_hashes'] = sig_hashes - # XXX: we need to track key revocation separately to use it here - # TODO: check key revocation here - return False @@ -147,6 +145,8 @@ def on_message_posting(event): :param event: :type event: AcceptEvent """ + if not config.get_value('misc', 'collect_sig_hashes'): + return pgp_list = PGPMailingList.for_list(event.mlist) if pgp_list is None: return diff --git a/src/mailman_pgp/rules/tests/test_signature.py b/src/mailman_pgp/rules/tests/test_signature.py index ec49a18..45dbf21 100644 --- a/src/mailman_pgp/rules/tests/test_signature.py +++ b/src/mailman_pgp/rules/tests/test_signature.py @@ -32,7 +32,7 @@ from zope.component import getUtility from zope.event import notify from mailman_pgp.chains.default import PGPChain -from mailman_pgp.config import mm_config +from mailman_pgp.config import mm_config, config from mailman_pgp.database import mm_transaction, transaction from mailman_pgp.model.address import PGPAddress from mailman_pgp.model.list import PGPMailingList @@ -41,6 +41,7 @@ from mailman_pgp.pgp.inline import InlineWrapper from mailman_pgp.pgp.mime import MIMEWrapper from mailman_pgp.pgp.wrapper import PGPWrapper from mailman_pgp.rules.signature import Signature +from mailman_pgp.testing.config import patch_config from mailman_pgp.testing.layers import PGPConfigLayer from mailman_pgp.testing.pgp import load_key, load_message from mailman_pgp.utils.pgp import hashes @@ -299,6 +300,17 @@ class TestPostingEvent(TestCase): self.assertIsNotNone(sig_hash) self.assertEqual(sig_hash.fingerprint, self.sender_key.fingerprint) + @patch_config('misc', 'collect_sig_hashes', 'no') + def test_no_collect(self): + msg = load_message('mime_signed.eml') + wrapped = PGPWrapper(msg) + sighashes = set(hashes(wrapped.verify(self.sender_key))) + msgdata = dict(pgp_sig_hashes=sighashes) + notify(AcceptEvent(self.mlist, msg, msgdata, + mm_config.chains[PGPChain.name])) + + self.assertEqual(0, len(PGPSigHash.query().all())) + def test_no_pgp_list(self): with mm_transaction(): mlist = create_list('ordinary@example.com') |
