The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(responses): drive streamed-id regression via production ResponseCompletedEvent shape
mateo-berri95f8373e3cf2
diff --git a/tests/test_litellm/test_responses_id_security.py b/tests/test_litellm/test_responses_id_security.pyindex f1cb9eccff0..763ee4dac00 100644--- a/tests/test_litellm/test_responses_id_security.py+++ b/tests/test_litellm/test_responses_id_security.py@@ -13,8 +13,11 @@ from litellm.proxy.hooks.responses_id_security import (ResponsesIDSecurity,_is_responses_api_create_route,)-from litellm.types.llms.base import BaseLiteLLMOpenAIResponseObject-from litellm.types.llms.openai import ResponsesAPIResponse+from litellm.types.llms.openai import (+ ResponseCompletedEvent,+ ResponsesAPIResponse,+ ResponsesAPIStreamEvents,+)from litellm.types.utils import SpecialEnums@@ -612,18 +615,36 @@ class TestIsResponsesApiCreateRoute:class TestAsyncPostCallStreamingIteratorHook:"""Regression test for LIT-6167: streamed responses on /openai/v1/responses and/responses must have their ids security-encrypted, not just on the exact- /v1/responses path. Uses real encryption so the id must round-trip back to the- raw provider id plus the caller's user/team, which is the access-control wrapper- the aliases were leaking without."""+ /v1/responses path. A streamed create emits ResponseCompletedEvent, whose+ client-visible id lives on event.response.id, so the test drives that production+ event shape (not a top-level id) and uses real encryption, asserting the id+ round-trips back to the raw provider id plus the caller's user/team, which is the+ access-control wrapper the aliases were leaking without."""@staticmethodasync def _agen(chunks):for chunk in chunks:yield chunk+ @staticmethod+ def _completed_event(response_id):+ return ResponseCompletedEvent(+ type=ResponsesAPIStreamEvents.RESPONSE_COMPLETED,+ response=ResponsesAPIResponse(+ id=response_id,+ created_at=0,+ model="gpt-5.1",+ object="response",+ output=[],+ parallel_tool_calls=False,+ tool_choice="auto",+ tools=[],+ ),+ )+async def _drain_streamed_id(self, responses_id_security, route, monkeypatch):monkeypatch.setenv("LITELLM_SALT_KEY", "sk-test-salt-key-abcdefghij")- chunk = BaseLiteLLMOpenAIResponseObject(id="resp_rawprovider123")+ event = self._completed_event("resp_rawprovider123")mock_auth = MagicMock()mock_auth.user_id = "user-a"@@ -634,11 +655,11 @@ class TestAsyncPostCallStreamingIteratorHook:outasync for out in responses_id_security.async_post_call_streaming_iterator_hook(user_api_key_dict=mock_auth,- response=self._agen([chunk]),+ response=self._agen([event]),request_data={},)]- return collected[0].id+ return collected[0].response.id@pytest.mark.asyncio@pytest.mark.parametrize(