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)
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
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)
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)
def getUser(userid): return User.get(userid)
def load_user(userid): return User.get(userid)
def test_User_can_be_retrieved_by_id(self): self.assertEqual(self.user, User.get(self.user.userid))
def test_Unauthenticated_user_is_loaded_as_unauthenticated(self): self.assertEqual(False, User.get(self.user.userid).is_authenticated)
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)
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)
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)
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)
def test_Inactive_user_is_loaded_as_inactive(self): self.assertEqual(False, User.get(self.user.userid).is_active())
def getAuthenticatedUser(self): authid, isHerself = self.getSession()['auth_user'] authuser = User.get(authid) return authuser, isHerself