예제 #1
0
파일: test.py 프로젝트: frach/homeberry
 def test_user_password(self):
     test_user = User(username='******', password='******')
     self.assertTrue(test_user.check_password('test_pass'), "Wrong password hash generated after creting user.")
     self.assertIn('pbkdf2:sha256:1000$', test_user.password)
     self.assertEqual(len(test_user.password), 92, "Wrong hash length.")
     test_user.set_password('another_password')
     self.assertIn('pbkdf2:sha256:1000$', test_user.password)
     self.assertEqual(len(test_user.password), 92, "Wrong hash length.")
     self.assertTrue(test_user.check_password('another_password'), "Wrong password hash generated after setting password.")
예제 #2
0
def sign_in():
    """
       parameters:
         - name: Login
           required: username and password
           description: Login route to authenticate existing users
       responses:
         400: Login failed
           description: Bad Username/Password
         200:
           description: Login Success
           result schema:
             User object
       """
    requested_user = request.get_json()
    user = User(username=requested_user['username'],
                password=requested_user['password'],
                accessToken=requested_user['accessToken'],
                tokenType=requested_user['tokenType'],
                expiresIn=requested_user['expiresIn'],
                refreshToken=requested_user['refreshToken'],
                name='',
                role='')
    if user.check_password(requested_user['pwAttempted']):
        return user.toJSON()
    else:
        abort(400)
예제 #3
0
    def test_user_check_password(self):
        user = User('test_user')
        user.set_password('password')

        self.assertTrue(user.check_password('password'))
예제 #4
0
 def test_password_hashing(self):
     u = User(username='******')
     u.set_password('cat')
     self.assertFalse(u.check_password('dog'))
     self.assertTrue(u.check_password('cat'))