mirror of
https://github.com/Rarebuffalo/securelens-backend.git
synced 2026-06-19 07:00:30 +00:00
spoof User-Agent for Agent Router calls to bypass unauthorized client detection
This commit is contained in:
@@ -94,3 +94,21 @@ async def test_analyze_file_passes_api_base():
|
||||
mock_call_ai_json.assert_called_once()
|
||||
called_kwargs = mock_call_ai_json.call_args[1]
|
||||
assert called_kwargs["api_base"] == "https://agentrouter.org/v1"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_call_ai_injects_agentrouter_headers():
|
||||
with patch("litellm.acompletion", new_callable=AsyncMock) as mock_acompletion:
|
||||
mock_acompletion.return_value.choices = [
|
||||
AsyncMock(message=AsyncMock(content="Mock response"))
|
||||
]
|
||||
|
||||
await call_ai(
|
||||
prompt="Hello",
|
||||
api_key="mock_key",
|
||||
model="openai/deepseek-chat",
|
||||
api_base="https://agentrouter.org/v1"
|
||||
)
|
||||
|
||||
mock_acompletion.assert_called_once()
|
||||
called_kwargs = mock_acompletion.call_args[1]
|
||||
assert called_kwargs["extra_headers"] == {"User-Agent": "claude-code/0.2.9"}
|
||||
|
||||
Reference in New Issue
Block a user