def testFetchByUsername_NotFound(self):
     user1 = UserData(username='******', password='******')
     self.user_datastore.save(user1)
     user2 = UserData(username='******', password='******')
     self.user_datastore.save(user2)
     userfound1 = self.user_datastore.fetchByUsername('foo')
     self.assertTrue(userfound1 == None, 'Found user' + str(userfound1))
 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 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))
 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 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))
 def testFetchByUsername(self):
     user1 = UserData(username='******', password='******')
     self.user_datastore.save(user1)
     user2 = UserData(username='******', password='******')
     self.user_datastore.save(user2)
     userfound1 = self.user_datastore.fetchByUsername('cdoremus1')
     self.assertEquals(userfound1.password, user1.password,
                       'Found user' + str(userfound1))
     self.assertTrue(userfound1.user_id == 1,
                     "User id is not 1: " + str(userfound1.user_id))
Beispiel #7
0
 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)
 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)
 def testFetchAll(self):
     user1 = UserData(username='******', password='******')
     new_user1 = self.user_datastore.save(user1)
     user2 = UserData(username='******', password='******')
     new_user2 = self.user_datastore.save(user2)
     users = self.user_datastore.fetchAll()
     self.assertTrue(users.count() == 2,
                     "User count: " + str(users.count()))
     self.assertTrue(new_user1.user_id == 1,
                     'New user_id for user1: ' + str(new_user1.user_id))
     self.assertTrue(new_user2.user_id == 2,
                     'New user_id for user2: ' + str(new_user2.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
 def testUserExists_False(self):
     username = '******'
     testVal ='foo'
     #add a record to the data store
     userData = UserData(username=username, password='******')
     self.user_datastore.save(userData)
     self.assertFalse(self.validation.user_exists(testVal), "User " + testVal + " exists. User added: " + userData.username)
Beispiel #12
0
 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
 def test_validate_login_username_notfound(self):
     username = '******'
     password = '******'
     user = UserData(username=username,password=password)
     self.user_datastore.save(user)
     
     msgs, isValid = self.validation_login.validate(username + 'foo', password)
     self.assertFalse(isValid)
     self.assertFalse(len(msgs) == 0)
 def test_validate_login_invalid_password(self):
     username = '******'
     password = '******'
     hashed_password = self.crypt.crypt_password(username, password)
     user = UserData(username=username, password=hashed_password)
     self.user_datastore.save(user)
     
     msgs, isValid = self.validation_login.validate(username, password + 'bar')
     self.assertFalse(isValid)
     self.assertFalse(len(msgs) == 0)
Beispiel #15
0
 def register(self, username,password,verify, email=None):
     validation_msgs, isValid = self.signup_validation.validate(username=username, password=password, verify=verify, email=email)
     if not isValid:
         raise UserRegistrationError(validation_msgs)
     else:
         crypt_password = self._crypt_password(username, password)
         user = UserData(username=username,password=crypt_password,email=email)
         saved_user = self.storage.save(user)
         user_id = saved_user.user_id
     return self.crypt.make_cookie(user_id)
 def testValidate_UserExists(self):
     '''
     Test validate() with a user that already exists
     '''
     username = '******'
     password = '******'
     
     #add a record to the data store
     userData = UserData(username=username, password=password)
     self.user_datastore.save(userData)
     #verify in database
     user = self.user_datastore.fetchByUsername(username)
     print user.username
     self.assertTrue(self.validation.validate(username=username, password=password, verify=password, email=None), "User " + username + " exists")
Beispiel #17
0
 def testRegister_failed(self):
     username = '******'
     password = '******'
     verify = password
     user = UserData(username=username, password=password)
     self.storage.save(user)
     try:
         self.service.register(username=username,
                               password=password,
                               verify=verify)
         self.fail(
             'Should not get here because UserRegistrationError should be raised due to the fact that user already exists'
         )
     except UserRegistrationError as error:
         self.assertEquals(error.validation_messages['user_exists_error'],
                           'That user already exists.')
 def testUserExists_True(self):
     username = '******'
     #add a record to the data store
     userData = UserData(username=username, password='******')
     self.user_datastore.save(userData)
     self.assertTrue(self.validation.user_exists(username), "User " + username + " does not exist")