本文整理汇总了Python中pdoauth.models.Assurance.Assurance.new方法的典型用法代码示例。如果您正苦于以下问题:Python Assurance.new方法的具体用法?Python Assurance.new怎么用?Python Assurance.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pdoauth.models.Assurance.Assurance
的用法示例。
在下文中一共展示了Assurance.new方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepareHashCollision
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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
示例2: _loginAndDeregister
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
def _loginAndDeregister(self):
self.createLoggedInUser()
user = self.cred.user
Assurance.new(user, "test", user)
self._assureHaveCredentialsAndAssurances(user)
resp = self._doDeregister()
return resp
示例3: do_verify_email
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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")
示例4: setUp
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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: test_error_message_on_hash_collision
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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'))
示例13: doAddAssurance
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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)
示例14: updateEmailByCredential
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
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)
示例15: test_if_hash_is_same_no_assurances_deleted
# 需要导入模块: from pdoauth.models.Assurance import Assurance [as 别名]
# 或者: from pdoauth.models.Assurance.Assurance import new [as 别名]
def test_if_hash_is_same_no_assurances_deleted(self):
digest = self.createHash()
user = self.createUserWithCredentials().user
data = dict(
digest=digest
)
self.controller.checkAndUpdateHash(FakeForm(data), user)
Assurance.new(user, "test", user)
self.controller.checkAndUpdateHash(FakeForm(data), user)
assurances = Assurance.getByUser(user)
self.assertTrue("test" in assurances.keys())
self.assertTrue("hashgiven" in assurances.keys())