本文整理汇总了Python中pdoauth.models.Assurance.Assurance类的典型用法代码示例。如果您正苦于以下问题:Python Assurance类的具体用法?Python Assurance怎么用?Python Assurance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Assurance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_verify_email
def do_verify_email(self, token):
cred = self.getCredentialForEmailverifyToken(token)
self.checkEmailverifyCredential(cred)
user = cred.user
Assurance.new(user,emailVerification,user)
cred.rm()
return self.simple_response("email verified OK")
示例2: _loginAndDeregister
def _loginAndDeregister(self):
self.createLoggedInUser()
user = self.cred.user
Assurance.new(user, "test", user)
self._assureHaveCredentialsAndAssurances(user)
resp = self._doDeregister()
return resp
示例3: prepareHashCollision
def prepareHashCollision(self, assuredTarget, email=None):
form = self.prepareLoginForm(email=email)
self.anotherUser = self.createUserWithCredentials().user
self.anotherUser.hash = self.targetUser.hash
if assuredTarget:
Assurance.new(self.anotherUser, 'test', self.cred.user)
return form
示例4: setUp
def setUp(self):
self.anyuser = User.query.first() # @UndefinedVariable
self.user = self.createUserWithCredentials().user
Assurance.new(self.user, 'emailverification', self.user)
self.oldEmailAddress = self.userCreationEmail
self.newEmailAddress = "email{0}@example.com".format(self.mkRandomString(5))
PDUnitTest.setUp(self)
示例5: updateHashAndAssurances
def updateHashAndAssurances(self, user, digest):
user.hash = digest
assurances = Assurance.listByUser(user)
self.deleteHandAssuredAssurances(assurances)
if digest is not None:
Assurance.new(user, "hashgiven", user)
user.save()
示例6: users_with_assurer_assurance_can_get_user_by_email
def users_with_assurer_assurance_can_get_user_by_email(self):
current_user = self.controller.getCurrentUser()
Assurance.new(current_user, 'assurer', current_user)
self.setupRandom()
self.createUserWithCredentials()
target = User.getByEmail(self.usercreation_email)
resp = self.controller.do_get_by_email(target.email)
self.assertUserResponse(resp)
示例7: test_the_applications_receive_intersection_of_users_assurances_and_applications_assurances
def test_the_applications_receive_intersection_of_users_assurances_and_applications_assurances(self):
AppAssurance.add(self.app, 'test')
AppAssurance.add(self.app, 'test2')
user = self.cred.user
Assurance.new(user, "test", user)
Assurance.new(user, "test3", user)
userinfo = self.getUserInfo()
self.assertEqual(userinfo['assurances'], ['test'])
示例8: users_without_assurer_assurance_cannot_get_email_and_digest_for_anyone
def users_without_assurer_assurance_cannot_get_email_and_digest_for_anyone(self):
current_user = self.controller.getCurrentUser()
targetuser=self.createUserWithCredentials()
Assurance.new(targetuser,'test',current_user)
target = User.getByEmail(self.usercreation_email)
with self.assertRaises(ReportedError) as e:
self.showUserByCurrentUser(target.userid)
self.assertTrue(e.exception.status,403)
示例9: no_by_email_with_wrong_email
def no_by_email_with_wrong_email(self):
current_user = self.controller.getCurrentUser()
Assurance.new(current_user, 'assurer', current_user)
self.setupRandom()
self.createUserWithCredentials()
target = User.getByEmail(self.usercreation_email)
with self.assertRaises(ReportedError) as e:
self.controller.do_get_by_email('u'+target.email)
self.assertTrue(e.exception.status,404)
示例10: test_users_with_assurer_assurance_can_get_email_and_digest_for_anyone
def test_users_with_assurer_assurance_can_get_email_and_digest_for_anyone(self):
current_user = self._createAssurer()
targetuser=self.createUserWithCredentials().user
Assurance.new(targetuser,'test',current_user)
target = User.getByEmail(self.userCreationEmail)
resp = self.showUserByCurrentUser(target.userid)
data = self.fromJson(resp)
assurances = data['assurances']
self.assertEqual(assurances['test'][0]['assurer'], current_user.email)
示例11: test_the_emailverification_assurance_does_not_count_in_hash_collision
def test_the_emailverification_assurance_does_not_count_in_hash_collision(self):
anotherUser = self.createUserWithCredentials().user
Assurance.new(anotherUser, "emailverification", anotherUser)
theHash = self.createHash()
anotherUser.hash = theHash
form = self.prepareLoginForm(digest=theHash)
resp = self.controller.doRegistration(form)
self.assertEqual(200, resp.status_code)
data = self.fromJson(resp)
self.assertEqual(data['message'],anotherUserUsingYourHash)
示例12: updateEmailByCredential
def updateEmailByCredential(self, cred, verify):
oldemail=cred.user.email
cred.user.email = cred.getAdditionalInfo()
cred.user.save()
for assurance in Assurance.listByUser(cred.user, 'emailverification'):
assurance.rm()
if verify:
Assurance.new(cred.user, 'emailverification', cred.user)
else:
self.sendPasswordVerificationEmail(cred.user)
self.sendEmail(cred.user, None, None, "CHANGE_EMAIL_DONE",oldemail=oldemail, newemail=cred.user.email)
示例13: test_error_message_on_hash_collision
def test_error_message_on_hash_collision(self):
anotheruser = self.createUserWithCredentials().user
digest = self.createHash()
anotheruser.hash = digest
Assurance.new(anotheruser, "test", anotheruser)
anotheruser.save()
with app.test_client() as client:
resp = self.doUpdateHashForUser(client, digest=digest)
self.assertEqual(400, resp.status_code)
self.assertEqual('{"errors": ["another user is using your hash"]}', resp.data.decode('utf-8'))
示例14: doAddAssurance
def doAddAssurance(self, form):
neededAssurance = form.assurance.data
self.assureUserHaveTheGivingAssurancesFor(neededAssurance)
user = self.getUserForEmailAndOrHash(
form.digest.data, form.email.data)
numOfOthers = self.deleteDigestFromOtherUsers(user)
Assurance.new(user, neededAssurance, self.getCurrentUser())
msg = [[addedAssurance, neededAssurance, user.email]]
if numOfOthers:
msg.append([otherUsersWithYourHash, str(numOfOthers)])
return self.simple_response(msg)
示例15: assurers_need_assurer_assurance
def assurers_need_assurer_assurance(self):
with app.test_client() as c:
target = self._setupTestWithoutAssurance(c)
Assurance.new(current_user, 'assurer.test', current_user)
data = dict(
digest = target.hash,
assurance = "test",
email = target.email,
csrf_token = self.getCSRF(c))
resp = c.post(config.base_url + '/v1/add_assurance', data = data)
self.assertEquals(403, resp.status_code)
self.assertEquals('{"errors": ["no authorization"]}', self.getResponseText(resp))