Example #1
0
 def test_incorrect_password(self, is_pw_correct, lookup_user_id):
     is_pw_correct.return_value = False
     lookup_user_id.return_value = "1234"
     self.mock_cursor.fetchone.return_value = ["1234", "hashed", "Alice van Wonderland", "[email protected]", 0]
     user = users.get_user_by_email_and_password(self.mock_session, "user", "password")
     self.assertFalse(user)
     is_pw_correct.assert_called_once_with("password", "hashed")
Example #2
0
 def test_correct_password(self, is_pw_correct, lookup_user_id):
     is_pw_correct.return_value = True
     lookup_user_id.return_value = "1234"
     self.mock_cursor.fetchone.return_value = ["1234", "hashed", "Alice van Wonderland", "[email protected]", 0]
     user = users.get_user_by_email_and_password(self.mock_session, "[email protected]", "password")
     self.assertTrue(user)
     self.assertEquals("[email protected]", user["email"])
     self.mock_session.execute.assert_called_once_with(ANY, {'email': "[email protected]"})
     is_pw_correct.assert_called_once_with("password", "hashed")
Example #3
0
 def post(self):
     username = self.request_data["username"]
     password = self.request_data["password"]
     user = users.get_user_by_email_and_password(self.db_session(), username, password)
     if user:
         _log.debug("User %s provided correct password (%s) (%s)", username, user["email"], str(user))
         self.do_login(user, True)
     else:
         _log.debug("User %s provided incorrect password", username)
         self.send_error(httplib.FORBIDDEN, reason="Incorrect username or password")