def get_auth_router(self, backend: BaseAuthentication) -> APIRouter: """ Return an auth router for a given authentication backend. :param backend: The authentication backend instance. """ return get_auth_router(backend, self.db, self.authenticator)
async def test_app_client(mock_user_db, mock_authentication, get_test_client) -> httpx.AsyncClient: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db) mock_auth_router = get_auth_router(mock_authentication, mock_user_db, authenticator) mock_bis_auth_router = get_auth_router(mock_authentication_bis, mock_user_db, authenticator) app = FastAPI() app.include_router(mock_auth_router, prefix="/mock") app.include_router(mock_bis_auth_router, prefix="/mock-bis") return await get_test_client(app)
async def test_app_client( mock_user_db, mock_authentication, get_test_client) -> AsyncGenerator[httpx.AsyncClient, None]: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db) mock_auth_router = get_auth_router(mock_authentication, mock_user_db, authenticator) mock_bis_auth_router = get_auth_router(mock_authentication_bis, mock_user_db, authenticator) app = FastAPI() app.include_router(mock_auth_router, prefix="/mock") app.include_router(mock_bis_auth_router, prefix="/mock-bis") async for client in get_test_client(app): yield client
def _app_factory(requires_verification: bool) -> FastAPI: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db) mock_auth_router = get_auth_router( mock_authentication, mock_user_db, authenticator, requires_verification=requires_verification, ) mock_bis_auth_router = get_auth_router( mock_authentication_bis, mock_user_db, authenticator, requires_verification=requires_verification, ) app = FastAPI() app.include_router(mock_auth_router, prefix="/mock") app.include_router(mock_bis_auth_router, prefix="/mock-bis") return app
def get_auth_router(self, backend: BaseAuthentication, requires_verification: bool = False) -> APIRouter: """ Return an auth router for a given authentication backend. :param backend: The authentication backend instance. """ return get_auth_router( backend, self.db, self.authenticator, requires_verification, )
def get_auth_router(self, backend: AuthenticationBackend, requires_verification: bool = False) -> APIRouter: """ Return an auth router for a given authentication backend. :param backend: The authentication backend instance. :param requires_verification: Whether the authentication require the user to be verified or not. """ return get_auth_router( backend, self.get_user_manager, self.authenticator, requires_verification, )