@@ -807,3 +808,12 @@ def open_with_perm_test(self):
os.umask(old_umask)
finally:
shutil.rmtree(test_dir)
+
+class EncryptPasswordTests(unittest.TestCase):
+ def encrypt_password_test(self):
+ """ Test the encrypt_password function"""
+ for algo in ["$1$", "$5$", "$6$"]:
+ enc_pw = iutil.encrypt_password("DocBrown", algo, 16)
+ self.assertEqual(algo, enc_pw[:3])
+ self.assertEqual(crypt.crypt("DocBrown", enc_pw), enc_pw)
+ self.assertNotEqual(crypt.crypt("Einstein", enc_pw), enc_pw)
For 3.4 and later crypt.mksalt is ok, for 2.7 it isn't. Salt length is really always
16 since we don't allow DES. I guess I could simplify everything for master and leave
this for rhel7-branch.
--
To view this pull request on github, visit
https://github.com/rhinstaller/anaconda/pull/421#discussion_r43018351