aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/rest/tests
diff options
context:
space:
mode:
authorJ08nY2017-08-10 20:48:24 +0200
committerJ08nY2017-08-10 20:48:24 +0200
commitfc2ef7bf00a540b335ed6d75e7684e717774bfcf (patch)
tree6bc2003a36bac8c72c03575a870342cb30b77fcd /src/mailman_pgp/rest/tests
parenta973479205cec0d5fbf162030906ce405b3698b2 (diff)
downloadmailman-pgp-fc2ef7bf00a540b335ed6d75e7684e717774bfcf.tar.gz
mailman-pgp-fc2ef7bf00a540b335ed6d75e7684e717774bfcf.tar.zst
mailman-pgp-fc2ef7bf00a540b335ed6d75e7684e717774bfcf.zip
Add option to disable exposing the list private key on REST.
Diffstat (limited to 'src/mailman_pgp/rest/tests')
-rw-r--r--src/mailman_pgp/rest/tests/test_lists.py59
1 files changed, 34 insertions, 25 deletions
diff --git a/src/mailman_pgp/rest/tests/test_lists.py b/src/mailman_pgp/rest/tests/test_lists.py
index 365cd05..900e8b9 100644
--- a/src/mailman_pgp/rest/tests/test_lists.py
+++ b/src/mailman_pgp/rest/tests/test_lists.py
@@ -24,6 +24,7 @@ from mailman.interfaces.action import Action
from mailman.testing.helpers import call_api
from pgpy import PGPKey
+from mailman_pgp.config import config
from mailman_pgp.database import mm_transaction, transaction
from mailman_pgp.model.list import PGPMailingList
from mailman_pgp.testing.layers import PGPRESTLayer
@@ -91,44 +92,52 @@ class TestListConfig(TestCase):
self.pgp_list.key = self.list_key
def test_put(self):
- config = dict(unsigned_msg_action='defer',
- inline_pgp_action='defer',
- expired_sig_action='defer',
- revoked_sig_action='defer',
- invalid_sig_action='defer',
- duplicate_sig_action='defer',
- strip_original_sig=False,
- sign_outgoing=True,
- nonencrypted_msg_action='defer',
- encrypt_outgoing=False)
+ cfg = dict(unsigned_msg_action='defer',
+ inline_pgp_action='defer',
+ expired_sig_action='defer',
+ revoked_sig_action='defer',
+ invalid_sig_action='defer',
+ duplicate_sig_action='defer',
+ strip_original_sig=False,
+ sign_outgoing=True,
+ nonencrypted_msg_action='defer',
+ encrypt_outgoing=False,
+ key_change_workflow='pgp-key-change-mod-workflow',
+ key_signing_allowed=['member', 'owner'])
json, response = call_api(
'http://localhost:9001/3.1/plugins/pgp/lists/'
'test.example.com',
- data=config,
+ data=cfg,
method='PUT')
self.assertEqual(response.status_code, 204)
- for key in config:
+ for key in cfg:
attr = getattr(self.pgp_list, key)
if isinstance(attr, Action):
- attr = attr.name
- self.assertEqual(attr, config[key])
+ self.assertEqual(attr.name, cfg[key])
+ elif key == 'key_signing_allowed':
+ attr = [enum.name for enum in attr]
+ self.assertEqual(attr, sorted(cfg[key]))
+ else:
+ self.assertEqual(attr, cfg[key])
def test_put_wrong_value(self):
- config = dict(unsigned_msg_action='not-an-action',
- inline_pgp_action='defer',
- expired_sig_action='defer',
- revoked_sig_action='defer',
- invalid_sig_action='defer',
- duplicate_sig_action='defer',
- strip_original_sig=False,
- sign_outgoing=True,
- nonencrypted_msg_action='defer',
- encrypt_outgoing=False)
+ cfg = dict(unsigned_msg_action='not-an-action',
+ inline_pgp_action='defer',
+ expired_sig_action='defer',
+ revoked_sig_action='defer',
+ invalid_sig_action='defer',
+ duplicate_sig_action='defer',
+ strip_original_sig=False,
+ sign_outgoing=True,
+ nonencrypted_msg_action='defer',
+ encrypt_outgoing=False,
+ key_change_workflow='pgp-key-change-mod-workflow',
+ key_signing_allowed=['member', 'owner'])
with self.assertRaises(HTTPError) as cm:
call_api('http://localhost:9001/3.1/plugins/pgp/lists/'
'test.example.com',
- data=config,
+ data=cfg,
method='PUT')
self.assertEqual(cm.exception.code, 400)