From bffcaa94539c114afdb7c4750c8a397c2223c8bc Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Tue, 3 Mar 2026 09:26:38 +0100 Subject: [PATCH 1/2] Added missing parameters --- tests/unit/utils/test_common.py | 17 ++++++++++++----- tests/unit/utils/test_mcp_headers.py | 7 +++++++ tests/unit/utils/test_responses.py | 6 ++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/tests/unit/utils/test_common.py b/tests/unit/utils/test_common.py index 39d343e2f..197048664 100644 --- a/tests/unit/utils/test_common.py +++ b/tests/unit/utils/test_common.py @@ -2,6 +2,7 @@ from logging import Logger +from pydantic import AnyHttpUrl from pytest_mock import MockerFixture import pytest @@ -37,10 +38,11 @@ async def test_register_mcp_servers_empty_list(mocker: MockerFixture) -> None: workers=10, color_log=True, access_log=True, + root_path="/.", ), llama_stack=LlamaStackConfiguration( use_as_library_client=False, - url="http://localhost:8321", + url=AnyHttpUrl("http://localhost:8321"), library_client_config_path=None, api_key=None, timeout=60, @@ -98,10 +100,11 @@ async def test_register_mcp_servers_single_server_not_registered( workers=10, color_log=True, access_log=True, + root_path="/.", ), llama_stack=LlamaStackConfiguration( use_as_library_client=False, - url="http://localhost:8321", + url=AnyHttpUrl("http://localhost:8321"), library_client_config_path=None, api_key=None, timeout=60, @@ -161,10 +164,11 @@ async def test_register_mcp_servers_single_server_already_registered( workers=10, color_log=True, access_log=True, + root_path="/.", ), llama_stack=LlamaStackConfiguration( use_as_library_client=False, - url="http://localhost:8321", + url=AnyHttpUrl("http://localhost:8321"), library_client_config_path=None, api_key=None, timeout=60, @@ -233,10 +237,11 @@ async def test_register_mcp_servers_multiple_servers_mixed_registration( workers=10, color_log=True, access_log=True, + root_path="/.", ), llama_stack=LlamaStackConfiguration( use_as_library_client=False, - url="http://localhost:8321", + url=AnyHttpUrl("http://localhost:8321"), library_client_config_path=None, api_key=None, timeout=60, @@ -304,10 +309,11 @@ async def test_register_mcp_servers_with_custom_provider(mocker: MockerFixture) workers=10, color_log=True, access_log=True, + root_path="/.", ), llama_stack=LlamaStackConfiguration( use_as_library_client=False, - url="http://localhost:8321", + url=AnyHttpUrl("http://localhost:8321"), library_client_config_path=None, api_key=None, timeout=60, @@ -375,6 +381,7 @@ async def test_register_mcp_servers_async_with_library_client( workers=10, color_log=True, access_log=True, + root_path="/.", ), llama_stack=LlamaStackConfiguration( use_as_library_client=True, diff --git a/tests/unit/utils/test_mcp_headers.py b/tests/unit/utils/test_mcp_headers.py index e76d632fe..5dda9170a 100644 --- a/tests/unit/utils/test_mcp_headers.py +++ b/tests/unit/utils/test_mcp_headers.py @@ -203,6 +203,7 @@ def test_extracts_matching_headers(self) -> None: name="rbac", url="http://rbac:8080", headers=["x-rh-identity", "x-request-id"], + provider_id="xyzzy", ) request_headers = { "x-rh-identity": "encoded-identity-value", @@ -221,6 +222,7 @@ def test_skips_missing_headers(self) -> None: name="rbac", url="http://rbac:8080", headers=["x-rh-identity", "x-missing-header"], + provider_id="xyzzy", ) request_headers = { "x-rh-identity": "identity-value", @@ -234,6 +236,7 @@ def test_empty_allowlist(self) -> None: name="rbac", url="http://rbac:8080", headers=[], + provider_id="xyzzy", ) request_headers = {"x-rh-identity": "identity-value"} result = extract_propagated_headers(server, request_headers) @@ -245,6 +248,7 @@ def test_empty_request_headers(self) -> None: name="rbac", url="http://rbac:8080", headers=["x-rh-identity"], + provider_id="xyzzy", ) result = extract_propagated_headers(server, {}) assert not result @@ -255,6 +259,7 @@ def test_case_insensitive_lookup(self) -> None: name="rbac", url="http://rbac:8080", headers=["X-Rh-Identity"], + provider_id="xyzzy", ) # FastAPI/Starlette lowercases header names internally request_headers = {"x-rh-identity": "identity-value"} @@ -267,6 +272,7 @@ def test_case_insensitive_lookup_mixed_case_request(self) -> None: name="rbac", url="http://rbac:8080", headers=["x-rh-identity"], + provider_id="xyzzy", ) # Plain dict with mixed-case keys (not Starlette Headers) request_headers = {"X-RH-Identity": "identity-value"} @@ -278,6 +284,7 @@ def test_no_headers_field_configured(self) -> None: server = ModelContextProtocolServer( name="rbac", url="http://rbac:8080", + provider_id="xyzzy", ) request_headers = {"x-rh-identity": "identity-value"} result = extract_propagated_headers(server, request_headers) diff --git a/tests/unit/utils/test_responses.py b/tests/unit/utils/test_responses.py index f1f3ef924..c0810965d 100644 --- a/tests/unit/utils/test_responses.py +++ b/tests/unit/utils/test_responses.py @@ -633,6 +633,7 @@ async def test_get_mcp_tools_with_propagated_headers( name="rbac", url="http://rbac:8080", headers=["x-rh-identity", "x-request-id"], + provider_id="provider", ), ] mock_config = mocker.Mock() @@ -667,6 +668,7 @@ async def test_get_mcp_tools_propagated_headers_do_not_overwrite_auth_headers( url="http://rbac:8080", authorization_headers={"Authorization": str(secret_file)}, headers=["Authorization", "x-rh-identity"], + provider_id="provider", ), ] mock_config = mocker.Mock() @@ -697,6 +699,7 @@ async def test_get_mcp_tools_propagated_headers_missing_from_request( name="rbac", url="http://rbac:8080", headers=["x-rh-identity", "x-missing"], + provider_id="provider", ), ] mock_config = mocker.Mock() @@ -722,6 +725,7 @@ async def test_get_mcp_tools_propagated_headers_no_request_headers( name="rbac", url="http://rbac:8080", headers=["x-rh-identity"], + provider_id="provider", ), ] mock_config = mocker.Mock() @@ -743,6 +747,7 @@ async def test_get_mcp_tools_propagated_headers_additive_with_mcp_headers( url="http://server1:8080", authorization_headers={"Authorization": "client"}, headers=["x-rh-identity"], + provider_id="provider", ), ] mock_config = mocker.Mock() @@ -773,6 +778,7 @@ async def test_get_mcp_tools_mixed_case_precedence( url="http://rbac:8080", authorization_headers={"Authorization": str(secret_file)}, headers=["authorization", "x-rh-identity"], + provider_id="provider", ), ] mock_config = mocker.Mock() From b055357168f45a4fe5414dc901ba6df1cffc5330 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Tue, 3 Mar 2026 09:26:51 +0100 Subject: [PATCH 2/2] Added missing parameters --- .../config/test_authentication_configuration.py | 15 ++++++++++----- .../config/test_llama_stack_configuration.py | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/unit/models/config/test_authentication_configuration.py b/tests/unit/models/config/test_authentication_configuration.py index 7575751a0..b862b3453 100644 --- a/tests/unit/models/config/test_authentication_configuration.py +++ b/tests/unit/models/config/test_authentication_configuration.py @@ -303,11 +303,12 @@ def test_authentication_configuration_in_config_noop() -> None: color_log=True, access_log=True, workers=1, + root_path="/.", ), llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="tests/configuration/run.yaml", - url="http://localhost", + url=AnyHttpUrl("http://localhost"), api_key=SecretStr(""), timeout=60, ), @@ -342,11 +343,12 @@ def test_authentication_configuration_skip_readiness_probe() -> None: color_log=True, access_log=True, workers=1, + root_path="/.", ), llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="tests/configuration/run.yaml", - url="http://localhost", + url=AnyHttpUrl("http://localhost"), api_key=SecretStr(""), timeout=60, ), @@ -389,11 +391,12 @@ def test_authentication_configuration_in_config_k8s() -> None: color_log=True, access_log=True, workers=1, + root_path="/.", ), llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="tests/configuration/run.yaml", - url="http://localhost", + url=AnyHttpUrl("http://localhost"), api_key=SecretStr(""), timeout=60, ), @@ -446,11 +449,12 @@ def test_authentication_configuration_in_config_rh_identity() -> None: color_log=True, access_log=True, workers=1, + root_path="/.", ), llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="tests/configuration/run.yaml", - url="http://localhost", + url=AnyHttpUrl("http://localhost"), api_key=SecretStr(""), timeout=60, ), @@ -493,11 +497,12 @@ def test_authentication_configuration_in_config_jwktoken() -> None: color_log=True, access_log=True, workers=1, + root_path="/.", ), llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="tests/configuration/run.yaml", - url="http://localhost", + url=AnyHttpUrl("http://localhost"), api_key=SecretStr(""), timeout=60, ), diff --git a/tests/unit/models/config/test_llama_stack_configuration.py b/tests/unit/models/config/test_llama_stack_configuration.py index cc2db8236..89cedf55a 100644 --- a/tests/unit/models/config/test_llama_stack_configuration.py +++ b/tests/unit/models/config/test_llama_stack_configuration.py @@ -1,7 +1,7 @@ """Unit tests for LlamaStackConfiguration model.""" import pytest -from pydantic import ValidationError +from pydantic import ValidationError, AnyHttpUrl from utils.checks import InvalidConfigurationError @@ -25,7 +25,7 @@ def test_llama_stack_configuration_constructor() -> None: llama_stack_configuration = LlamaStackConfiguration( use_as_library_client=False, - url="http://localhost", + url=AnyHttpUrl("http://localhost"), library_client_config_path=None, api_key=None, timeout=60,