本文整理汇总了Python中globaleaks.utils.token.Token.proof_of_work方法的典型用法代码示例。如果您正苦于以下问题:Python Token.proof_of_work方法的具体用法?Python Token.proof_of_work怎么用?Python Token.proof_of_work使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类globaleaks.utils.token.Token
的用法示例。
在下文中一共展示了Token.proof_of_work方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_put
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import proof_of_work [as 别名]
def test_put(self):
self.submission_desc = yield self.get_dummy_submission(self.dummyContext['id'])
token = Token('submission')
token.proof_of_work = False
handler = self.request(self.submission_desc)
yield handler.put(token.id)
示例2: setup_tip_environment
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import proof_of_work [as 别名]
def setup_tip_environment(self):
self.context_desc = yield admin.context.create_context(self.dummyContext, 'en')
self.dummyReceiver_1['contexts'] = self.dummyReceiver_2['contexts'] = [self.context_desc['id']]
self.dummyReceiver_1['can_postpone_expiration'] = False
self.dummyReceiver_2['can_postpone_expiration'] = True
self.dummyReceiver_1['can_delete_submission'] = True
self.dummyReceiver_2['can_delete_submission'] = False
self.receiver1_desc = yield admin.receiver.create_receiver(self.dummyReceiver_1, 'en')
self.receiver2_desc = yield admin.receiver.create_receiver(self.dummyReceiver_2, 'en')
self.assertEqual(self.receiver1_desc['contexts'], [ self.context_desc['id']])
self.assertEqual(self.receiver2_desc['contexts'], [ self.context_desc['id']])
dummySubmissionDict = yield self.get_dummy_submission(self.context_desc['id'])
token = Token(token_kind='submission')
token.proof_of_work = False
self.submission_desc = yield submission.create_submission(token.id, dummySubmissionDict, False, 'en')
self.assertEqual(self.submission_desc['answers'], dummySubmissionDict['answers'])
tips_receiver_1 = yield receiver.get_receivertip_list(self.receiver1_desc['id'], 'en')
tips_receiver_2 = yield receiver.get_receivertip_list(self.receiver2_desc['id'], 'en')
self.rtip1_id = tips_receiver_1[0]['id']
self.rtip2_id = tips_receiver_2[0]['id']
self.rtip1_questionnaire_hash = tips_receiver_1[0]['questionnaire_hash']
self.rtip1_questionnaire_hash = tips_receiver_2[0]['questionnaire_hash']
示例3: test_submission_file_delivery_pgp
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import proof_of_work [as 别名]
def test_submission_file_delivery_pgp(self):
new_fields = MockDict().dummyFields
new_context = MockDict().dummyContext
new_context['name'] = "this uniqueness is no more checked due to the lang"
new_context_output = yield create_context(new_context, 'en')
self.context_assertions(new_context, new_context_output)
doubletest = yield get_context_list('en')
self.assertEqual(len(doubletest), 2)
yanr = self.get_dummy_receiver("antani1")
yanr['pgp_key_public'] = unicode(VALID_PGP_KEY1)
yanr['contexts'] = [ new_context_output['id']]
yanr_output = yield receiver.create_receiver(yanr, 'en')
self.receiver_assertions(yanr, yanr_output)
asdr = self.get_dummy_receiver("antani2")
asdr['pgp_key_public'] = unicode(VALID_PGP_KEY1)
asdr['contexts'] = [ new_context_output['id']]
asdr_output = yield receiver.create_receiver(asdr, 'en')
self.receiver_assertions(asdr, asdr_output)
new_subm = dict(MockDict().dummySubmission)
new_subm['finalize'] = False
new_subm['context_id'] = new_context_output['id']
new_subm['receivers'] = [ asdr_output['id'],
yanr_output['id'] ]
new_subm['identity_provided'] = False
new_subm['answers'] = yield self.fill_random_answers(new_context_output['id'])
token = Token('submission')
token.proof_of_work = False
yield self.emulate_file_upload(token, 3)
new_subm_output = yield submission.create_submission(token.id, new_subm, False, 'en')
yield DeliverySchedule().operation()
# now get a lots of receivertips/receiverfiles and check!
ifilist = yield self.get_internalfiles_by_wbtip(new_subm_output['id'])
self.assertTrue(isinstance(ifilist, list))
self.assertEqual(len(ifilist), 3)
rfilist = yield self.get_receiverfiles_by_wbtip(new_subm_output['id'])
self.assertTrue(isinstance(ifilist, list))
self.assertEqual(len(rfilist), 6)
for i in range(0, 3):
self.assertLess(ifilist[0]['size'], rfilist[i]['size'])
self.assertEqual(rfilist[0]['status'], u"encrypted" )
示例4: test_token_update_right_answer
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import proof_of_work [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)
示例5: test_proof_of_work_right_answer
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import proof_of_work [as 别名]
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()
示例6: test_put_right_answer
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import proof_of_work [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)
示例7: test_token_uses_limit
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import proof_of_work [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
)
示例8: test_proof_of_work_right_answer
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import proof_of_work [as 别名]
def test_proof_of_work_right_answer(self):
token = Token('submission')
difficulty = {
'human_captcha': False,
'graph_captcha': False,
'proof_of_work': False
}
token.generate_token_challenge(difficulty)
token = TokenList.get(token.id)
# 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" }
# validate with right value: OK
self.assertTrue(token.update({'proof_of_work_answer': 0}))
示例9: test_put_wrong_answer
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import proof_of_work [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')
示例10: test_proof_of_work_right_answer
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import proof_of_work [as 别名]
def test_proof_of_work_right_answer(self):
# This is at the beginning
event.EventTrackQueue.reset()
token = Token('submission')
difficulty = {
'human_captcha': False,
'graph_captcha': False,
'proof_of_work': False
}
token.generate_token_challenge(difficulty)
token = TokenList.get(token.id)
# 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" }
# validate with right value: OK
self.assertFalse(token.update({'proof_of_work_answer': 26}))
# verify that the challenge is marked as solved
self.assertFalse(token.proof_of_work)
示例11: create_submission_with_files
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import proof_of_work [as 别名]
def create_submission_with_files(self, request):
token = Token('submission')
token.proof_of_work = False
yield self.emulate_file_upload(token, 3)
output = yield create_submission(token.id, request, False, 'en')
returnValue(output)
示例12: create_submission
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import proof_of_work [as 别名]
def create_submission(self, request):
token = Token('submission')
token.proof_of_work = False
output = yield create_submission(token.id, request, True, 'en')
returnValue(output)