Loading .pre-commit-config.yaml +1 −0 Changes for .pre-commit-config.yaml: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -30,5 +30,6 @@ repos: "PyJWT[crypto]>=2.10.1", "pytest>=8.0.0", "pytest-asyncio>=0.25.0", "sqlalchemy>=2.0.48", "structlog>=25.0.0", ] pyproject.toml +2 −0 Changes for pyproject.toml: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -13,6 +13,8 @@ dependencies = [ "structlog>=25.0.0", "PyJWT[crypto]>=2.10.1", "httpx>=0.28.0", "sqlalchemy>=2.0.48", "asyncpg>=0.31.0", ] [project.optional-dependencies] Loading src/portal_service/config.py +7 −0 Changes for src/portal_service/config.py: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -50,6 +50,12 @@ class SessionSettings(BaseModel): https_only: bool = False class PostgreSQLSettings(BaseModel): url: str = "postgresql+asyncpg://postgres:postgres@localhost:5432/portal" echo: bool = False create_schema_on_startup: bool = False class CORSSettings(BaseModel): allowed_origins: list[str] = ["http://localhost:3000"] Loading @@ -64,6 +70,7 @@ class Settings(BaseSettings): auth: AuthSettings = AuthSettings() oidc: OIDCSettings | None = None session: SessionSettings postgresql_settings: PostgreSQLSettings = PostgreSQLSettings() cors: CORSSettings = CORSSettings() @model_validator(mode="after") Loading tests/conftest.py +2 −0 Changes for tests/conftest.py: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ CLIENT_ID = "oop-portal" _BASE_ENV = { "SESSION__SECRET_KEY": "test-secret-key-for-sessions", "POSTGRESQL_SETTINGS__URL": "postgresql+asyncpg://portal:portal@127.0.0.1:1/portal", "POSTGRESQL_SETTINGS__CREATE_SCHEMA_ON_STARTUP": "false", "OIDC__ISSUER": ISSUER, "OIDC__CLIENT_ID": CLIENT_ID, "OIDC__CLIENT_SECRET": "test-client-secret", Loading tests/test_config.py +20 −0 Changes for tests/test_config.py: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import pytest from portal_service.config import ( AuthSettings, OIDCSettings, PostgreSQLSettings, SecurityMode, SessionSettings, Settings, Loading Loading @@ -68,3 +69,22 @@ def test_none_mode_allows_missing_oidc() -> None: ) assert s.auth.security_mode == SecurityMode.NONE assert s.oidc is None def test_postgresql_defaults() -> None: pg = PostgreSQLSettings() assert pg.url == "postgresql+asyncpg://postgres:postgres@localhost:5432/portal" assert pg.echo is False assert pg.create_schema_on_startup is False def test_postgresql_settings_from_env(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setenv("SESSION__SECRET_KEY", "s") monkeypatch.setenv("AUTH__SECURITY_MODE", "none") monkeypatch.setenv( "POSTGRESQL_SETTINGS__URL", "postgresql+asyncpg://portal:secret@postgres:5432/portal" ) monkeypatch.setenv("POSTGRESQL_SETTINGS__CREATE_SCHEMA_ON_STARTUP", "true") pg = Settings().postgresql_settings # type: ignore[call-arg] assert pg.url == "postgresql+asyncpg://portal:secret@postgres:5432/portal" assert pg.create_schema_on_startup is True Loading
.pre-commit-config.yaml +1 −0 Changes for .pre-commit-config.yaml: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -30,5 +30,6 @@ repos: "PyJWT[crypto]>=2.10.1", "pytest>=8.0.0", "pytest-asyncio>=0.25.0", "sqlalchemy>=2.0.48", "structlog>=25.0.0", ]
pyproject.toml +2 −0 Changes for pyproject.toml: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -13,6 +13,8 @@ dependencies = [ "structlog>=25.0.0", "PyJWT[crypto]>=2.10.1", "httpx>=0.28.0", "sqlalchemy>=2.0.48", "asyncpg>=0.31.0", ] [project.optional-dependencies] Loading
src/portal_service/config.py +7 −0 Changes for src/portal_service/config.py: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -50,6 +50,12 @@ class SessionSettings(BaseModel): https_only: bool = False class PostgreSQLSettings(BaseModel): url: str = "postgresql+asyncpg://postgres:postgres@localhost:5432/portal" echo: bool = False create_schema_on_startup: bool = False class CORSSettings(BaseModel): allowed_origins: list[str] = ["http://localhost:3000"] Loading @@ -64,6 +70,7 @@ class Settings(BaseSettings): auth: AuthSettings = AuthSettings() oidc: OIDCSettings | None = None session: SessionSettings postgresql_settings: PostgreSQLSettings = PostgreSQLSettings() cors: CORSSettings = CORSSettings() @model_validator(mode="after") Loading
tests/conftest.py +2 −0 Changes for tests/conftest.py: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ CLIENT_ID = "oop-portal" _BASE_ENV = { "SESSION__SECRET_KEY": "test-secret-key-for-sessions", "POSTGRESQL_SETTINGS__URL": "postgresql+asyncpg://portal:portal@127.0.0.1:1/portal", "POSTGRESQL_SETTINGS__CREATE_SCHEMA_ON_STARTUP": "false", "OIDC__ISSUER": ISSUER, "OIDC__CLIENT_ID": CLIENT_ID, "OIDC__CLIENT_SECRET": "test-client-secret", Loading
tests/test_config.py +20 −0 Changes for tests/test_config.py: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import pytest from portal_service.config import ( AuthSettings, OIDCSettings, PostgreSQLSettings, SecurityMode, SessionSettings, Settings, Loading Loading @@ -68,3 +69,22 @@ def test_none_mode_allows_missing_oidc() -> None: ) assert s.auth.security_mode == SecurityMode.NONE assert s.oidc is None def test_postgresql_defaults() -> None: pg = PostgreSQLSettings() assert pg.url == "postgresql+asyncpg://postgres:postgres@localhost:5432/portal" assert pg.echo is False assert pg.create_schema_on_startup is False def test_postgresql_settings_from_env(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setenv("SESSION__SECRET_KEY", "s") monkeypatch.setenv("AUTH__SECURITY_MODE", "none") monkeypatch.setenv( "POSTGRESQL_SETTINGS__URL", "postgresql+asyncpg://portal:secret@postgres:5432/portal" ) monkeypatch.setenv("POSTGRESQL_SETTINGS__CREATE_SCHEMA_ON_STARTUP", "true") pg = Settings().postgresql_settings # type: ignore[call-arg] assert pg.url == "postgresql+asyncpg://portal:secret@postgres:5432/portal" assert pg.create_schema_on_startup is True