def test_load_user(self): """Method to test the registered user details""" with app.test_request_context(): auth_manager = auth.AuthManager() auth_manager.init_login(app) user = create_user(email='*****@*****.**', password='******') self.assertEqual(user, db.session.query(User).get(user.id))
def test_is_accessible(self): """Method to test if user is accessible(authenticated)""" with app.test_request_context(): auth_manager = auth.AuthManager() auth_manager.init_login(app) user = create_user(email='*****@*****.**', password='******') login_user(user) logout_user() self.assertEqual(auth_manager.is_accessible(), False)
def test_verified_user(self): """Method to test if user is verified""" with app.test_request_context(): auth_manager = auth.AuthManager() auth_manager.init_login(app) user = create_user(email='*****@*****.**', password='******') user.is_verified = False login_user(user) self.assertEqual(auth_manager.is_verified_user(), False)
def test_check_auth_admin(self): """Method to test proper authentication & admin rights for a user""" with app.test_request_context(): auth_manager = auth.AuthManager() auth_manager.init_login(app) user = create_user(email='*****@*****.**', password='******') user.is_admin = True status = auth_manager.check_auth_admin('*****@*****.**', 'password') self.assertEqual(True, status) user = create_user(email='*****@*****.**', password='******') user.is_admin = False status = auth_manager.check_auth_admin('*****@*****.**', 'password') self.assertEqual(False, status)