code: def test_auth_required_at_blueprint_before_request(app, client):
      bp = APIBlueprint("auth", __name__)
      no_auth_bp = APIBlueprint("no-auth", __name__)
  
      auth = HTTPTokenAuth()
  
      @bp.before_request
      @bp.auth_required(auth)
      def before():
          pass
  
      @bp.get("/foo")
      def foo():
          pass
  
      @bp.get("/bar")
      def bar():
          pass
  
      @bp.route("/baz")
      class Baz(MethodView):
          def get(self):
              pass
  
          def post(self):
              pass
  
      @no_auth_bp.get("/eggs")
      def eggs():
          return "no auth"
  
      app.register_blueprint(bp)
      app.register_blueprint(no_auth_bp)
  
      rv = client.get("/foo")
      assert rv.status_code == 401
      rv = client.get("/bar")
      assert rv.status_code == 401
      rv = client.get("/baz")
      assert rv.status_code == 401
      rv = client.get("/eggs")
      assert rv.status_code == 200
  
      rv = client.get("/openapi.json")
      assert rv.status_code == 200
      validate_spec(rv.json)
  
      assert "auth" in app._auth_blueprints
      assert "no-auth" not in app._auth_blueprints
  
      assert "BearerAuth" in rv.json["components"]["securitySchemes"]
      assert rv.json["components"]["securitySchemes"]["BearerAuth"] == {
          "scheme": "bearer",
          "type": "http",
      }
  
      assert (
          "BearerAuth" in rv.json["paths"]["/foo"]["get"]["security"][0]
      )
      assert (
          "BearerAuth" in rv.json["paths"]["/bar"]["get"]["security"][0]
      )
      assert (
          "BearerAuth" in rv.json["paths"]["/baz"]["get"]["security"][0]
      )
      assert (
          "BearerAuth"
          in rv.json["paths"]["/baz"]["post"]["security"][0]
      )
      assert "security" not in rv.json["paths"]["/eggs"]["get"]
  
file_path: apiflask/tests/test_decorator_auth_required.py
imports: from flask.views import MethodView
  from openapi_spec_validator import validate_spec
  from apiflask import APIBlueprint
  from apiflask.security import HTTPBasicAuth
  from apiflask.security import HTTPTokenAuth
label_desc: Use image node_id 3 for calling a global function with example usage: test_auth_required_at_blueprint_before_request(app, client) and returns: str