Example #1
0
    def setUp(self):
        from django_facebook.test_utils.mocks import MockFacebookAPI, MockFacebookAuthorization, RequestMock
        import sys
        import StringIO
        self.prints = sys.stdout = StringIO.StringIO()

        from open_facebook import api
        import open_facebook

        self.originalAPI = open_facebook.OpenFacebook
        self.originalAuthorization = open_facebook.FacebookAuthorization

        open_facebook.OpenFacebook = api.OpenFacebook = MockFacebookAPI
        open_facebook.FacebookAuthorization = api.FacebookAuthorization = MockFacebookAuthorization

        rf = RequestMock()
        self.request = rf.get('/')
        self.client = Client()

        # time to setup the test user
        user_model = get_user_model()
        user_dict = dict(
            username='******',
            is_staff=False,
            is_active=True,
            email="*****@*****.**",
        )
        test_ip = '127.0.0.1'
        # hack to make fashiolista tests run ok
        if is_user_attribute('registration_ip'):
            user_dict['registration_ip'] = test_ip
            user_dict['last_login_ip'] = test_ip
        user_model.objects.create(**user_dict)
Example #2
0
 def authenticate(self, *args, **kwargs):
     '''
     Route to either the user or profile table depending on which type of user
     customization we are using
     (profile was used in Django < 1.5, user is the new way in 1.5 and up)
     '''
     user_attribute = is_user_attribute('facebook_id')
     if user_attribute:
         user = self.user_authenticate(*args, **kwargs)
     else:
         user = self.profile_authenticate(*args, **kwargs)
     return user
Example #3
0
 def authenticate(self, facebook_id=None, facebook_email=None):
     '''
     Route to either the user or profile table depending on which type of user
     customization we are using
     (profile was used in Django < 1.5, user is the new way in 1.5 and up)
     '''
     user_attribute = is_user_attribute('facebook_id')
     if user_attribute:
         user = self.user_authenticate(facebook_id, facebook_email)
     else:
         user = self.profile_authenticate(facebook_id, facebook_email)
     return user
 def authenticate(self, *args, **kwargs):
     '''
     Route to either the user or profile table depending on which type of user
     customization we are using
     (profile was used in Django < 1.5, user is the new way in 1.5 and up)
     '''
     user_attribute = is_user_attribute('facebook_id')
     if user_attribute:
         kwargs1 = dict(filter(lambda(k,v): k in ['facebook_id', 'facebook_email'], kwargs.items()))
         user = self.user_authenticate(*args, **kwargs1)
     else:
         user = self.profile_authenticate(*args, **kwargs)
     return user
 def authenticate(self, facebook_id=None, facebook_email=None):
     '''
     Route to either the user or profile table depending on which type of user
     customization we are using
     (profile was used in Django < 1.5, user is the new way in 1.5 and up)
     '''
     logger.info('FacebookBackend authenticate %s %s', facebook_id, facebook_email)
     user_attribute = is_user_attribute('facebook_id')
     if user_attribute:
         user = self.user_authenticate(facebook_id, facebook_email)
     else:
         user = self.profile_authenticate(facebook_id, facebook_email)
     return user
Example #6
0
 def authenticate(self, *args, **kwargs):
     '''
     Route to either the user or profile table depending on which type of user
     customization we are using
     (profile was used in Django < 1.5, user is the new way in 1.5 and up)
     '''
     user_attribute = is_user_attribute('facebook_id')
     if user_attribute:
         kwargs1 = dict(
             filter(lambda (k, v): k in ['facebook_id', 'facebook_email'],
                    kwargs.items()))
         user = self.user_authenticate(*args, **kwargs1)
     else:
         user = self.profile_authenticate(*args, **kwargs)
     return user
 def authenticate(self, *args, **kwargs):
     '''
     Route to either the user or profile table depending on which type of user
     customization we are using
     (profile was used in Django < 1.5, user is the new way in 1.5 and up)
     '''
     logger.info("A01 Inside Authenticate function")
     user_attribute = is_user_attribute('facebook_id')
     if user_attribute:
         logger.info("A02 user attribute %s" % user_attribute)
         user = self.user_authenticate(*args, **kwargs)
         logger.info("A03 User authentication %s" % user)
     else:
         user = self.profile_authenticate(*args, **kwargs)
         logger.info("A04 Profile authentication %s" % user)
     return user
Example #8
0
    def setUp(self):
        from django_facebook.test_utils.mocks import MockFacebookAPI, MockFacebookAuthorization, RequestMock
        import sys
        import io
        self.prints = sys.stdout = io.StringIO()

        from open_facebook import api
        import open_facebook

        self.originalAPI = open_facebook.OpenFacebook
        self.originalAuthorization = open_facebook.FacebookAuthorization

        open_facebook.OpenFacebook = api.OpenFacebook = MockFacebookAPI
        open_facebook.FacebookAuthorization = api.FacebookAuthorization = MockFacebookAuthorization

        rf = RequestMock()
        self.request = rf.get('/')
        self.client = Client()

        # time to setup the test user
        user_model = get_user_model()
        user_dict = dict(
            username='******',
            is_staff=False,
            is_active=True,
            email="*****@*****.**",
        )
        test_ip = '127.0.0.1'
        # hack to make fashiolista tests run ok
        if is_user_attribute('registration_ip'):
            user_dict['registration_ip'] = test_ip
            user_dict['last_login_ip'] = test_ip
        user_model.objects.create(**user_dict)

        from django.conf import settings
        if getattr(settings, 'MODE', None) == 'userena':
            from django.core.management import call_command
            call_command('check_permissions', output=False)