jira python83: unicode names and passwords should be encoded as utf8, with test

This commit is contained in:
Gregg Lind 2010-01-08 21:08:30 +00:00 committed by Mike Dirolf
parent e1e5252e6d
commit 76465238f2
2 changed files with 3 additions and 1 deletions

View File

@ -363,7 +363,7 @@ class Database(object):
raise TypeError("username must be an instance of (str, unicode)")
md5hash = _md5func()
md5hash.update(username + ":mongo:" + password)
md5hash.update(username.encode('utf-8') + ":mongo:" + password.encode('utf-8'))
return unicode(md5hash.hexdigest())
def authenticate(self, name, password):

View File

@ -227,6 +227,8 @@ class TestDatabase(unittest.TestCase):
u"cd7e45b3b2767dc2fa9b6b548457ed00")
self.assertEqual(db._password_digest("mike", "password"),
db._password_digest(u"mike", u"password"))
self.assertEqual(db._password_digest("Gustave", u"Dor\xe9"),
u"81e0e2364499209f466e75926a162d73")
def test_authenticate(self):
db = self.connection.pymongo_test