Esempio n. 1
0
 def test_valid_real_data(self):
     data = {
         "expires_at": 1403429380,
         "scopes": [
           "public_profile",
           "basic_info",
           "publish_checkins",
           "status_update",
           "photo_upload",
           "video_upload",
           "email",
           "create_note",
           "share_item",
           "publish_stream",
           "publish_actions",
           "user_friends"
         ],
         "app_id": 423260947733647,
         "application": "'Social WiFi'",
         "issued_at": 1398245380,
         "is_valid": True,
         "user_id": 1000066666,
     }
     response = forms.parse_facebook_response({'data': data}, '123')
     self.assertEqual(response.is_valid, True)
Esempio n. 2
0
 def test_valid_real_data(self):
     data = {
         "expires_at": 1403429380,
         "scopes": [
           "public_profile",
           "basic_info",
           "publish_checkins",
           "status_update",
           "photo_upload",
           "video_upload",
           "email",
           "create_note",
           "share_item",
           "publish_stream",
           "publish_actions",
           "user_friends"
         ],
         "app_id": 423260947733647,
         "application": "'Social WiFi'",
         "issued_at": 1398245380,
         "is_valid": True,
         "user_id": 1000066666,
     }
     response = forms.parse_facebook_response({'data': data}, '123')
     self.assertEqual(response.is_valid, True)
Esempio n. 3
0
 def test_test_strange_types(self):
     data = {
         'expires_at': {},
         'is_valid': [],
         'scopes[]': {},
         'user_id': 1.1,
     }
     response = forms.parse_facebook_response({'data': data}, '123')
     self.assertEqual(response.is_valid, False)
Esempio n. 4
0
 def test_valid_response(self):
     data = {
         'expires_at': 12341234,
         'is_valid': True,
         'scopes[]': 'foo,bar',
         'user_id': '123',
     }
     response = forms.parse_facebook_response({'data': data}, '123')
     self.assertEqual(response.is_valid, True)
Esempio n. 5
0
 def test_test_strange_types(self):
     data = {
         'expires_at': {},
         'is_valid': [],
         'scopes[]': {},
         'user_id': 1.1,
     }
     response = forms.parse_facebook_response({'data': data}, '123')
     self.assertEqual(response.is_valid, False)
Esempio n. 6
0
 def test_valid_response(self):
     data = {
         'expires_at': 12341234,
         'is_valid': True,
         'scopes[]': 'foo,bar',
         'user_id': '123',
     }
     response = forms.parse_facebook_response({'data': data}, '123')
     self.assertEqual(response.is_valid, True)
 def debug_token(self, token):
     graph = utils.get_application_graph()
     response = graph.get('/debug_token', input_token=token)
     parsed_response = forms.parse_facebook_response(response, token)
     if parsed_response.is_valid:
         data = parsed_response.parsed_data
         self._update_scope(data)
         return self.get_token_info(data)
     else:
         raise TokenDebugException('Invalid Facebook response.',
                                   {'errors': parsed_response.errors})
Esempio n. 8
0
 def debug_token(self, token):
     graph = utils.get_application_graph()
     response = graph.get('v2.1/debug_token', input_token=token)
     parsed_response = forms.parse_facebook_response(response, token)
     if parsed_response.is_valid:
         data = parsed_response.parsed_data
         self._update_scope(data)
         return self.get_token_info(data)
     else:
         raise ValueError('Invalid Facebook response.',
                          {'errors': parsed_response.errors})
Esempio n. 9
0
 def test_if_original_dict_is_not_modified(self):
     data = {}
     input_json = {'data': data}
     forms.parse_facebook_response(input_json, '123')
     self.assertEqual({}, data)
     self.assertEqual({'data': {}}, input_json)
Esempio n. 10
0
 def test_with_empty_data(self):
     response = forms.parse_facebook_response({'data': {}}, '123')
     self.assertEqual(response.is_valid, False)
Esempio n. 11
0
 def test_without_data(self):
     response = forms.parse_facebook_response({}, '123')
     self.assertEqual(response.is_valid, False)
Esempio n. 12
0
 def test_data_as_int(self):
     response = forms.parse_facebook_response({'data': []}, '123')
     self.assertEqual(response.is_valid, False)
Esempio n. 13
0
 def test_if_original_dict_is_not_modified(self):
     data = {}
     input_json = {'data': data}
     forms.parse_facebook_response(input_json, '123')
     self.assertEqual({}, data)
     self.assertEqual({'data': {}}, input_json)
Esempio n. 14
0
 def test_with_empty_data(self):
     response = forms.parse_facebook_response({'data': {}}, '123')
     self.assertEqual(response.is_valid, False)
Esempio n. 15
0
 def test_without_data(self):
     response = forms.parse_facebook_response({}, '123')
     self.assertEqual(response.is_valid, False)
Esempio n. 16
0
 def test_data_as_int(self):
     response = forms.parse_facebook_response({'data': []}, '123')
     self.assertEqual(response.is_valid, False)
Esempio n. 17
0
 def test_bool_response(self):
     response = forms.parse_facebook_response(False, '123')
     self.assertEqual(response.is_valid, False)
Esempio n. 18
0
 def test_bool_response(self):
     response = forms.parse_facebook_response(False, '123')
     self.assertEqual(response.is_valid, False)