Exemple #1
0
    def test_proof_of_work_right_answer(self):
        token = Token('submission')
        token.solve()

        # Note, this solution works with two '00' at the end, if the
        # difficulty changes, also this dummy value has to.
        token.proof_of_work = {'question': "7GJ4Sl37AEnP10Zk9p7q", 'solved': False}

        # validate with right value: OK
        self.assertTrue(token.update({'proof_of_work_answer': 26}))
        token.use()
Exemple #2
0
    def test_proof_of_work_right_answer(self):
        token = Token('submission')
        token.solve()

        # Note, this solution works with two '00' at the end, if the
        # difficulty changes, also this dummy value has to.
        token.proof_of_work = {'question': "7GJ4Sl37AEnP10Zk9p7q", 'solved': False}

        # validate with right value: OK
        self.assertTrue(token.update({'proof_of_work_answer': 26}))
        token.use()
Exemple #3
0
    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)
Exemple #4
0
    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 _ in range(token.MAX_USES-1):
            token.use()

        # validate with right value but with no additional
        # attempts available: FAIL
        self.assertRaises(errors.TokenFailure, token.use)
Exemple #5
0
    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)
Exemple #6
0
    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
        )