def get_users_router( self, requires_verification: bool = False, ) -> APIRouter: """ Return a router with routes to manage users. :param requires_verification: Whether the endpoints require the users to be verified or not. """ return get_users_router( self.get_user_manager, self._user_model, self._user_update_model, self._user_db_model, self.authenticator, requires_verification, )
def _app_factory(requires_verification: bool) -> FastAPI: mock_authentication_bis = get_mock_authentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], get_user_manager) user_router = get_users_router( get_user_manager, User, UserUpdate, UserDB, authenticator, requires_verification=requires_verification, ) app = FastAPI() app.include_router(user_router) return app
def get_users_router( self, after_update: Optional[Callable[[models.UD, Dict[str, Any], Request], None]] = None, ) -> APIRouter: """ Return a router with routes to manage users. :param after_update: Optional function called after a successful user update. """ return get_users_router( self.db, self._user_model, self._user_update_model, self._user_db_model, self.authenticator, after_update, )
async def test_app_client(mock_user_db, mock_authentication, after_update, get_test_client) -> httpx.AsyncClient: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db) user_router = get_users_router( mock_user_db, User, UserUpdate, UserDB, authenticator, after_update, ) app = FastAPI() app.include_router(user_router) return await get_test_client(app)
def _app_factory(requires_verification: bool) -> FastAPI: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db) user_router = get_users_router( mock_user_db, User, UserUpdate, UserDB, authenticator, after_update, requires_verification=requires_verification, validate_password=validate_password, ) app = FastAPI() app.include_router(user_router) return app
async def test_app_client( mock_user_db, mock_authentication, after_update, get_test_client) -> AsyncGenerator[httpx.AsyncClient, None]: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db) user_router = get_users_router( mock_user_db, User, UserUpdate, UserDB, authenticator, after_update, ) app = FastAPI() app.include_router(user_router) async for client in get_test_client(app): yield client
def get_users_router( self, after_update: Optional[Callable[[models.UD, Dict[str, Any], Request], None]] = None, requires_verification: bool = False, ) -> APIRouter: """ Return a router with routes to manage users. :param after_update: Optional function called after a successful user update. :param requires_verification: Whether the endpoints require the users to be verified or not. """ return get_users_router( self.db, self._user_model, self._user_update_model, self._user_db_model, self.authenticator, after_update, requires_verification, self.validate_password, )