MCPcopy
hub / github.com/django/django / test_unusable

Method test_unusable

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

Source from the content-addressed store, hash-verified

233 self.assertEqual(hasher.encode.call_args_list, [expected_call] * 3)
234
235 def test_unusable(self):
236 encoded = make_password(None)
237 self.assertEqual(
238 len(encoded),
239 len(UNUSABLE_PASSWORD_PREFIX) + UNUSABLE_PASSWORD_SUFFIX_LENGTH,
240 )
241 self.assertFalse(is_password_usable(encoded))
242 self.assertFalse(check_password(None, encoded))
243 self.assertFalse(check_password(encoded, encoded))
244 self.assertFalse(check_password(UNUSABLE_PASSWORD_PREFIX, encoded))
245 self.assertFalse(check_password("", encoded))
246 self.assertFalse(check_password("lètmein", encoded))
247 self.assertFalse(check_password("lètmeinz", encoded))
248 with self.assertRaisesMessage(ValueError, "Unknown password hashing algorithm"):
249 identify_hasher(encoded)
250 # Assert that the unusable passwords actually contain a random part.
251 # This might fail one day due to a hash collision.
252 self.assertNotEqual(encoded, make_password(None), "Random password collision?")
253
254 def test_unspecified_password(self):
255 """

Callers

nothing calls this directly

Calls 5

make_passwordFunction · 0.90
is_password_usableFunction · 0.90
check_passwordFunction · 0.90
identify_hasherFunction · 0.90
assertRaisesMessageMethod · 0.80

Tested by

no test coverage detected