diff --git a/fractal_server/config.py b/fractal_server/config.py index 2ef7287ccd..80cc4a756c 100644 --- a/fractal_server/config.py +++ b/fractal_server/config.py @@ -54,8 +54,8 @@ class MailSettings(BaseModel): recipients: list[EmailStr] = Field(min_items=1) smtp_server: str port: int - encrypted_password: str - encryption_key: str + encrypted_password: Optional[str] = None + encryption_key: Optional[str] = None instance_name: str use_starttls: bool use_login: bool diff --git a/tests/no_version/test_email.py b/tests/no_version/test_email.py index 9b533cf81d..287f8e1847 100644 --- a/tests/no_version/test_email.py +++ b/tests/no_version/test_email.py @@ -3,22 +3,25 @@ from fractal_server.app.models import OAuthAccount from fractal_server.app.models import UserOAuth from fractal_server.app.security import get_user_manager +from fractal_server.config import MailSettings async def test_server_not_available(override_settings_factory, db, caplog): override_settings_factory( - FRACTAL_EMAIL_PASSWORD=( - "gAAAAABnoQUGHMsDgLkpDtwUtrKtf9T1so44ahEXExGRceAnf097mVY1EbNuMP5fj" - "vkndvwCwBJM7lHoSgKQkZ4VbvO9t3PJZg==" - ), - FRACTAL_EMAIL_PASSWORD_KEY=( - "lp3j2FVDkzLd0Rklnzg1pHuV9ClCuDE0aGeJfTNCaW4=" - ), - FRACTAL_EMAIL_RECIPIENTS="test@example.org", - FRACTAL_EMAIL_SENDER="fractal@fractal.fractal", - FRACTAL_EMAIL_SMTP_SERVER="localhost", - FRACTAL_EMAIL_SMTP_PORT="1234", - FRACTAL_EMAIL_INSTANCE_NAME="fractal", + FRACTAL_EMAIL_SETTINGS=MailSettings( + sender="fractal@fractal.fractal", + recipients=["test@example.org"], + smtp_server="localhost", + port=1234, + encrypted_password=( + "gAAAAABnoQUGHMsDgLkpDtwUtrKtf9T1so44ahEXExGRceAnf097mVY1EbNuM" + "P5fjvkndvwCwBJM7lHoSgKQkZ4VbvO9t3PJZg==" + ), + encryption_key="lp3j2FVDkzLd0Rklnzg1pHuV9ClCuDE0aGeJfTNCaW4=", + instance_name="fractal", + use_starttls=False, + use_login=True, + ) ) user = UserOAuth( email="user@example.org", @@ -49,5 +52,6 @@ async def test_server_not_available(override_settings_factory, db, caplog): async with contextlib.asynccontextmanager(get_user_manager)() as um: await um.on_after_register(user) + assert "ERROR sending notification email" in caplog.text assert "[Errno 111] Connection refused" in caplog.text diff --git a/tests/v2/06_tasks_lifecycle/test_unit_bash_scripts.py b/tests/v2/06_tasks_lifecycle/test_unit_bash_scripts.py index 7424211cff..13c07e3a7b 100644 --- a/tests/v2/06_tasks_lifecycle/test_unit_bash_scripts.py +++ b/tests/v2/06_tasks_lifecycle/test_unit_bash_scripts.py @@ -64,7 +64,7 @@ def test_template_2( settings = Settings( **Settings( FRACTAL_PIP_CACHE_DIR=(tmp_path / "CACHE_DIR").as_posix() - ).dict() + ).dict(exclude_unset=True) ) path = tmp_path / "unit_templates" venv_path = path / "venv"