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
14 changes: 11 additions & 3 deletions src/models/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Any, Optional

from pydantic import BaseModel
from pydantic import BaseModel, Field


class ModelsResponse(BaseModel):
Expand Down Expand Up @@ -252,8 +252,16 @@ class AuthorizedResponse(BaseModel):
username: The name of the logged in user.
"""

user_id: str
username: str
user_id: str = Field(
...,
description="User ID, for example UUID",
examples=["c5260aec-4d82-4370-9fdf-05cf908b3f16"],
)
username: str = Field(
...,
description="User name",
examples=["John Doe", "Adam Smith"],
)

# provides examples for /docs endpoint
model_config = {
Expand Down
30 changes: 26 additions & 4 deletions tests/unit/models/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,22 @@ def test_tls_configuration() -> None:
assert cfg.tls_key_password == Path("tests/configuration/password")


def test_tls_configuration_in_service_configuration() -> None:
"""Test the TLS configuration in service configuration."""
cfg = ServiceConfiguration(
tls_config=TLSConfiguration(
tls_certificate_path=Path("tests/configuration/server.crt"),
tls_key_path=Path("tests/configuration/server.key"),
tls_key_password=Path("tests/configuration/password"),
)
)
assert cfg is not None
assert cfg.tls_config is not None
assert cfg.tls_config.tls_certificate_path == Path("tests/configuration/server.crt")
assert cfg.tls_config.tls_key_path == Path("tests/configuration/server.key")
assert cfg.tls_config.tls_key_password == Path("tests/configuration/password")


def test_tls_configuration_wrong_certificate_path() -> None:
"""Test the TLS configuration loading when some path is broken."""
with pytest.raises(ValueError, match="Path does not point to a file"):
Expand Down Expand Up @@ -416,7 +432,13 @@ def test_dump_configuration(tmp_path) -> None:
"""
cfg = Configuration(
name="test_name",
service=ServiceConfiguration(),
service=ServiceConfiguration(
tls_config=TLSConfiguration(
tls_certificate_path=Path("tests/configuration/server.crt"),
tls_key_path=Path("tests/configuration/server.key"),
tls_key_password=Path("tests/configuration/password"),
)
),
llama_stack=LlamaStackConfiguration(
use_as_library_client=True,
library_client_config_path="tests/configuration/run.yaml",
Expand Down Expand Up @@ -462,9 +484,9 @@ def test_dump_configuration(tmp_path) -> None:
"color_log": True,
"access_log": True,
"tls_config": {
"tls_certificate_path": None,
"tls_key_path": None,
"tls_key_password": None,
"tls_certificate_path": "tests/configuration/server.crt",
"tls_key_password": "tests/configuration/password",
"tls_key_path": "tests/configuration/server.key",
},
},
"llama_stack": {
Expand Down