File tree Expand file tree Collapse file tree
lib/crewai-tools/src/lib/crewai-tools/tests/tools Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,3 +120,26 @@ class FakeResponse:
120120
121121 resultado = tool .run (pregunta = "cualquier pregunta" )
122122 assert "límite" in resultado .lower ()
123+
124+
125+ def test_redirect_is_rejected_without_reading_body (monkeypatch ):
126+ """CodeRabbit: ante un 3xx, la tool debe cortar antes de llamar
127+ .json() (defensa contra que alguien quite ese return a futuro y
128+ la key termine yendo a un host fuera de lex-mex.xyz)."""
129+ tool = LexMexTool (api_key = "lmx_live_test" )
130+
131+ class FakeRedirectResponse :
132+ status_code = 302
133+
134+ def json (self ):
135+ raise AssertionError (
136+ ".json() no debe llamarse ante una respuesta de redirect"
137+ )
138+
139+ monkeypatch .setattr (
140+ "crewai_tools.tools.lexmex_tool.lexmex_tool.requests.post" ,
141+ lambda * a , ** kw : FakeRedirectResponse (),
142+ )
143+
144+ resultado = tool .run (pregunta = "cualquier pregunta" )
145+ assert "redirección" in resultado .lower ()
You can’t perform that action at this time.
0 commit comments