Split up and improve speed of keygen tests

test_generate_keypair is nova's slowest unit test, partly because it's
doing 3 separate things, and partly because we're generating
unnecessarily large keys which can suffer from entropy problems.

This patch splits up the 3 cases and asks for a 1024-bit key instead of
4096.

Change-Id: I7516b63e2b49251d44b4206b565a34bc7ccc6539
This commit is contained in:
Matthew Gilliard 2015-05-20 16:03:32 -07:00
parent 98f7e8dae3
commit 1c0e31e32e
1 changed files with 4 additions and 2 deletions

View File

@ -344,18 +344,20 @@ class KeyPairTest(test.TestCase):
fingerprint = crypto.generate_fingerprint(self.ecdsa_pub)
self.assertEqual(self.ecdsa_fp, fingerprint)
def test_generate_key_pair(self):
def test_generate_key_pair_2048_bits(self):
(private_key, public_key, fingerprint) = crypto.generate_key_pair()
raw_pub = public_key.split(' ')[1].decode('base64')
pkey = paramiko.rsakey.RSAKey(None, raw_pub)
self.assertEqual(2048, pkey.get_bits())
bits = 4096
def test_generate_key_pair_1024_bits(self):
bits = 1024
(private_key, public_key, fingerprint) = crypto.generate_key_pair(bits)
raw_pub = public_key.split(' ')[1].decode('base64')
pkey = paramiko.rsakey.RSAKey(None, raw_pub)
self.assertEqual(bits, pkey.get_bits())
def test_generate_key_pair_mocked_private_key(self):
keyin = StringIO.StringIO()
keyin.write(self.rsa_prv)
keyin.seek(0)