aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/rest/tests/test_lists.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman_pgp/rest/tests/test_lists.py')
-rw-r--r--src/mailman_pgp/rest/tests/test_lists.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/mailman_pgp/rest/tests/test_lists.py b/src/mailman_pgp/rest/tests/test_lists.py
index 3bdd01d..4a80bde 100644
--- a/src/mailman_pgp/rest/tests/test_lists.py
+++ b/src/mailman_pgp/rest/tests/test_lists.py
@@ -14,7 +14,7 @@
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
-
+from time import sleep
from unittest import TestCase
from urllib.error import HTTPError
@@ -22,6 +22,7 @@ from mailman.app.lifecycle import create_list
from mailman.database.transaction import transaction as mailman_transaction
from mailman.testing.helpers import call_api
from mailman.testing.layers import RESTLayer
+from pgpy import PGPKey
class TestLists(TestCase):
@@ -38,7 +39,7 @@ class TestLists(TestCase):
'missing.example.com')
self.assertEqual(cm.exception.code, 404)
- def test_has_list(self):
+ def test_all_lists(self):
json, response = call_api(
'http://localhost:9001/3.1/plugins/pgp/lists/')
self.assertEqual(json['total_size'], 1)
@@ -46,3 +47,27 @@ class TestLists(TestCase):
lists = json['entries']
plist = lists[0]
self.assertEqual(plist['list_id'], self.mlist.list_id)
+
+ def test_get_list(self):
+ json, response = call_api(
+ 'http://localhost:9001/3.1/plugins/pgp/lists/'
+ 'test.example.com')
+ self.assertEqual(json['list_id'], self.mlist.list_id)
+
+ def test_get_list_key(self):
+ for i in range(15):
+ try:
+ json, response = call_api(
+ 'http://localhost:9001/3.1/plugins/pgp/lists/'
+ 'test.example.com/key')
+ break
+ except HTTPError:
+ sleep(1)
+
+ json.pop('http_etag')
+ self.assertEqual(len(json.keys()), 2)
+ self.assertIn('public_key', json.keys())
+ self.assertIn('key_fingerprint', json.keys())
+
+ key, _ = PGPKey.from_blob(json['public_key'])
+ self.assertEqual(json['key_fingerprint'], key.fingerprint)