aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/pgp/tests/test_keygen.py
diff options
context:
space:
mode:
authorJ08nY2017-07-19 20:43:24 +0200
committerJ08nY2017-07-19 21:46:39 +0200
commitf0670baf7f66faab8ed4f16d393eea8a570f9630 (patch)
treedfe4669827c0171bfb45f5a50f6093216d05761b /src/mailman_pgp/pgp/tests/test_keygen.py
parent63b7097f67dfcbd95c4df359d31374e8849a666c (diff)
downloadmailman-pgp-f0670baf7f66faab8ed4f16d393eea8a570f9630.tar.gz
mailman-pgp-f0670baf7f66faab8ed4f16d393eea8a570f9630.tar.zst
mailman-pgp-f0670baf7f66faab8ed4f16d393eea8a570f9630.zip
Diffstat (limited to 'src/mailman_pgp/pgp/tests/test_keygen.py')
-rw-r--r--src/mailman_pgp/pgp/tests/test_keygen.py38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/mailman_pgp/pgp/tests/test_keygen.py b/src/mailman_pgp/pgp/tests/test_keygen.py
index dab6801..bbd0c84 100644
--- a/src/mailman_pgp/pgp/tests/test_keygen.py
+++ b/src/mailman_pgp/pgp/tests/test_keygen.py
@@ -15,32 +15,42 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
+"""Test the out-of-process key generator."""
from os.path import exists, isfile, join
from tempfile import TemporaryDirectory
from unittest import TestCase
+from parameterized import parameterized
from pgpy import PGPKey
-from pgpy.constants import PubKeyAlgorithm
+from pgpy.constants import PubKeyAlgorithm, EllipticCurveOID
from mailman_pgp.pgp.keygen import ListKeyGenerator
-class TesKeygen(TestCase):
+class TestKeygen(TestCase):
def setUp(self):
- self.keypair_config = {
- 'key_type': PubKeyAlgorithm.RSAEncryptOrSign,
- 'key_length': 1024,
- 'subkey_type': PubKeyAlgorithm.RSAEncryptOrSign,
- 'subkey_length': 1024
- }
self.display_name = 'Display Name'
self.posting_address = 'posting@address.com'
self.request_address = 'posting-request@address.com'
- def test_generate(self):
+ @parameterized.expand([
+ # RSA + RSA
+ (PubKeyAlgorithm.RSAEncryptOrSign, 1024,
+ PubKeyAlgorithm.RSAEncryptOrSign, 1024),
+ # ECDSA + ECDH
+ (PubKeyAlgorithm.ECDSA, EllipticCurveOID.SECP256K1,
+ PubKeyAlgorithm.ECDH, EllipticCurveOID.SECP256K1),
+ # DSA + ECDH
+ (PubKeyAlgorithm.DSA, 1024,
+ PubKeyAlgorithm.ECDH, EllipticCurveOID.SECP256K1)
+ ])
+ def test_generate(self, primary_key_type, primary_key_size, sub_key_type,
+ sub_key_size):
with TemporaryDirectory() as temp_dir:
key_path = join(temp_dir, 'key.asc')
- keygen = ListKeyGenerator(self.keypair_config, self.display_name,
+ keygen = ListKeyGenerator((primary_key_type, primary_key_size),
+ (sub_key_type, sub_key_size),
+ self.display_name,
self.posting_address,
self.request_address, key_path)
keygen.start()
@@ -50,18 +60,18 @@ class TesKeygen(TestCase):
key, _ = PGPKey.from_file(key_path)
self.assertEqual(key.key_algorithm,
- self.keypair_config['key_type'])
+ primary_key_type)
self.assertEqual(key.key_size,
- self.keypair_config['key_length'])
+ primary_key_size)
subs = key.subkeys
self.assertEqual(len(subs), 1)
keyid, sub = subs.popitem()
self.assertEqual(sub.key_algorithm,
- self.keypair_config['subkey_type'])
+ sub_key_type)
self.assertEqual(sub.key_size,
- self.keypair_config['subkey_length'])
+ sub_key_size)
uids = key.userids
self.assertEqual(len(uids), 2)