From 0f7e1acfc6fec4b8d0c7775f9abd046159191d8a Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 25 Oct 2025 16:14:19 -0700 Subject: [PATCH] test: update tests --- .../index.html} | 0 .../proxy/_experimental/out/guardrails.html | 1 - .../out/{logs.html => logs/index.html} | 0 .../{model-hub.html => model-hub/index.html} | 0 .../index.html} | 0 .../index.html} | 0 .../proxy/_experimental/out/onboarding.html | 1 - .../index.html} | 0 .../out/{teams.html => teams/index.html} | 0 .../{test-key.html => test-key/index.html} | 0 .../out/{usage.html => usage/index.html} | 0 .../out/{users.html => users/index.html} | 0 .../index.html} | 0 .../test_llm_pass_through_endpoints.py | 85 ++++++++++++++----- 14 files changed, 64 insertions(+), 23 deletions(-) rename litellm/proxy/_experimental/out/{api-reference.html => api-reference/index.html} (100%) delete mode 100644 litellm/proxy/_experimental/out/guardrails.html rename litellm/proxy/_experimental/out/{logs.html => logs/index.html} (100%) rename litellm/proxy/_experimental/out/{model-hub.html => model-hub/index.html} (100%) rename litellm/proxy/_experimental/out/{model_hub_table.html => model_hub_table/index.html} (100%) rename litellm/proxy/_experimental/out/{models-and-endpoints.html => models-and-endpoints/index.html} (100%) delete mode 100644 litellm/proxy/_experimental/out/onboarding.html rename litellm/proxy/_experimental/out/{organizations.html => organizations/index.html} (100%) rename litellm/proxy/_experimental/out/{teams.html => teams/index.html} (100%) rename litellm/proxy/_experimental/out/{test-key.html => test-key/index.html} (100%) rename litellm/proxy/_experimental/out/{usage.html => usage/index.html} (100%) rename litellm/proxy/_experimental/out/{users.html => users/index.html} (100%) rename litellm/proxy/_experimental/out/{virtual-keys.html => virtual-keys/index.html} (100%) diff --git a/litellm/proxy/_experimental/out/api-reference.html b/litellm/proxy/_experimental/out/api-reference/index.html similarity index 100% rename from litellm/proxy/_experimental/out/api-reference.html rename to litellm/proxy/_experimental/out/api-reference/index.html diff --git a/litellm/proxy/_experimental/out/guardrails.html b/litellm/proxy/_experimental/out/guardrails.html deleted file mode 100644 index 725f464406..0000000000 --- a/litellm/proxy/_experimental/out/guardrails.html +++ /dev/null @@ -1 +0,0 @@ -LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/logs.html b/litellm/proxy/_experimental/out/logs/index.html similarity index 100% rename from litellm/proxy/_experimental/out/logs.html rename to litellm/proxy/_experimental/out/logs/index.html diff --git a/litellm/proxy/_experimental/out/model-hub.html b/litellm/proxy/_experimental/out/model-hub/index.html similarity index 100% rename from litellm/proxy/_experimental/out/model-hub.html rename to litellm/proxy/_experimental/out/model-hub/index.html diff --git a/litellm/proxy/_experimental/out/model_hub_table.html b/litellm/proxy/_experimental/out/model_hub_table/index.html similarity index 100% rename from litellm/proxy/_experimental/out/model_hub_table.html rename to litellm/proxy/_experimental/out/model_hub_table/index.html diff --git a/litellm/proxy/_experimental/out/models-and-endpoints.html b/litellm/proxy/_experimental/out/models-and-endpoints/index.html similarity index 100% rename from litellm/proxy/_experimental/out/models-and-endpoints.html rename to litellm/proxy/_experimental/out/models-and-endpoints/index.html diff --git a/litellm/proxy/_experimental/out/onboarding.html b/litellm/proxy/_experimental/out/onboarding.html deleted file mode 100644 index 40585b9758..0000000000 --- a/litellm/proxy/_experimental/out/onboarding.html +++ /dev/null @@ -1 +0,0 @@ -LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/organizations.html b/litellm/proxy/_experimental/out/organizations/index.html similarity index 100% rename from litellm/proxy/_experimental/out/organizations.html rename to litellm/proxy/_experimental/out/organizations/index.html diff --git a/litellm/proxy/_experimental/out/teams.html b/litellm/proxy/_experimental/out/teams/index.html similarity index 100% rename from litellm/proxy/_experimental/out/teams.html rename to litellm/proxy/_experimental/out/teams/index.html diff --git a/litellm/proxy/_experimental/out/test-key.html b/litellm/proxy/_experimental/out/test-key/index.html similarity index 100% rename from litellm/proxy/_experimental/out/test-key.html rename to litellm/proxy/_experimental/out/test-key/index.html diff --git a/litellm/proxy/_experimental/out/usage.html b/litellm/proxy/_experimental/out/usage/index.html similarity index 100% rename from litellm/proxy/_experimental/out/usage.html rename to litellm/proxy/_experimental/out/usage/index.html diff --git a/litellm/proxy/_experimental/out/users.html b/litellm/proxy/_experimental/out/users/index.html similarity index 100% rename from litellm/proxy/_experimental/out/users.html rename to litellm/proxy/_experimental/out/users/index.html diff --git a/litellm/proxy/_experimental/out/virtual-keys.html b/litellm/proxy/_experimental/out/virtual-keys/index.html similarity index 100% rename from litellm/proxy/_experimental/out/virtual-keys.html rename to litellm/proxy/_experimental/out/virtual-keys/index.html diff --git a/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py b/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py index 1043ea29a7..06e8a3ce6a 100644 --- a/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py +++ b/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py @@ -242,22 +242,35 @@ class TestVertexAIPassThroughHandler: test_token = vertex_credentials with mock.patch( - "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.vertex_llm_base._ensure_access_token_async" - ) as mock_ensure_token, mock.patch( - "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.vertex_llm_base._get_token_and_url" - ) as mock_get_token, mock.patch( + "litellm.llms.vertex_ai.vertex_llm_base.VertexBase.load_auth" + ) as mock_load_auth, mock.patch( "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.create_pass_through_route" ) as mock_create_route, mock.patch( "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.get_litellm_virtual_key" ) as mock_get_virtual_key, mock.patch( "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.user_api_key_auth" - ) as mock_user_auth: + ) as mock_user_auth, mock.patch( + "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.get_vertex_pass_through_handler" + ) as mock_get_handler: + # Mock credentials object with necessary attributes + mock_credentials = Mock() + mock_credentials.token = test_token + # Setup mocks - mock_ensure_token.return_value = ("test-auth-header", test_project) - mock_get_token.return_value = (test_token, "") + mock_load_auth.return_value = (mock_credentials, test_project) mock_get_virtual_key.return_value = "Bearer test-key" mock_user_auth.return_value = {"api_key": "test-key"} + # Mock the vertex handler + mock_handler = Mock() + mock_handler.get_default_base_target_url.return_value = ( + f"https://{test_location}-aiplatform.googleapis.com/" + ) + mock_handler.update_base_target_url_with_credential_location = Mock( + return_value=f"https://{test_location}-aiplatform.googleapis.com/" + ) + mock_get_handler.return_value = mock_handler + # Mock create_pass_through_route to return a function that returns a mock response mock_endpoint_func = AsyncMock(return_value={"status": "success"}) mock_create_route.return_value = mock_endpoint_func @@ -327,22 +340,35 @@ class TestVertexAIPassThroughHandler: test_token = vertex_credentials with mock.patch( - "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.vertex_llm_base._ensure_access_token_async" - ) as mock_ensure_token, mock.patch( - "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.vertex_llm_base._get_token_and_url" - ) as mock_get_token, mock.patch( + "litellm.llms.vertex_ai.vertex_llm_base.VertexBase.load_auth" + ) as mock_load_auth, mock.patch( "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.create_pass_through_route" ) as mock_create_route, mock.patch( "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.get_litellm_virtual_key" ) as mock_get_virtual_key, mock.patch( "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.user_api_key_auth" - ) as mock_user_auth: + ) as mock_user_auth, mock.patch( + "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.get_vertex_pass_through_handler" + ) as mock_get_handler: + # Mock credentials object with necessary attributes + mock_credentials = Mock() + mock_credentials.token = test_token + # Setup mocks - mock_ensure_token.return_value = ("test-auth-header", test_project) - mock_get_token.return_value = (test_token, "") + mock_load_auth.return_value = (mock_credentials, test_project) mock_get_virtual_key.return_value = "Bearer test-key" mock_user_auth.return_value = {"api_key": "test-key"} + # Mock the vertex handler for global location + mock_handler = Mock() + mock_handler.get_default_base_target_url.return_value = ( + "https://aiplatform.googleapis.com/" + ) + mock_handler.update_base_target_url_with_credential_location = Mock( + return_value="https://aiplatform.googleapis.com/" + ) + mock_get_handler.return_value = mock_handler + # Mock create_pass_through_route to return a function that returns a mock response mock_endpoint_func = AsyncMock(return_value={"status": "success"}) mock_create_route.return_value = mock_endpoint_func @@ -414,14 +440,31 @@ class TestVertexAIPassThroughHandler: mock_response = Response() with mock.patch( - "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.vertex_llm_base._ensure_access_token_async" - ) as mock_ensure_token, mock.patch( - "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.vertex_llm_base._get_token_and_url" - ) as mock_get_token, mock.patch( + "litellm.llms.vertex_ai.vertex_llm_base.VertexBase.load_auth" + ) as mock_load_auth, mock.patch( "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.create_pass_through_route" - ) as mock_create_route: - mock_ensure_token.return_value = ("test-auth-header", default_project) - mock_get_token.return_value = (default_credentials, "") + ) as mock_create_route, mock.patch( + "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.get_vertex_pass_through_handler" + ) as mock_get_handler: + # Mock credentials object with necessary attributes + mock_credentials = Mock() + mock_credentials.token = default_credentials + + mock_load_auth.return_value = (mock_credentials, default_project) + + # Mock the vertex handler + mock_handler = Mock() + mock_handler.get_default_base_target_url.return_value = ( + f"https://{default_location}-aiplatform.googleapis.com/" + ) + mock_handler.update_base_target_url_with_credential_location = Mock( + return_value=f"https://{default_location}-aiplatform.googleapis.com/" + ) + mock_get_handler.return_value = mock_handler + + # Mock create_pass_through_route to return a function that returns a mock response + mock_endpoint_func = AsyncMock(return_value={"status": "success"}) + mock_create_route.return_value = mock_endpoint_func try: await vertex_proxy_route(