aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/pgp/tests/test_inline.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman_pgp/pgp/tests/test_inline.py')
-rw-r--r--src/mailman_pgp/pgp/tests/test_inline.py47
1 files changed, 14 insertions, 33 deletions
diff --git a/src/mailman_pgp/pgp/tests/test_inline.py b/src/mailman_pgp/pgp/tests/test_inline.py
index d144991..b6d84ec 100644
--- a/src/mailman_pgp/pgp/tests/test_inline.py
+++ b/src/mailman_pgp/pgp/tests/test_inline.py
@@ -15,19 +15,19 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
-""""""
-import unittest
+"""Tests for the inline wrapper."""
from parameterized import parameterized
from mailman_pgp.pgp.inline import InlineWrapper
-from mailman_pgp.pgp.tests.base import load_key, load_message, PGPTestCase
+from mailman_pgp.pgp.tests.base import load_key, load_message, WrapperTestCase
-class TestSigning(PGPTestCase, unittest.TestCase):
- def setUp(self):
- self.wrapper = InlineWrapper
+class InlineWrapperTestCase(WrapperTestCase):
+ wrapper = InlineWrapper
+
+class TestSigning(InlineWrapperTestCase):
@parameterized.expand([
(load_message('data/inline_signed.eml'),
True),
@@ -39,8 +39,7 @@ class TestSigning(PGPTestCase, unittest.TestCase):
False)
])
def test_is_signed(self, message, signed):
- wrapped = self.wrapper(message)
- self.assertEqual(wrapped.is_signed(), signed)
+ super().is_signed(message, signed)
def test_sign(self):
pass
@@ -54,14 +53,10 @@ class TestSigning(PGPTestCase, unittest.TestCase):
False)
])
def test_verify(self, message, key, valid):
- wrapped = self.wrapper(message)
- self.assertEqual(bool(wrapped.verify(key)), valid)
-
+ super().verify(message, key, valid)
-class TestEncryption(PGPTestCase, unittest.TestCase):
- def setUp(self):
- self.wrapper = InlineWrapper
+class TestEncryption(InlineWrapperTestCase):
@parameterized.expand([
(load_message('data/inline_encrypted.eml'),
True),
@@ -73,8 +68,7 @@ class TestEncryption(PGPTestCase, unittest.TestCase):
False)
])
def test_is_encrypted(self, message, encrypted):
- wrapped = self.wrapper(message)
- self.assertEqual(wrapped.is_encrypted(), encrypted)
+ super().is_encrypted(message, encrypted)
def test_encrypt(self):
pass
@@ -85,15 +79,10 @@ class TestEncryption(PGPTestCase, unittest.TestCase):
'Some encrypted text.\n\n')
])
def test_decrypt(self, message, key, clear):
- wrapped = self.wrapper(message)
- self.assertEqual(wrapped.decrypt(key).message,
- bytearray(clear, 'latin-1'))
-
+ super().decrypt(message, key, clear)
-class TestKeys(PGPTestCase, unittest.TestCase):
- def setUp(self):
- self.wrapper = InlineWrapper
+class TestKeys(InlineWrapperTestCase):
@parameterized.expand([
(load_message('data/inline_privkey.eml'),
True),
@@ -105,8 +94,7 @@ class TestKeys(PGPTestCase, unittest.TestCase):
False)
])
def test_has_keys(self, message, has_keys):
- wrapped = self.wrapper(message)
- self.assertEqual(wrapped.has_keys(), has_keys)
+ super().has_keys(message, has_keys)
@parameterized.expand([
(load_message('data/inline_privkey.eml'),
@@ -115,11 +103,4 @@ class TestKeys(PGPTestCase, unittest.TestCase):
[load_key('data/rsa_1024.pub.asc')])
])
def test_keys(self, message, keys):
- wrapped = self.wrapper(message)
- loaded = list(wrapped.keys())
- loaded_fingerprints = list(map(lambda key: key.fingerprint, loaded))
-
- self.assertEqual(len(loaded), len(keys))
-
- fingerprints = list(map(lambda key: key.fingerprint, keys))
- self.assertListEqual(loaded_fingerprints, fingerprints)
+ super().keys(message, keys)