From a005ff9b2170138388a08eb88938ccfe3b290d67 Mon Sep 17 00:00:00 2001 From: Rick <26716961+Bytechoreographer@users.noreply.github.com> Date: Wed, 21 Oct 2026 18:10:32 +0800 Subject: [PATCH] test(dashscope): cover caller Authorization on messages --- .../test_dashscope_messages_transformation.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/unit/llms/dashscope/test_dashscope_messages_transformation.py b/tests/unit/llms/dashscope/test_dashscope_messages_transformation.py index 5c3e6ec72dc..24d79c6a3e3 100644 --- a/tests/unit/llms/dashscope/test_dashscope_messages_transformation.py +++ b/tests/unit/llms/dashscope/test_dashscope_messages_transformation.py @@ -107,6 +107,24 @@ def test_caller_auth_header_is_honored_without_a_dashscope_key(monkeypatch: pyte assert resolved_headers["x-api-key"] == "caller-key" +def test_caller_authorization_header_is_honored_without_a_dashscope_key(monkeypatch: pytest.MonkeyPatch): + monkeypatch.delenv("DASHSCOPE_API_KEY", raising=False) + monkeypatch.setattr(litellm, "api_key", None) + headers = {"Authorization": "Bearer caller-token"} + + resolved_headers, _ = DashScopeAnthropicMessagesConfig().validate_anthropic_messages_environment( + headers=headers, + model="qwen3.7-plus", + messages=[], + optional_params={}, + litellm_params={}, + api_key=None, + api_base=WORKSPACE, + ) + + assert resolved_headers["Authorization"] == "Bearer caller-token" + + def test_dashscope_key_wins_over_an_anthropic_environment_key(monkeypatch: pytest.MonkeyPatch): monkeypatch.setenv("DASHSCOPE_API_KEY", "sk-dashscope") monkeypatch.setenv("ANTHROPIC_API_KEY", "sk-ant-secret")