aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman_pgp')
-rw-r--r--src/mailman_pgp/pgp/tests/test_inline.py15
-rw-r--r--src/mailman_pgp/pgp/tests/test_mime.py9
-rw-r--r--src/mailman_pgp/pgp/tests/test_wrapper.py14
-rw-r--r--src/mailman_pgp/pgp/wrapper.py2
-rw-r--r--src/mailman_pgp/testing/pgp.py4
5 files changed, 43 insertions, 1 deletions
diff --git a/src/mailman_pgp/pgp/tests/test_inline.py b/src/mailman_pgp/pgp/tests/test_inline.py
index 4009a4b..7f82ab4 100644
--- a/src/mailman_pgp/pgp/tests/test_inline.py
+++ b/src/mailman_pgp/pgp/tests/test_inline.py
@@ -77,6 +77,12 @@ class TestSigning(InlineWrapperTestCase):
load_key('rsa_1024.pub.asc')),
(load_message('clear_multipart.eml'),
load_key('ecc_p256.priv.asc'),
+ load_key('ecc_p256.pub.asc')),
+ (load_message('inline_signed.eml'),
+ load_key('ecc_p256.priv.asc'),
+ load_key('ecc_p256.pub.asc')),
+ (load_message('inline_signed_multipart.eml'),
+ load_key('ecc_p256.priv.asc'),
load_key('ecc_p256.pub.asc'))
])
def test_sign_verify(self, message, priv, pub):
@@ -192,6 +198,15 @@ class TestKeys(InlineWrapperTestCase):
@parameterized.expand([
(load_message('inline_privkey.eml'),
+ True),
+ (load_message('inline_pubkey.eml'),
+ True)
+ ])
+ def test_is_keys(self, message, is_keys):
+ self.is_keys(message, is_keys)
+
+ @parameterized.expand([
+ (load_message('inline_privkey.eml'),
[load_key('rsa_1024.priv.asc')]),
(load_message('inline_pubkey.eml'),
[load_key('rsa_1024.pub.asc')]),
diff --git a/src/mailman_pgp/pgp/tests/test_mime.py b/src/mailman_pgp/pgp/tests/test_mime.py
index 1415be5..78c9e71 100644
--- a/src/mailman_pgp/pgp/tests/test_mime.py
+++ b/src/mailman_pgp/pgp/tests/test_mime.py
@@ -158,6 +158,15 @@ class TestKeys(MIMEWrapperTestCase):
@parameterized.expand([
(load_message('mime_privkey.eml'),
+ False),
+ (load_message('mime_pubkey.eml'),
+ False)
+ ])
+ def test_is_keys(self, message, is_keys):
+ self.is_keys(message, is_keys)
+
+ @parameterized.expand([
+ (load_message('mime_privkey.eml'),
[load_key('rsa_1024.priv.asc')]),
(load_message('mime_pubkey.eml'),
[load_key('rsa_1024.pub.asc')]),
diff --git a/src/mailman_pgp/pgp/tests/test_wrapper.py b/src/mailman_pgp/pgp/tests/test_wrapper.py
index 13657ac..f1f7621 100644
--- a/src/mailman_pgp/pgp/tests/test_wrapper.py
+++ b/src/mailman_pgp/pgp/tests/test_wrapper.py
@@ -18,6 +18,9 @@
"""Tests for the combined wrapper."""
from parameterized import parameterized
+from mailman_pgp.pgp.inline import InlineWrapper
+from mailman_pgp.pgp.mime import MIMEWrapper
+from mailman_pgp.pgp.mime_multisig import MIMEMultiSigWrapper
from mailman_pgp.pgp.wrapper import PGPWrapper
from mailman_pgp.testing.pgp import load_key, load_message, WrapperTestCase
@@ -194,3 +197,14 @@ class TestCombined(PGPWrapperTestCase):
def test_sign_then_encrypt_decrypt_verify(self, message, sign_key,
encrypt_key):
self.sign_then_encrypt_decrypt_verify(message, sign_key, encrypt_key)
+
+
+class TestPGPWrapper(PGPWrapperTestCase):
+ def setUp(self):
+ self.msg = load_message('clear.eml')
+
+ def test_defaults(self):
+ PGPWrapper(self.msg)
+ for wrap_class in (InlineWrapper, MIMEWrapper, MIMEMultiSigWrapper):
+ PGPWrapper(self.msg, wrap_class)
+ self.assertRaises(ValueError, PGPWrapper, self.msg, 'Not a class')
diff --git a/src/mailman_pgp/pgp/wrapper.py b/src/mailman_pgp/pgp/wrapper.py
index f506c2e..6193b57 100644
--- a/src/mailman_pgp/pgp/wrapper.py
+++ b/src/mailman_pgp/pgp/wrapper.py
@@ -37,7 +37,7 @@ class PGPWrapper():
:param msg: The message to wrap.
:type msg: mailman.email.message.Message
:param default:
- :type default: MIMEWrapper|MIMEMultiSigWrapper|InlineWrapper
+ :type default: Type[MIMEWrapper|MIMEMultiSigWrapper|InlineWrapper]
"""
self.msg = msg
self.mime = MIMEWrapper(msg)
diff --git a/src/mailman_pgp/testing/pgp.py b/src/mailman_pgp/testing/pgp.py
index 6b2bc48..844b708 100644
--- a/src/mailman_pgp/testing/pgp.py
+++ b/src/mailman_pgp/testing/pgp.py
@@ -126,6 +126,10 @@ class WrapperTestCase(TestCase):
wrapped = self.wrap(message)
self.assertEqual(wrapped.has_keys(), has_keys)
+ def is_keys(self, message, is_keys):
+ wrapped = self.wrap(message)
+ self.assertEqual(wrapped.is_keys(), is_keys)
+
def keys(self, message, keys):
wrapped = self.wrap(message)
loaded = list(wrapped.keys())