コード例 #1
0
    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})
コード例 #2
0
ファイル: test_token.py プロジェクト: RuanAragao/GlobaLeaks
    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}
        )
コード例 #3
0
ファイル: test_token.py プロジェクト: alitalia/GlobaLeaks
    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})