Esempio n. 1
0
 def createEmailtestApp(klass):
     name = klass.createRandomUserId()
     app = Application.new(name, name, "https://{0}.com/".format(name))
     klass.allApps.add(app)
     AppMap.new(app, klass.user)
     klass.boundApps.add(app)
     klass.app = app
Esempio n. 2
0
 def _getDeregistrationSecret(self):
     self._loginAndDeregister()
     user = self.cred.user
     if self.addAppMapToUser == True:
         app = Application.query.first()  # @UndefinedVariable
         AppMap.new(app, user)
     deregistrationCredential = Credential.getByUser(user, 'deregister')
     secret = deregistrationCredential.secret
     return secret
Esempio n. 3
0
 def _getDeregistrationSecret(self):
     self._loginAndDeregister()
     user = self.cred.user
     if self.addAppMapToUser==True:
         app = Application.query.first()  # @UndefinedVariable
         AppMap.new(app, user)
     deregistrationCredential = Credential.getByUser(user, 'deregister')
     secret = deregistrationCredential.secret
     return secret
Esempio n. 4
0
 def test_in_hash_collision_if_the_other_user_is_hand_assured_the_user_is_not_deleted(self):
     anotheruser = self.createUserWithCredentials().user
     digest = self.createHash()
     anotheruser.hash = digest
     Assurance.new(anotheruser, "test", anotheruser)
     anotheruser.save()
     user = self.createUserWithCredentials().user
     app = Application.query.first()  # @UndefinedVariable
     AppMap.new(app, user)
     email = self.userCreationEmail
     additionalInfo = dict()
     with self.assertRaises(ReportedError):
         self.controller.checkHashInOtherUsers(user,additionalInfo,digest)
     self.assertEqual(email, User.getByEmail(email).email)
Esempio n. 5
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()
Esempio n. 6
0
 def test_the_list_of_applications_contain_all_applications_for_the_user(
         self):
     userMaps = AppMap.getForUser(self.user)
     appList = set()
     for appMap in userMaps:
         appList.add(appMap.app)
     self.assertEqual(self.boundApps, appList)
Esempio n. 7
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()
Esempio n. 8
0
 def test_proxy_id_is_not_created_deterministically(self):
     cred = self.createLoggedInUser()
     app = self.app
     mapentry = AppMap(app, cred.user)
     mapentry.save()
     oldid = mapentry.userid
     mapentry.rm();
     mapentry = AppMap(app, cred.user)
     self.assertNotEqual(oldid, mapentry.userid)
Esempio n. 9
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())
Esempio n. 10
0
 def removeFbuser(self, user=None):
     if user is None:
         user = config.facebookUser2
     self.user = User.getByEmail(user.email)
     if self.user:
         Credential.getByUser(self.user, "facebook").rm()
         for appMap in AppMap.getForUser(self.user):
             appMap.rm()
         self.user.rm()
Esempio n. 11
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())
Esempio n. 12
0
 def removeFbuser(self,user=None):
     if user is None:
         user = config.facebookUser2
     self.user = User.getByEmail(user.email)
     if self.user:
         Credential.getByUser(self.user, "facebook").rm()
         for appMap in AppMap.getForUser(self.user):
             appMap.rm()
         self.user.rm()
Esempio n. 13
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)
Esempio n. 14
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)
Esempio n. 15
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'], [])
Esempio n. 16
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'], [])
Esempio n. 17
0
 def test_the_list_entries_contain_whether_the_user_enabled_emailing(self):
     missingCount = 0
     for entry in self.appList:
         app = Application.find(entry['name'])
         mapEntry = AppMap.find(app, self.user)
         if mapEntry:
             self.assertEqual(entry['email_enabled'], mapEntry.can_email)
         else:
             missingCount += 1
     self.assertTrue(missingCount < len(self.appList))
     self.assertTrue(missingCount > 0)
Esempio n. 18
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)
Esempio n. 19
0
 def test_the_list_entries_contain_whether_the_user_enabled_emailing(self):
     missingCount= 0
     for entry in self.appList:
         app = Application.find(entry['name'])
         mapEntry=AppMap.find(app,self.user)
         if mapEntry:
             self.assertEqual(entry['email_enabled'], mapEntry.can_email)
         else:
             missingCount += 1
     self.assertTrue(missingCount < len(self.appList))
     self.assertTrue(missingCount > 0)
Esempio n. 20
0
 def createUserAppMapEntry(self, user, app):
     entry = dict(name=app.name,
                  can_email=app.can_email,
                  hostname=app.redirect_uri.split('/')[2])
     appMapEntry = AppMap.find(app, user)
     if appMapEntry:
         entry['email_enabled'] = appMapEntry.can_email
         entry['username'] = appMapEntry.userid
     else:
         entry['email_enabled'] = None
         entry['username'] = None
     return entry
Esempio n. 21
0
 def createUserAppMapEntry(self, user, app):
     entry = dict(name=app.name, 
         can_email=app.can_email, 
         hostname=app.redirect_uri.split('/')[2])
     appMapEntry = AppMap.find(app, user)
     if appMapEntry:
         entry['email_enabled'] = appMapEntry.can_email
         entry['username'] = appMapEntry.userid
     else:
         entry['email_enabled'] = None
         entry['username'] = None
     return entry
Esempio n. 22
0
    def createTestAppMaps(self):
        self.boundApps = set()
        self.emailerApps = list()
        for i in range(20):  # @UnusedVariable
            name = self.createRandomUserId()
            newApp = Application.new(name, name,
                                     "https://{0}.com/".format(name))
            if (random.randint(1, 2) == 1):
                newApp.can_email = True
                newApp.save()
                self.emailerApps.append(newApp)
        self.allApps = set(Application.all())

        self.emailerMaps = list()
        for app in self.allApps:
            if (random.randint(1, 2) == 1):
                self.boundApps.add(app)
                m = AppMap.new(app, self.user)
                if app.can_email and (random.randint(1, 2) == 1):
                    m.can_email = True
                    self.emailerMaps.append(m)
                    m.save()
Esempio n. 23
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)
Esempio n. 24
0
 def test_the_list_of_applications_contain_all_applications_for_the_user(self):
     userMaps = AppMap.getForUser(self.user)
     appList = set()
     for appMap in userMaps:
         appList.add(appMap.app)
     self.assertEqual(self.boundApps,appList)
Esempio n. 25
0
 def test_appMap_can_email_is_false_even_if_the_app_can_email(self):
     appMap = AppMap.new(self.app,self.user)
     self.emailerApps.append(self.app)
     self.assertEqual(False,appMap.can_email)
Esempio n. 26
0
 def test_appMap_can_email_is_false_by_default(self):
     appMap = AppMap.new(self.app,self.user)
     self.assertEqual(False,appMap.can_email)
Esempio n. 27
0
 def test_appMap_can_email_is_false_even_if_the_app_can_email(self):
     appMap = AppMap.new(self.app, self.user)
     self.emailerApps.append(self.app)
     self.assertEqual(False, appMap.can_email)
Esempio n. 28
0
 def removeAppMaps(self, user):
     for appmap in AppMap.getForUser(user):
         appmap.rm()
Esempio n. 29
0
 def test_the_list_entries_contain_the_proxy_username(self):
     for entry in self.appList:
         app = Application.find(entry['name'])
         mapEntry = AppMap.find(app, self.user)
         if mapEntry:
             self.assertEqual(entry['username'], mapEntry.userid)
Esempio n. 30
0
 def test_the_list_entries_contain_the_proxy_username(self):
     for entry in self.appList:
         app = Application.find(entry['name'])
         mapEntry=AppMap.find(app,self.user)
         if mapEntry:
             self.assertEqual(entry['username'], mapEntry.userid)
Esempio n. 31
0
 def removeAppMaps(self, user):
     for appmap in AppMap.getForUser(user):
         appmap.rm()
Esempio n. 32
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
Esempio n. 33
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)
Esempio n. 34
0
 def test_appMap_can_email_is_false_by_default(self):
     appMap = AppMap.new(self.app, self.user)
     self.assertEqual(False, appMap.can_email)