def uninstrument_app(app: fastapi.FastAPI):
     app.user_middleware = [
         x for x in app.user_middleware
         if x.cls is not OpenTelemetryMiddleware
     ]
     app.middleware_stack = app.build_middleware_stack()
     app._is_instrumented_by_opentelemetry = False
示例#2
0
def mock_auth(application: FastAPI) -> FastAPI:
    """Mock auth dependency and token middleware."""
    application.dependency_overrides[bearer_auth] = bearer_auth_mock

    application.user_middleware = []
    application.middleware_stack = application.build_middleware_stack()

    return application