aboutsummaryrefslogtreecommitdiff
path: root/tests/test_pkey.py
diff options
context:
space:
mode:
authorJeremy T. Bouse <jbouse@debian.org>2014-09-22 09:21:39 -0400
committerJeremy T. Bouse <jbouse@debian.org>2014-09-22 09:21:39 -0400
commitccd643cdbd7ba752727d62051058a4454451414d (patch)
tree9bc89a6629132f474b3297735069d025145a965c /tests/test_pkey.py
parent588a4823436454e8968ee36ae95ff92e1cddc3f7 (diff)
downloadpython-paramiko-ccd643cdbd7ba752727d62051058a4454451414d.tar
python-paramiko-ccd643cdbd7ba752727d62051058a4454451414d.tar.gz
Imported Upstream version 1.15.0upstream/1.15.0
Diffstat (limited to 'tests/test_pkey.py')
-rw-r--r--tests/test_pkey.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_pkey.py b/tests/test_pkey.py
index 1468ee2..f673254 100644
--- a/tests/test_pkey.py
+++ b/tests/test_pkey.py
@@ -21,6 +21,7 @@ Some unit tests for public/private key objects.
"""
import unittest
+import os
from binascii import hexlify
from hashlib import md5
@@ -253,3 +254,20 @@ class KeyTest (unittest.TestCase):
msg.rewind()
pub = ECDSAKey(data=key.asbytes())
self.assertTrue(pub.verify_ssh_sig(b'ice weasels', msg))
+
+ def test_salt_size(self):
+ # Read an existing encrypted private key
+ file_ = test_path('test_rsa_password.key')
+ password = 'television'
+ newfile = file_ + '.new'
+ newpassword = 'radio'
+ key = RSAKey(filename=file_, password=password)
+ # Write out a newly re-encrypted copy with a new password.
+ # When the bug under test exists, this will ValueError.
+ try:
+ key.write_private_key_file(newfile, password=newpassword)
+ # Verify the inner key data still matches (when no ValueError)
+ key2 = RSAKey(filename=newfile, password=newpassword)
+ self.assertEqual(key, key2)
+ finally:
+ os.remove(newfile)