-
-
Notifications
You must be signed in to change notification settings - Fork 11k
test(e2e): cover credential-backed /v1/messages request #33863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| """Live e2e: stored credentials resolve into a deployment serving /v1/messages.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
|
|
||
| import pytest | ||
|
|
||
| from e2e_config import unique_marker | ||
| from e2e_http import require_successful_call | ||
| from endpoints_client import EndpointsClient, MessagesResult | ||
| from lifecycle import ResourceManager | ||
| from models import CredentialCreateBody, LiteLLMParamsBody | ||
|
|
||
| pytestmark = pytest.mark.e2e | ||
|
|
||
|
|
||
| class TestCredentialBackedMessages: | ||
| @pytest.mark.covers("mgmt.credential.new.serves_request") | ||
| def test_credential_backed_messages(self, endpoints_client: EndpointsClient, resources: ResourceManager) -> None: | ||
| marker = unique_marker() | ||
| credential_name = f"e2e-cred-{marker}" | ||
| model = f"e2e-cred-messages-{marker}" | ||
| anthropic_api_key = os.getenv("ANTHROPIC_API_KEY") | ||
| assert anthropic_api_key, "ANTHROPIC_API_KEY must be set for this live e2e test" | ||
|
|
||
| endpoints_client.proxy.create_credential( | ||
| CredentialCreateBody( | ||
| credential_name=credential_name, | ||
| credential_values={"api_key": anthropic_api_key}, | ||
| ) | ||
| ) | ||
| resources.defer(lambda: endpoints_client.proxy.delete_credential(credential_name)) | ||
|
|
||
| model_id = endpoints_client.create_model( | ||
| model, | ||
| LiteLLMParamsBody( | ||
| model="anthropic/claude-haiku-4-5", | ||
| litellm_credential_name=credential_name, | ||
| ), | ||
| ) | ||
| resources.defer(lambda: endpoints_client.delete_model(model_id)) | ||
|
|
||
| key = resources.key() | ||
| result = endpoints_client.messages(key, model, "reply with one word") | ||
| require_successful_call(result) | ||
| parsed = MessagesResult.model_validate_json(result.body) | ||
| assert parsed.role == "assistant", f"unexpected role: {result.body[:300]}" | ||
| assert parsed.text.strip(), f"/v1/messages returned no text: {result.body[:300]}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -492,6 +492,7 @@ class LiteLLMParamsBody(BaseModel): | |
|
|
||
| model: str | ||
| api_key: str | None = None | ||
| litellm_credential_name: str | None = None | ||
| api_base: str | None = None | ||
| api_version: str | None = None | ||
| realtime_protocol: str | None = None | ||
|
|
@@ -556,6 +557,16 @@ class ModelDeleteBody(BaseModel): | |
| id: str | ||
|
|
||
|
|
||
| class CredentialCreateBody(BaseModel): | ||
| credential_name: str | ||
| credential_values: dict[str, str] | ||
| credential_info: dict[str, str] = {} | ||
|
Comment on lines
+560
to
+563
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Both fields are typed as |
||
|
|
||
|
|
||
| class CredentialCreateResponse(BaseModel): | ||
| success: bool | ||
|
|
||
|
|
||
| # ---------- key / team / user / organization management ---------- | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sourcefield references production code, not the test fileEvery other entry in this file sets
sourceto a test-harness or test file (e.g.key_management_endpoints.py:4252,workflow_management_endpoints.py). This new entry setssource: "credential_endpoints/endpoints.py:42", which is the production endpoint. The test that covers this entry lives inllm_translation/test_credential_messages_e2e.py; pointing there would keep the registry consistent and make it easy to jump from the registry to the actual test.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!