Files
ea-chatbot-lg/backend/tests/test_config.py
Yunxiao Xu 68c0985482 feat(auth): Complete OIDC security refactor and modernize test suite
- Refactored OIDC flow to implement PKCE, state/nonce validation, and BFF pattern.
- Centralized configuration in Settings class (DEV_MODE, FRONTEND_URL, OIDC_REDIRECT_URI).
- Updated auth routers to use conditional secure cookie flags based on DEV_MODE.
- Modernized and cleaned up test suite by removing legacy Streamlit tests.
- Fixed linting errors and unused imports across the backend.
2026-02-15 02:50:26 -08:00

45 lines
1.9 KiB
Python

from ea_chatbot.config import Settings, LLMConfig
def test_default_settings():
"""Test that default settings are loaded correctly."""
settings = Settings()
# Check default config for query analyzer
assert isinstance(settings.query_analyzer_llm, LLMConfig)
assert settings.query_analyzer_llm.provider == "openai"
assert settings.query_analyzer_llm.model == "gpt-5-mini"
assert settings.query_analyzer_llm.temperature == 0.0
# Check default config for planner
assert isinstance(settings.planner_llm, LLMConfig)
assert settings.planner_llm.provider == "openai"
assert settings.planner_llm.model == "gpt-5-mini"
def test_env_override(monkeypatch):
"""Test that environment variables override defaults."""
monkeypatch.setenv("QUERY_ANALYZER_LLM__MODEL", "gpt-3.5-turbo")
monkeypatch.setenv("QUERY_ANALYZER_LLM__TEMPERATURE", "0.7")
settings = Settings()
assert settings.query_analyzer_llm.model == "gpt-3.5-turbo"
assert settings.query_analyzer_llm.temperature == 0.7
def test_provider_specific_params():
"""Test that provider specific parameters can be set."""
config = LLMConfig(
provider="openai",
model="o1-preview",
provider_specific={"reasoning_effort": "high"}
)
assert config.provider_specific["reasoning_effort"] == "high"
def test_oidc_settings(monkeypatch):
"""Test OIDC settings configuration."""
monkeypatch.setenv("OIDC_CLIENT_ID", "test_client_id")
monkeypatch.setenv("OIDC_CLIENT_SECRET", "test_client_secret")
monkeypatch.setenv("OIDC_SERVER_METADATA_URL", "https://test.server/.well-known/openid-configuration")
settings = Settings()
assert settings.oidc_client_id == "test_client_id"
assert settings.oidc_client_secret == "test_client_secret"
assert settings.oidc_server_metadata_url == "https://test.server/.well-known/openid-configuration"