本文整理汇总了Python中django.contrib.auth.tokens.PasswordResetTokenGenerator._make_token_with_timestamp方法的典型用法代码示例。如果您正苦于以下问题:Python PasswordResetTokenGenerator._make_token_with_timestamp方法的具体用法?Python PasswordResetTokenGenerator._make_token_with_timestamp怎么用?Python PasswordResetTokenGenerator._make_token_with_timestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.auth.tokens.PasswordResetTokenGenerator
的用法示例。
在下文中一共展示了PasswordResetTokenGenerator._make_token_with_timestamp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_date_length
# 需要导入模块: from django.contrib.auth.tokens import PasswordResetTokenGenerator [as 别名]
# 或者: from django.contrib.auth.tokens.PasswordResetTokenGenerator import _make_token_with_timestamp [as 别名]
def test_date_length(self):
"""
Overly long dates, which are a potential DoS vector, aren't allowed.
"""
user = User.objects.create_user('ima1337h4x0r', '[email protected]', 'p4ssw0rd')
p0 = PasswordResetTokenGenerator()
# This will put a 14-digit base36 timestamp into the token, which is too large.
with self.assertRaises(ValueError):
p0._make_token_with_timestamp(user, 175455491841851871349)
示例2: test_date_length
# 需要导入模块: from django.contrib.auth.tokens import PasswordResetTokenGenerator [as 别名]
# 或者: from django.contrib.auth.tokens.PasswordResetTokenGenerator import _make_token_with_timestamp [as 别名]
def test_date_length(self):
"""
Make sure we don't allow overly long dates, causing a potential DoS.
"""
user = User.objects.create_user('ima1337h4x0r', '[email protected]', 'p4ssw0rd')
p0 = PasswordResetTokenGenerator()
# This will put a 14-digit base36 timestamp into the token, which is too large.
tk1 = p0._make_token_with_timestamp(user, 175455491841851871349)
self.assertFalse(p0.check_token(user, tk1))