Example #1
0
 def setCanEmail(self, appName, user, value):
     app = Application.find(appName)
     if app == None:
         raise ReportedError(Messages.unknownApplication)
     theMap = AppMap.get(app, user)
     theMap.can_email = value
     theMap.save()
Example #2
0
 def setCanEmail(self, appName, user, value):
     app = Application.find(appName)
     if app == None:
         raise ReportedError(Messages.unknownApplication)
     theMap = AppMap.get(app, user)
     theMap.can_email = value
     theMap.save()
Example #3
0
 def test_the_email_address_shown_for_the_user_is_userid_dot_appname_at_EMAILDOMAIN(
         self):
     userinfo1 = self.getUserInfo()
     appMapEntry = AppMap.get(self.app, self.cred.user)
     emailAddress = "{0}.{1}@{2}".format(appMapEntry.userid, self.app.name,
                                         config.Config.EMAIL_DOMAIN)
     self.assertEqual(userinfo1['email'], emailAddress)
     self.assertEqual(userinfo1['email'], appMapEntry.getEmail())
Example #4
0
 def test_the_email_address_shown_for_the_user_is_userid_dot_appname_at_EMAILDOMAIN(self):
     userinfo1 = self.getUserInfo()
     appMapEntry = AppMap.get(self.app, self.cred.user)
     emailAddress = "{0}.{1}@{2}".format(
                     appMapEntry.userid,
                     self.app.name,
                     config.Config.EMAIL_DOMAIN)
     self.assertEqual(userinfo1['email'], emailAddress)
     self.assertEqual(userinfo1['email'], appMapEntry.getEmail())
Example #5
0
 def test_the_server_can_get_your_user_info_with_your_access_token(self):
     accessToken = self.obtainAccessToken()['access_token']
     url = TE.backendUrl + "/v1/users/me"
     headers = {'Authorization': 'Bearer {0}'.format(accessToken)}
     resp = requests.get(url, headers=headers, verify=False)
     answer = resp.json()
     user = User.getByEmail(self.userCreationEmail)
     appMapEntry = AppMap.get(TE.app, user)
     self.assertEqual(answer['email'], appMapEntry.getEmail())
     self.assertEqual(answer['assurances'], [])
Example #6
0
 def test_the_server_can_get_your_user_info_with_your_access_token(self):
     accessToken = self.obtainAccessToken()['access_token']
     url = TE.backendUrl + "/v1/users/me"
     headers = {'Authorization': 'Bearer {0}'.format(accessToken)}
     resp = requests.get(url, headers=headers, verify=False)
     answer = resp.json()
     user = User.getByEmail(self.userCreationEmail)
     appMapEntry = AppMap.get(TE.app, user)
     self.assertEqual(answer['email'], appMapEntry.getEmail())
     self.assertEqual(answer['assurances'], [])
Example #7
0
 def shownDataForApp(self, user, authenticator):
     app = Application.get(authenticator)
     appmapEntry = AppMap.get(app, user)
     shownEmail = appmapEntry.getEmail()
     shownUserId = appmapEntry.userid
     shownAssurances = self.computeAssurancesForApp(user, app)
     return dict(
         email=shownEmail,
         userid=shownUserId,
         assurances=shownAssurances)
Example #8
0
 def shownDataForApp(self, user, authenticator):
     app = Application.get(authenticator)
     appmapEntry = AppMap.get(app, user)
     shownEmail = appmapEntry.getEmail()
     shownUserId = appmapEntry.userid
     shownAssurances = self.computeAssurancesForApp(user, app)
     return dict(
         email=shownEmail,
         userid=shownUserId,
         assurances=shownAssurances)
Example #9
0
 def assertUserSetTheMap(self, app, theCase, theString):
     with app.test_client() as c:
         theApp = self.chooseAppWithOppositeEmailCapability(theCase)
         self.login(c, self.user)
         csrf = self.getCSRF(c)
         data = dict(csrf_token=csrf,
                     appname=theApp.name,
                     canemail=theString)
         resp = c.post("/v1/setappcanemail", data=data)
         self.assertEqual('200 OK', resp.status)
         self.assertEqual(theCase, AppMap.get(theApp, self.user).can_email)
Example #10
0
 def test_the_user_can_unset_the_can_email_attribute_of_the_app_map(self):
     boundApp = self.emailerApps[0]
     theMap = AppMap.get(boundApp, self.user)
     theMap.can_email = True
     self.appHandler.setCanEmail(boundApp.name, self.user, False)
     self.assertEqual(theMap.can_email, False)
Example #11
0
 def chooseAppWithOppositeEmailCapability(self, canEmail):
     for appName in self.appNames:
         theApp = Application.find(appName)
         theMap = AppMap.get(theApp, self.user)
         if theMap.can_email is not canEmail:
             return theApp
Example #12
0
 def test_the_user_can_unset_the_can_email_attribute_of_the_app_map(self):
     boundApp = self.emailerApps[0]
     theMap = AppMap.get(boundApp, self.user)
     theMap.can_email = True
     self.appHandler.setCanEmail(boundApp.name, self.user, False)
     self.assertEqual(theMap.can_email, False)