Example #1
0
 def test_email_validation_email_can_be_resent(self):
     with app.test_client() as client:
         self.login(client)
         client.get(config.BASE_URL + "/v1/send_verify_email")
         user = User.get(self.userid)
         self.assertEqual(
             self.userCreationEmail,
             Credential.getByUser(user, "emailcheck").user.email)
 def test_email_change_can_be_confirmed(self):
     with app.test_client() as client:
         resp = self.initiateEmailChange(client)
         self.assertEmailChangeIsInitiated(resp)
         data = dict(confirm=True,secret=self.secret)
         resp = client.post(config.BASE_URL + '/v1/confirmemailchange', data=data)
         text = self.getResponseText(resp)
         self.assertEqual(200,resp.status_code)
         self.assertEqual(Messages.emailChanged, json.loads(text)["message"])
         user=User.get(self.userid)
         self.assertEqual(self.newEmail,user.email)
Example #3
0
 def getShownUser(self, userid, authuser, isHerself):
     if userid == 'me':
         shownUser = authuser
     elif isHerself:
         if Assurance.getByUser(authuser).has_key('assurer'):
             shownUser = User.get(userid)
         else:
             raise ReportedError(["no authorization to show other users"], status=403)
     else:
         raise ReportedError(["no authorization to show other users"], status=403)
     return shownUser
Example #4
0
 def test_email_change_can_be_confirmed(self):
     with app.test_client() as client:
         resp = self.initiateEmailChange(client)
         self.assertEmailChangeIsInitiated(resp)
         data = dict(confirm=True, secret=self.secret)
         resp = client.post(config.BASE_URL + '/v1/confirmemailchange',
                            data=data)
         text = self.getResponseText(resp)
         self.assertEqual(200, resp.status_code)
         self.assertEqual(Messages.emailChanged,
                          json.loads(text)["message"])
         user = User.get(self.userid)
         self.assertEqual(self.newEmail, user.email)
Example #5
0
 def getDataOfUserForAuthenticator(self, userid, authuser, authenticator):
     user = User.get(userid)
     if not user:
             raise ReportedError([noSuchUser], status=404)
     if self.doesUserAskOwnData(userid, authenticator):
         return self.shownDataForUser(user)
     if self.doesUserAskForOthersData(authuser, authenticator):
         assurances = Assurance.getByUser(authuser)
         if 'assurer' in assurances:
             return self.shownDataForAssurer(user)
         else:
             raise ReportedError([noShowAuthorization], status=403)
     return self.shownDataForApp(user, authenticator)
Example #6
0
 def getDataOfUserForAuthenticator(self, userid, authuser, authenticator):
     user = User.get(userid)
     if not user:
             raise ReportedError([noSuchUser], status=404)
     if self.doesUserAskOwnData(userid, authenticator):
         return self.shownDataForUser(user)
     if self.doesUserAskForOthersData(authuser, authenticator):
         assurances = Assurance.getByUser(authuser)
         if 'assurer' in assurances:
             return self.shownDataForAssurer(user)
         else:
             raise ReportedError([noShowAuthorization], status=403)
     return self.shownDataForApp(user, authenticator)
Example #7
0
def getUser(userid):
    return User.get(userid)
Example #8
0
def load_user(userid):
    return User.get(userid)
Example #9
0
 def test_User_can_be_retrieved_by_id(self):
     self.assertEqual(self.user, User.get(self.user.userid))
Example #10
0
 def test_Unauthenticated_user_is_loaded_as_unauthenticated(self):
     self.assertEqual(False, User.get(self.user.userid).is_authenticated)
Example #11
0
 def getAuthenticatedUser(self):
     authid, authenticator = self.getSession()['auth_user']
     authuser = User.get(authid)
     return authuser, authenticator
 def test_email_validation_email_can_be_resent(self):
     with app.test_client() as client:
         self.login(client)
         client.get(config.BASE_URL + "/v1/send_verify_email")
         user=User.get(self.userid)
         self.assertEqual(self.userCreationEmail, Credential.getByUser(user, "emailcheck").user.email)
Example #13
0
 def test_confirmChangeEmail_does_not_change_email_address_to_the_new_one_if_confirm_is_false(self):
     self.doConfirmChangeEmail(confirm=False)
     user = User.get(self.user.userid)
     self.assertEqual(self.oldEmailAddress, user.email)
Example #14
0
 def test_confirmChangeEmail_changes_email_address_to_the_new_one(self):
     self.doConfirmChangeEmail()
     user = User.get(self.user.userid)
     self.assertEqual(self.newEmailAddress, user.email)
Example #15
0
 def test_emailChangeInit_does_not_change_email_address(self):
     self.controller.emailChangeInit(self.newEmailAddress, self.user)
     user = User.get(self.user.userid)
     self.assertEqual(self.oldEmailAddress, self.user.email)
     self.assertEqual(self.oldEmailAddress, user.email)
Example #16
0
 def test_Inactive_user_is_loaded_as_inactive(self):
     self.assertEqual(False, User.get(self.user.userid).is_active())
Example #17
0
 def getAuthenticatedUser(self):
     authid, isHerself = self.getSession()['auth_user']
     authuser = User.get(authid)
     return authuser, isHerself
Example #18
0
def getUser(userid):
    return User.get(userid)