本文整理汇总了Python中users.models.UserProfile.check_password方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.check_password方法的具体用法?Python UserProfile.check_password怎么用?Python UserProfile.check_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.check_password方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_browserid_password
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_browserid_password(self):
for source in amo.LOGIN_SOURCE_BROWSERIDS:
u = UserProfile(password=self.utf, source=source)
assert u.check_password('foo')
u = UserProfile(password=self.utf, source=amo.LOGIN_SOURCE_UNKNOWN)
assert not u.check_password('foo')
示例2: test_empty_password
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_empty_password(self):
profile = UserProfile(password=None)
assert profile.has_usable_password() is False
assert not check_password(None, profile.password)
assert not profile.check_password(None)
profile = UserProfile(password='')
assert profile.has_usable_password() is False
assert not check_password('', profile.password)
assert not profile.check_password('')
示例3: test_persona_sha512_base64_maybe_not_latin1
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_persona_sha512_base64_maybe_not_latin1(self):
passwd = u'fo\xf3'
hsh = hashlib.sha512(self.bytes_ + passwd.encode('latin1')).hexdigest()
u = UserProfile(password='sha512+base64$%s$%s' %
(encodestring(self.bytes_), hsh))
assert u.check_password(self.utf) is False
assert u.has_usable_password() is True
示例4: test_persona_sha512_md5_base64
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_persona_sha512_md5_base64(self):
md5 = hashlib.md5('password').hexdigest()
hsh = hashlib.sha512(self.bytes_ + md5).hexdigest()
u = UserProfile(password='sha512+MD5+base64$%s$%s' %
(encodestring(self.bytes_), hsh))
assert u.check_password('password') is True
assert u.has_usable_password() is True
示例5: test_valid_old_password
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_valid_old_password(self):
hsh = hashlib.md5(encoding.smart_str(self.utf)).hexdigest()
u = UserProfile(password=hsh)
assert u.check_password(self.utf) is True
# Make sure we updated the old password.
algo, salt, hsh = u.password.split('$')
eq_(algo, 'sha512')
eq_(hsh, get_hexdigest(algo, salt, self.utf))
示例6: test_valid_old_password
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_valid_old_password(self):
hsh = hashlib.md5('sekrit').hexdigest()
u = UserProfile(password=hsh)
assert u.check_password('sekrit') is True
# Make sure we updated the old password.
algo, salt, hsh = u.password.split('$')
eq_(algo, 'sha512')
eq_(hsh, get_hexdigest(algo, salt, 'sekrit'))
示例7: test_persona_sha512_base64_maybe_utf8
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_persona_sha512_base64_maybe_utf8(self):
hsh = hashlib.sha512(self.bytes_ + self.utf.encode('utf8')).hexdigest()
u = UserProfile(password='sha512+base64$%s$%s' %
(encodestring(self.bytes_), hsh))
assert u.check_password(self.utf) is True
assert u.has_usable_password() is True
示例8: test_valid_new_password
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_valid_new_password(self):
u = UserProfile()
u.set_password(self.utf)
assert u.check_password(self.utf) is True
assert u.has_usable_password() is True
示例9: test_invalid_new_password
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_invalid_new_password(self):
u = UserProfile()
u.set_password(self.utf)
assert u.check_password('wrong') is False
assert u.has_usable_password() is True
示例10: test_invalid_old_password
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_invalid_old_password(self):
u = UserProfile(password=self.utf)
assert u.check_password(self.utf) is False
assert u.has_usable_password() is True
示例11: test_persona_sha512_base64
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_persona_sha512_base64(self):
hsh = hashlib.sha512(self.bytes_ + 'password').hexdigest()
u = UserProfile(password='sha512+base64$%s$%s' %
(encodestring(self.bytes_), hsh))
assert u.check_password('password') is True
示例12: test_invalid_old_password
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_invalid_old_password(self):
u = UserProfile(password=self.utf)
assert u.check_password(self.utf) is False
示例13: test_valid_new_password
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_valid_new_password(self):
u = UserProfile()
u.set_password('sekrit')
assert u.check_password('sekrit') is True
示例14: test_invalid_new_password
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_invalid_new_password(self):
u = UserProfile()
u.set_password('sekrit')
assert u.check_password('wrong') is False
示例15: test_invalid_old_password
# 需要导入模块: from users.models import UserProfile [as 别名]
# 或者: from users.models.UserProfile import check_password [as 别名]
def test_invalid_old_password(self):
u = UserProfile(password='sekrit')
assert u.check_password('sekrit') is False