aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/rest/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman_pgp/rest/tests')
-rw-r--r--src/mailman_pgp/rest/tests/test_lists.py80
1 files changed, 78 insertions, 2 deletions
diff --git a/src/mailman_pgp/rest/tests/test_lists.py b/src/mailman_pgp/rest/tests/test_lists.py
index 381d4ac..365cd05 100644
--- a/src/mailman_pgp/rest/tests/test_lists.py
+++ b/src/mailman_pgp/rest/tests/test_lists.py
@@ -76,7 +76,21 @@ class TestLists(TestCase):
'test@example.com')
self.assertEqual(json['list_id'], self.mlist.list_id)
- def test_put_list_config(self):
+
+class TestListConfig(TestCase):
+ layer = PGPRESTLayer
+
+ def setUp(self):
+ with mm_transaction():
+ self.mlist = create_list('test@example.com',
+ style_name='pgp-default')
+
+ self.list_key = load_key('ecc_p256.priv.asc')
+ with transaction():
+ self.pgp_list = PGPMailingList.for_list(self.mlist)
+ 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',
@@ -100,7 +114,25 @@ class TestLists(TestCase):
attr = attr.name
self.assertEqual(attr, config[key])
- def test_patch_list_config(self):
+ 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)
+ with self.assertRaises(HTTPError) as cm:
+ call_api('http://localhost:9001/3.1/plugins/pgp/lists/'
+ 'test.example.com',
+ data=config,
+ method='PUT')
+ self.assertEqual(cm.exception.code, 400)
+
+ def test_patch(self):
json, response = call_api(
'http://localhost:9001/3.1/plugins/pgp/lists/'
'test.example.com',
@@ -109,6 +141,50 @@ class TestLists(TestCase):
self.assertEqual(response.status_code, 204)
self.assertEqual(self.pgp_list.unsigned_msg_action, Action.defer)
+ def test_patch_wrong_attribute(self):
+ with self.assertRaises(HTTPError) as cm:
+ call_api('http://localhost:9001/3.1/plugins/pgp/lists/'
+ 'test.example.com',
+ data=dict(something_something='somewhere'),
+ method='PATCH')
+ self.assertEqual(cm.exception.code, 400)
+
+ def test_patch_wrong_value(self):
+ with self.assertRaises(HTTPError) as cm:
+ call_api('http://localhost:9001/3.1/plugins/pgp/lists/'
+ 'test.example.com',
+ data=dict(unsigned_msg_action='not-an-action'),
+ method='PATCH')
+ self.assertEqual(cm.exception.code, 400)
+
+ def test_missing_list(self):
+ with self.assertRaises(HTTPError) as cm:
+ call_api('http://localhost:9001/3.1/plugins/pgp/lists/'
+ 'missing.example.com',
+ data=dict(),
+ method='PUT')
+ self.assertEqual(cm.exception.code, 404)
+ with self.assertRaises(HTTPError) as cm:
+ call_api('http://localhost:9001/3.1/plugins/pgp/lists/'
+ 'missing.example.com',
+ data=dict(),
+ method='PATCH')
+ self.assertEqual(cm.exception.code, 404)
+
+
+class TestListKey(TestCase):
+ layer = PGPRESTLayer
+
+ def setUp(self):
+ with mm_transaction():
+ self.mlist = create_list('test@example.com',
+ style_name='pgp-default')
+
+ self.list_key = load_key('ecc_p256.priv.asc')
+ with transaction():
+ self.pgp_list = PGPMailingList.for_list(self.mlist)
+ self.pgp_list.key = self.list_key
+
def test_get_list_key(self):
json, response = call_api(
'http://localhost:9001/3.1/plugins/pgp/lists/'