当前位置: 首页>>代码示例>>Python>>正文


Python Token.human_captcha方法代码示例

本文整理汇总了Python中globaleaks.utils.token.Token.human_captcha方法的典型用法代码示例。如果您正苦于以下问题:Python Token.human_captcha方法的具体用法?Python Token.human_captcha怎么用?Python Token.human_captcha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在globaleaks.utils.token.Token的用法示例。


在下文中一共展示了Token.human_captcha方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_token_validate

# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import human_captcha [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}
        )
开发者ID:RuanAragao,项目名称:GlobaLeaks,代码行数:35,代码来源:test_token.py

示例2: test_token_update_wrong_answer

# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import human_captcha [as 别名]
    def test_token_update_wrong_answer(self):
        token = Token('submission')

        token.human_captcha = {'question': 'XXX','answer': 1}

        token.update({'human_captcha_answer': 0})

        # verify that the challenge is changed
        self.assertNotEqual(token.human_captcha['question'], 'XXX')
开发者ID:br1n0,项目名称:GlobaLeaks,代码行数:11,代码来源:test_token.py

示例3: test_token_update_right_answer

# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import human_captcha [as 别名]
    def test_token_update_right_answer(self):
        token = Token('submission')

        token.human_captcha = {'question': '1 + 0','answer': 1}
        token.proof_of_work = False

        # validate with right value: OK
        token.update({'human_captcha_answer': 1})

        # verify that the challenge is marked as solved
        self.assertFalse(token.human_captcha)
开发者ID:br1n0,项目名称:GlobaLeaks,代码行数:13,代码来源:test_token.py

示例4: test_token_update_right_answer

# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import human_captcha [as 别名]
    def test_token_update_right_answer(self):
        token = Token('submission')
        token.solve()

        token.human_captcha = {'question': '1 + 0', 'answer': 1, 'solved': False}

        # validate with right value: OK
        self.assertTrue(token.update({'human_captcha_answer': 1}))

        # verify that the challenge is marked as solved
        self.assertTrue(token.human_captcha['solved'])
开发者ID:Taipo,项目名称:GlobaLeaks,代码行数:13,代码来源:test_token.py

示例5: test_put_wrong_answer

# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import human_captcha [as 别名]
    def test_put_wrong_answer(self):
        self.pollute_events()
        yield Alarm.compute_activity_level()

        token = Token('submission')

        token.human_captcha = {'question': 'XXX','answer': 1, 'solved': False}

        request_payload = token.serialize()

        request_payload['human_captcha_answer'] = 883

        handler = self.request(request_payload)
        self.assertRaises(errors.TokenFailure, handler.put, token.id)
开发者ID:,项目名称:,代码行数:16,代码来源:

示例6: test_token_usage_limit

# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import human_captcha [as 别名]
    def test_token_usage_limit(self):
        token = Token('submission')
        token.solve()

        token.human_captcha = {'question': 'XXX', 'answer': 1, 'solved': False}

        # validate with right value: OK
        token.update({'human_captcha_answer': 1})

        for i in range(0, token.MAX_USES-1):
            token.use()

        # validate with right value but with no additional
        # attempts available: FAIL
        self.assertRaises(errors.TokenFailure, token.use)
开发者ID:Taipo,项目名称:GlobaLeaks,代码行数:17,代码来源:test_token.py

示例7: test_put_right_answer

# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import human_captcha [as 别名]
    def test_put_right_answer(self):
        pollute_events_for_testing()
        yield Alarm.compute_activity_level()

        token = Token('submission')

        token.human_captcha = {'question': 'XXX','answer': 1}
        token.proof_of_work = False

        request_payload = token.serialize()

        request_payload['human_captcha_answer'] = 1

        handler = self.request(request_payload)
        yield handler.put(token.id)

        self.assertEqual(self.responses[0]['human_captcha'], False)
开发者ID:comradekingu,项目名称:GlobaLeaks,代码行数:19,代码来源:test_token.py

示例8: test_token_uses_limit

# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import human_captcha [as 别名]
    def test_token_uses_limit(self):
        token = Token('submission')

        token.human_captcha = False
        token.proof_of_work = False

        # validate with right value: OK
        token.update({'human_captcha_answer': 1})

        for i in range(0, token.MAX_USES):
            token.use()

        # validate with right value but with no additional
        # attempts available: FAIL
        self.assertRaises(
            errors.TokenFailure,
            token.use
        )
开发者ID:br1n0,项目名称:GlobaLeaks,代码行数:20,代码来源:test_token.py

示例9: test_put_right_answer

# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import human_captcha [as 别名]
    def test_put_right_answer(self):
        event.EventTrackQueue.reset()

        pollute_events_for_testing()
        yield anomaly.compute_activity_level()

        token = Token('submission')

        token.human_captcha = {'question': 'XXX','answer': 1}

        request_payload = token.serialize()

        request_payload['human_captcha_answer'] = 1

        handler = self.request(request_payload)
        yield handler.put(token.id)

        self.assertEqual(self.responses[0]['human_captcha'], False)
开发者ID:nsfw,项目名称:GlobaLeaks,代码行数:20,代码来源:test_token.py

示例10: test_put_right_answer

# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import human_captcha [as 别名]
    def test_put_right_answer(self):
        self.pollute_events()
        yield Alarm.compute_activity_level()

        token = Token('submission')
        token.human_captcha = {'question': 'XXX','answer': 1, 'solved': False}
        token.proof_of_work['solved'] = True

        request_payload = token.serialize()
        request_payload['human_captcha_answer'] = 1

        handler = self.request(request_payload)

        yield handler.put(token.id)

        token.use()

        self.assertFalse(self.responses[0]['human_captcha'])
        self.assertTrue(token.human_captcha['solved'])
开发者ID:,项目名称:,代码行数:21,代码来源:

示例11: test_put_wrong_answer

# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import human_captcha [as 别名]
    def test_put_wrong_answer(self):
        event.EventTrackQueue.reset()

        pollute_events_for_testing()
        yield Alarm.compute_activity_level()

        token = Token('submission')

        token.human_captcha = {'question': 'XXX','answer': 1}
        token.proof_of_work = False

        request_payload = token.serialize()

        request_payload['human_captcha_answer'] = 2

        handler = self.request(request_payload)
        yield handler.put(token.id)

        self.assertNotEqual(self.responses[0]['human_captcha'], False)

        # verify that the question is changed
        self.assertNotEqual(self.responses[0]['human_captcha'], 'XXX')
开发者ID:jpobley,项目名称:GlobaLeaks,代码行数:24,代码来源:test_token.py

示例12: test_token_validate

# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import human_captcha [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})
开发者ID:alitalia,项目名称:GlobaLeaks,代码行数:25,代码来源:test_token.py


注:本文中的globaleaks.utils.token.Token.human_captcha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。