mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-05 02:41:56 +00:00
test: cover too-many-redirects path in async_safe_request
This commit is contained in:
parent
7e5e5d424f
commit
d9292e129b
1 changed files with 14 additions and 0 deletions
|
|
@ -628,6 +628,20 @@ class TestAsyncSafeRequest:
|
|||
with pytest.raises(SSRFError):
|
||||
await async_safe_request(FakeClient(), "POST", "http://example.com/start")
|
||||
|
||||
async def test_too_many_redirects_raises(self, monkeypatch):
|
||||
def fake(host, port, *a, **kw):
|
||||
return [(socket.AF_INET, socket.SOCK_STREAM, 6, "", ("93.184.216.34", port))]
|
||||
|
||||
monkeypatch.setattr(url_utils.socket, "getaddrinfo", fake)
|
||||
monkeypatch.setattr(litellm, "user_url_validation", True)
|
||||
|
||||
class FakeClient:
|
||||
async def request(self, method, url, headers=None, follow_redirects=False, **kw):
|
||||
return _FakeResponse(302, location="http://example.com/next")
|
||||
|
||||
with pytest.raises(SSRFError, match="Too many redirects"):
|
||||
await async_safe_request(FakeClient(), "POST", "http://example.com/start")
|
||||
|
||||
async def test_master_switch_disabled_bypasses_validation(self, monkeypatch):
|
||||
monkeypatch.setattr(litellm, "user_url_validation", False)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue