Merge "Test cases for better handling of SSH key comments"
This commit is contained in:
commit
cd06b6fe59
@ -240,6 +240,12 @@ e6fCXWECgYEAqgpGvva5kJ1ISgNwnJbwiNw0sOT9BMOsdNZBElf0kJIIy6FMPvap
|
||||
raise exception.DecryptionFailure(reason=exc.stderr)
|
||||
|
||||
def test_ssh_encrypt_decrypt_text(self):
|
||||
self._test_ssh_encrypt_decrypt_text(self.pubkey)
|
||||
key_with_spaces_in_comment = self.pubkey.replace('test@test',
|
||||
'Generated by Nova')
|
||||
self._test_ssh_encrypt_decrypt_text(key_with_spaces_in_comment)
|
||||
|
||||
def _test_ssh_encrypt_decrypt_text(self, key):
|
||||
enc = crypto.ssh_encrypt_text(self.pubkey, self.text)
|
||||
self.assertIsInstance(enc, bytes)
|
||||
# Comparison between bytes and str raises a TypeError
|
||||
@ -321,6 +327,12 @@ class KeyPairTest(test.TestCase):
|
||||
"uYREz7iLRCP7BwUt8R+ZWzFZDeOLIWU= Generated-by-Nova"
|
||||
)
|
||||
|
||||
ecdsa_pub_with_spaces = (
|
||||
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAy"
|
||||
"NTYAAABBBG1r4wzPTIjSo78POCq+u/czb8gYK0KvqlmCvcRPrnDWxgLw7y6BX51t"
|
||||
"uYREz7iLRCP7BwUt8R+ZWzFZDeOLIWU= Generated by Nova"
|
||||
)
|
||||
|
||||
ecdsa_fp = "16:6a:c9:ec:80:4d:17:3e:d5:3b:6f:c0:d7:15:04:40"
|
||||
|
||||
def test_generate_fingerprint(self):
|
||||
@ -333,6 +345,9 @@ class KeyPairTest(test.TestCase):
|
||||
fingerprint = crypto.generate_fingerprint(self.ecdsa_pub)
|
||||
self.assertEqual(self.ecdsa_fp, fingerprint)
|
||||
|
||||
fingerprint = crypto.generate_fingerprint(self.ecdsa_pub_with_spaces)
|
||||
self.assertEqual(self.ecdsa_fp, fingerprint)
|
||||
|
||||
def test_generate_key_pair_2048_bits(self):
|
||||
(private_key, public_key, fingerprint) = crypto.generate_key_pair()
|
||||
pub_bytes = public_key.encode('utf-8')
|
||||
|
Loading…
x
Reference in New Issue
Block a user