8000 bpo-31664: Fix test_crypt for the openwall implementation of crypt. (… · ultimatecoder/cpython@0f26158 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f26158

Browse files
bpo-31664: Fix test_crypt for the openwall implementation of crypt. (python#4116)
1 parent 086c3ae commit 0f26158

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Lib/test/test_crypt.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ def test_log_rounds(self):
5757
def test_invalid_log_rounds(self):
5858
for log_rounds in (1, -1, 999):
5959
salt = crypt.mksalt(crypt.METHOD_BLOWFISH, log_rounds=log_rounds)
60-
self.assertIsNone(crypt.crypt('mypassword', salt))
60+
cr = crypt.crypt('mypassword', salt)
61+
if cr is not None:
62+
# On failure the openwall implementation returns a magic
63+
# string that is shorter than 13 characters and is guaranteed
64+
# to differ from a salt.
65+
self.assertNotEqual(cr, salt)
66+
self.assertLess(len(cr), 13)
6167

6268

6369
if __name__ == "__main__":

0 commit comments

Comments
 (0)
0