Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions tests/unit/models/config/test_authentication_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
),
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/models/config/test_llama_stack_configuration.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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,
Expand Down
17 changes: 12 additions & 5 deletions tests/unit/utils/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from logging import Logger

from pydantic import AnyHttpUrl
from pytest_mock import MockerFixture

import pytest
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/utils/test_mcp_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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"}
Expand All @@ -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"}
Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/utils/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
Loading