diff options
| author | J08nY | 2017-07-26 22:31:40 +0200 |
|---|---|---|
| committer | J08nY | 2017-07-26 22:31:40 +0200 |
| commit | 800dd99fe45cf1ff2611fd115936d3113516d342 (patch) | |
| tree | 99f0c1bf256bc13d0580816ce7dcc5a89e2a6224 /src/mailman_pgp/commands | |
| parent | 13055e265c738be43c0a4cb4c2898939cd0c1cd5 (diff) | |
| download | mailman-pgp-800dd99fe45cf1ff2611fd115936d3113516d342.tar.gz mailman-pgp-800dd99fe45cf1ff2611fd115936d3113516d342.tar.zst mailman-pgp-800dd99fe45cf1ff2611fd115936d3113516d342.zip | |
Diffstat (limited to 'src/mailman_pgp/commands')
| -rw-r--r-- | src/mailman_pgp/commands/eml_key.py | 20 | ||||
| -rw-r--r-- | src/mailman_pgp/commands/tests/test_key.py | 16 |
2 files changed, 26 insertions, 10 deletions
diff --git a/src/mailman_pgp/commands/eml_key.py b/src/mailman_pgp/commands/eml_key.py index 0437430..e792fa4 100644 --- a/src/mailman_pgp/commands/eml_key.py +++ b/src/mailman_pgp/commands/eml_key.py @@ -183,6 +183,16 @@ def _cmd_change(pgp_list, mlist, msg, msgdata, arguments, results): file=results) return ContinueProcessing.no + email = get_email(msg) + if not email: + print('No email to change key of.', file=results) + return ContinueProcessing.no + + pgp_address = PGPAddress.for_email(email) + if pgp_address is None: + print('A pgp enabled address not found.', file=results) + return ContinueProcessing.no + wrapped = PGPWrapper(msg) if wrapped.is_encrypted(): decrypted = wrapped.decrypt(pgp_list.key) @@ -197,16 +207,6 @@ def _cmd_change(pgp_list, mlist, msg, msgdata, arguments, results): print('More than one key! Send only one key.', file=results) return ContinueProcessing.no - email = get_email(msg) - if not email: - print('No email to change key of.', file=results) - return ContinueProcessing.no - - pgp_address = PGPAddress.for_email(email) - if pgp_address is None: - print('A pgp enabled address not found.', file=results) - return ContinueProcessing.no - workflow = KeyChangeWorkflow(mlist, pgp_address, keys.pop()) list(workflow) print('Key change request received.', file=results) diff --git a/src/mailman_pgp/commands/tests/test_key.py b/src/mailman_pgp/commands/tests/test_key.py index 0125888..8920e44 100644 --- a/src/mailman_pgp/commands/tests/test_key.py +++ b/src/mailman_pgp/commands/tests/test_key.py @@ -686,6 +686,14 @@ class TestAfterSubscription(unittest.TestCase): results_msg.get_payload()) def test_change_no_key(self): + bart = getUtility(IUserManager).create_address('bart@example.com', + 'Bart Person') + with transaction() as t: + pgp_address = PGPAddress(bart) + pgp_address.key = self.bart_key.pubkey + pgp_address.key_confirmed = True + t.add(pgp_address) + message = _create_plain('bart@example.com', 'test@example.com', 'key change', '') @@ -699,6 +707,14 @@ class TestAfterSubscription(unittest.TestCase): results_msg.get_payload()) def test_change_multiple_keys(self): + bart = getUtility(IUserManager).create_address('bart@example.com', + 'Bart Person') + with transaction() as t: + pgp_address = PGPAddress(bart) + pgp_address.key = self.bart_key.pubkey + pgp_address.key_confirmed = True + t.add(pgp_address) + set_message = _create_mixed('bart@example.com', 'test@example.com', 'key change') |
