本文整理汇总了Python中globaleaks.utils.token.Token.remaining_allowed_attempts方法的典型用法代码示例。如果您正苦于以下问题:Python Token.remaining_allowed_attempts方法的具体用法?Python Token.remaining_allowed_attempts怎么用?Python Token.remaining_allowed_attempts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类globaleaks.utils.token.Token
的用法示例。
在下文中一共展示了Token.remaining_allowed_attempts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_token_validate
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import remaining_allowed_attempts [as 别名]
def test_token_validate(self):
# This is at the beginning
anomaly.EventTrackQueue.reset()
token = Token('submission', context_id='ignored')
difficulty = {
'human_captcha': True,
'graph_captcha': False,
'proof_of_work': False,
}
token.set_difficulty(difficulty)
token = TokenList.get(token.token_id)
token.human_captcha = { 'answer': 1 }
token.remaining_allowed_attempts = 1
# validate with right value: OK
token.validate({'human_captcha_answer': 1})
# validate with wrong value: FAIL
self.assertRaises(
errors.TokenFailure,
token.validate, {'human_captcha_answer': 0}
)
# validate with right value but with no additional
# attemps available: FAIL
self.assertRaises(
errors.TokenFailure,
token.validate, {'human_captcha_answer': 1}
)
示例2: test_token_validate
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import remaining_allowed_attempts [as 别名]
def test_token_validate(self):
# This is at the beginning
event.EventTrackQueue.reset()
token = Token("submission", context_id="ignored")
difficulty = {"human_captcha": True, "graph_captcha": False, "proof_of_work": False}
token.set_difficulty(difficulty)
token = TokenList.get(token.token_id)
token.human_captcha = {"answer": 1}
token.remaining_allowed_attempts = 1
# validate with right value: OK
token.validate({"human_captcha_answer": 1})
# validate with wrong value: FAIL
self.assertRaises(errors.TokenFailure, token.validate, {"human_captcha_answer": 0})
# validate with right value but with no additional
# attemps available: FAIL
self.assertRaises(errors.TokenFailure, token.validate, {"human_captcha_answer": 1})