]> granicus.if.org Git - python/commitdiff
bpo-31664: Fix test_crypt for the openwall implementation of crypt. (#4116)
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 25 Oct 2017 13:30:13 +0000 (16:30 +0300)
committerGitHub <noreply@github.com>
Wed, 25 Oct 2017 13:30:13 +0000 (16:30 +0300)
Lib/test/test_crypt.py

index 8db1aefdf1ef2713643708033e913dd30e59b74c..796fd076c6a5e5b144d1a8b0e3dc64f5ef3ca650 100644 (file)
@@ -57,7 +57,13 @@ class CryptTestCase(unittest.TestCase):
     def test_invalid_log_rounds(self):
         for log_rounds in (1, -1, 999):
             salt = crypt.mksalt(crypt.METHOD_BLOWFISH, log_rounds=log_rounds)
-            self.assertIsNone(crypt.crypt('mypassword', salt))
+            cr = crypt.crypt('mypassword', salt)
+            if cr is not None:
+                # On failure the openwall implementation returns a magic
+                # string that is shorter than 13 characters and is guaranteed
+                # to differ from a salt.
+                self.assertNotEqual(cr, salt)
+                self.assertLess(len(cr), 13)
 
 
 if __name__ == "__main__":