def create_submission(self, request): token = Token("submission") token.solve() self.submission_desc = yield self.get_dummy_submission(self.dummyContext["id"]) handler = self.request(self.submission_desc) yield handler.put(token.id) returnValue(self.responses[0])
def create_submission(self, request): token = Token(1, 'submission') token.solve() self.submission_desc = yield self.get_dummy_submission( self.dummyContext['id']) handler = self.request(self.submission_desc) response = yield handler.put(token.id) returnValue(response['receipt'])
def test_token_reuse_blocked(self): token = Token() token.solve() self.submission_desc = yield self.get_dummy_submission(self.dummyContext["id"]) handler = self.request(self.submission_desc) yield handler.put(token.id) yield self.assertFailure(handler.put(token.id), errors.TokenFailure)
def create_submission_with_files(self, request): token = Token("submission") token.solve() yield self.emulate_file_upload(token, 3) self.submission_desc = yield self.get_dummy_submission(self.dummyContext["id"]) handler = self.request(self.submission_desc) result = yield handler.put(token.id) returnValue(self.responses[0])
def create_submission_with_files(self, request): token = Token('submission') token.solve() yield self.emulate_file_upload(token, 3) self.submission_desc = yield self.get_dummy_submission( self.dummyContext['id']) handler = self.request(self.submission_desc) response = yield handler.put(token.id) returnValue(response)
def test_token_reuse_blocked(self): token = Token() token.solve() self.submission_desc = yield self.get_dummy_submission( self.dummyContext['id']) handler = self.request(self.submission_desc) yield handler.put(token.id) yield self.assertFailure(handler.put(token.id), errors.TokenFailure)
def test_token_update_wrong_answer(self): token = Token('submission') token.solve() token.human_captcha = {'question': 'XXX', 'answer': 1, 'solved': False} token.update({'human_captcha_answer': 0}) # verify that the challenge is changed self.assertNotEqual(token.human_captcha['question'], 'XXX')
def test_token_update_wrong_answer(self): token = Token('submission') token.solve() token.human_captcha = {'question': 'XXX', 'answer': 1, 'solved': False} token.update({'human_captcha_answer': 0}) # verify that the challenge is changed self.assertNotEqual(token.human_captcha['question'], 'XXX')
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'])
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()
def test_proof_of_work_wrong_answer(self): token = Token(1, '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} self.assertFalse(token.update({'proof_of_work_answer': 0})) # validate with right value: OK self.assertRaises(errors.TokenFailure, token.use)
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'])
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()
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)
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)