Пример #1
0
 def test_validate_user_memcache(self):
     '''Validation of a user should store answer in memcache'''
     user_id = "memcache_validate_user "
     secret = "memcahce_validate_secret"
     SFUser.create(user_id, "fb_token", secret)
     self.assertNone(memcache.get(SECRET_KEY % (user_id, secret)))
     self.assertTrue(SFUser.validate_user(user_id, secret))
     self.assertEqual(memcache.get(SECRET_KEY % (user_id, secret)), 1)
Пример #2
0
 def validate_user_credentials(self, *args, **kw):
     user_id = self.request.get('user_id')
     secret = self.request.get('secret')
     if SFUser.validate_user(user_id, secret):
         handler_method(self, *args, **kw)
     else:
         self.bail_with_message(None, {'status': False, 'message': 'Authentication failed'}, 403)
         return
Пример #3
0
 def test_validate_user(self):
     '''User validation'''
     self.assertTrue(SFUser.validate_user(self.user_id, self.secret))
     self.assertTrue(SFUser.validate_user(self.user_id, self.secret))
     self.assertFalse(SFUser.validate_user(self.user_id, "a" + self.secret))