def testLogin(self):
     username = '******'
     password = '******'
     hashed_password = self.crypt.crypt_password(username, password)
     user = UserData(username=username, password=hashed_password)
     self.storage.save(user)
     user_id = user.key().id()
     cookie = self.crypt.make_cookie(user_id)
     new_cookie = self.service.login(username, password, cookie)
     self.assertFalse(new_cookie == None)
     self.assertEquals(user.key().id(), 1)
Пример #2
0
 def testSave(self):
     user = UserData(username='******', password='******')
     new_user = self.user_datastore.save(user)
     user_id = user.key().id()
     actual = self.user_datastore.fetch(user_id)
     self.assertEquals(user.username, actual.username, "Found user: " + str(actual.username))
     self.assertTrue(new_user.user_id ==1, 'New user_id: ' + str(new_user.user_id))
Пример #3
0
 def testFetch(self):
     user = UserData(username='******', password='******')
     user.put()
     user_id = user.key().id()
     actual = self.user_datastore.fetch(user_id)
     self.assertEquals(user.username, actual.username, "Found user: "******"Found user_id: " + str(actual.user_id))
 def testLogin_Failed(self):
     username = '******'
     password = '******'
     hashed_password = self.crypt.crypt_password(username, password)
     user = UserData(username=username, password=hashed_password)
     self.storage.save(user)
     user_id = user.key().id()
     cookie = self.crypt.make_cookie(user_id)
     try: 
         self.service.login(username + 'foo', password, cookie)
         self.fail('Should not get here because LoginError should be raised due to bad usernames')
     except LoginError as error:
         self.assertEquals(error.validation_messages['login_error'], 'Invalid login')
         print error