MCPcopy
hub / github.com/django/django / test_md5

Method test_md5

tests/auth_tests/test_hashers.py:111–129  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

109 PASSWORD_HASHERS=["django.contrib.auth.hashers.MD5PasswordHasher"]
110 )
111 def test_md5(self):
112 encoded = make_password("lètmein", "seasalt", "md5")
113 self.assertEqual(encoded, "md5$seasalt$3f86d0d3d465b7b458c231bf3555c0e3")
114 self.assertTrue(is_password_usable(encoded))
115 self.assertTrue(check_password("lètmein", encoded))
116 self.assertFalse(check_password("lètmeinz", encoded))
117 self.assertEqual(identify_hasher(encoded).algorithm, "md5")
118 # Blank passwords
119 blank_encoded = make_password("", "seasalt", "md5")
120 self.assertTrue(blank_encoded.startswith("md5$"))
121 self.assertTrue(is_password_usable(blank_encoded))
122 self.assertTrue(check_password("", blank_encoded))
123 self.assertFalse(check_password(" ", blank_encoded))
124 # Salt entropy check.
125 hasher = get_hasher("md5")
126 encoded_weak_salt = make_password("lètmein", "iodizedsalt", "md5")
127 encoded_strong_salt = make_password("lètmein", hasher.salt(), "md5")
128 self.assertIs(hasher.must_update(encoded_weak_salt), True)
129 self.assertIs(hasher.must_update(encoded_strong_salt), False)
130
131 @skipUnless(bcrypt, "bcrypt not installed")
132 def test_bcrypt_sha256(self):

Callers

nothing calls this directly

Calls 7

make_passwordFunction · 0.90
is_password_usableFunction · 0.90
check_passwordFunction · 0.90
identify_hasherFunction · 0.90
get_hasherFunction · 0.90
saltMethod · 0.45
must_updateMethod · 0.45

Tested by

no test coverage detected