From e1bf6d775ee99551abe68fb7ae3fdc808ed2a6a8 Mon Sep 17 00:00:00 2001 From: Alejandro Roman Date: Tue, 1 Sep 2026 13:15:33 +0400 Subject: [PATCH] feat(UI): fix lint issues --- .../files/python/migrate_from_mailu.py | 2 +- roles/web-app-stalwart/meta/services.yml | 6 +++++ .../web-app-stalwart/templates/compose.yml.j2 | 1 + .../test_msmtprc_ca_trust.py | 5 ++++- .../test_roundcube_oauth_scheme.py | 22 ++++++++++++++----- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/roles/web-app-stalwart/files/python/migrate_from_mailu.py b/roles/web-app-stalwart/files/python/migrate_from_mailu.py index 0e60fcc783..bdac639908 100755 --- a/roles/web-app-stalwart/files/python/migrate_from_mailu.py +++ b/roles/web-app-stalwart/files/python/migrate_from_mailu.py @@ -201,7 +201,7 @@ def connect(host: str, port: int, insecure: bool) -> imaplib.IMAP4_SSL: imap = imaplib.IMAP4_SSL(host, port, ssl_context=context, timeout=30) # Exception: imaplib encodes command arguments as ASCII, so a mailbox password holding any # non-ASCII character (e.g. '€') raises UnicodeEncodeError before the LOGIN is ever sent. - imap._encoding = "utf-8" # noqa: SLF001 + imap._encoding = "utf-8" return imap diff --git a/roles/web-app-stalwart/meta/services.yml b/roles/web-app-stalwart/meta/services.yml index afb9aca4b0..62b0a17b6d 100644 --- a/roles/web-app-stalwart/meta/services.yml +++ b/roles/web-app-stalwart/meta/services.yml @@ -93,6 +93,7 @@ mailu: enabled: false shared: false # nocheck: playwright-service-flag — DB engine, covered by role-local integration tests +# nocheck: image-healthcheck — the container DOES get a probe: sys-svc-rdbms/templates/services/postgres.yml.j2 emits pg_isready with the real username, and this role's compose pulls that partial in through sys-svc-compose's base. Declaring one here instead would be dead config, since no template of this role renders it (container-healthcheck-unused). The checker only follows one include level, so it cannot see that partial. postgres: bond: 1 enabled: true # nocheck: dynamic-flag @@ -112,6 +113,11 @@ webmail: enabled: true shared: true image: roundcube/roundcubemail + # Exception: the image ships no HEALTHCHECK, and curl is the only probe tool it carries (no + # wget, no nc) -- so this flavor and no other. `-f` passes the 302 that oauth_login_redirect + # returns from `/` under SSO while still failing a 5xx. + healthcheck: + flavor: curl version: "1.7.2-apache" cpus: "0.3" mem_reservation: 256m diff --git a/roles/web-app-stalwart/templates/compose.yml.j2 b/roles/web-app-stalwart/templates/compose.yml.j2 index 1ebe192595..165e5212b9 100644 --- a/roles/web-app-stalwart/templates/compose.yml.j2 +++ b/roles/web-app-stalwart/templates/compose.yml.j2 @@ -34,6 +34,7 @@ {{ lookup('container_image', application_id, service_name) }} {% include 'roles/sys-svc-container/templates/base.yml.j2' %} {{ lookup('container_extra_hosts') | indent(4) }} + {{ lookup('container_healthcheck', service_name) | indent(4) }} {{ lookup('container_ports', ['webmail', 'http', DOCKER_BIND_HOST]) | indent(4) }} environment: ROUNDCUBEMAIL_DEFAULT_HOST: "ssl://stalwart" diff --git a/tests/unit/python/roles/sys-svc-mail-msmtp/test_msmtprc_ca_trust.py b/tests/unit/python/roles/sys-svc-mail-msmtp/test_msmtprc_ca_trust.py index d749f92c8a..9048df5ff8 100644 --- a/tests/unit/python/roles/sys-svc-mail-msmtp/test_msmtprc_ca_trust.py +++ b/tests/unit/python/roles/sys-svc-mail-msmtp/test_msmtprc_ca_trust.py @@ -14,6 +14,7 @@ from __future__ import annotations import re import unittest +from typing import Any, ClassVar from jinja2 import Environment, StrictUndefined @@ -131,7 +132,9 @@ class TestMsmtprcOnionProxy(unittest.TestCase): Connection refused" and the hlth-msmtp unit takes the deploy down with it. """ - ONION_EMAIL = dict(EMAIL, host="mail.abc123.onion", tls=False, port=25) + ONION_EMAIL: ClassVar[dict[str, Any]] = dict( + EMAIL, host="mail.abc123.onion", tls=False, port=25 + ) def _proxy(self, rendered: str) -> dict[str, str]: found = {} diff --git a/tests/unit/python/roles/web-app-stalwart/test_roundcube_oauth_scheme.py b/tests/unit/python/roles/web-app-stalwart/test_roundcube_oauth_scheme.py index d128cc3f2a..164ce94b0c 100644 --- a/tests/unit/python/roles/web-app-stalwart/test_roundcube_oauth_scheme.py +++ b/tests/unit/python/roles/web-app-stalwart/test_roundcube_oauth_scheme.py @@ -23,10 +23,16 @@ from utils.cache.files import read_text from . import PROJECT_ROOT TEMPLATE = ( - PROJECT_ROOT / "roles" / "web-app-stalwart" / "templates" / "roundcube-oauth.inc.php.j2" + PROJECT_ROOT + / "roles" + / "web-app-stalwart" + / "templates" + / "roundcube-oauth.inc.php.j2" ) FORCE_HTTPS = "$_SERVER['HTTPS'] = 'on';" -ONION_BASE = "http://webmail.4dl6yijmuksgh5bfaf3csqoelji7zptyuo6wy5g5prjpnk6vdbzfwnad.onion" +ONION_BASE = ( + "http://webmail.4dl6yijmuksgh5bfaf3csqoelji7zptyuo6wy5g5prjpnk6vdbzfwnad.onion" +) CLEARNET_BASE = "https://webmail.infinito.example" @@ -67,7 +73,9 @@ class TestRoundcubeOauthScheme(unittest.TestCase): self.assertIn(FORCE_HTTPS, _render("https://webmail.example.onion")) def test_an_onion_issuer_routes_the_back_channel_through_tor(self): - rendered = _render(ONION_BASE, socks_proxy="socks5h://host.docker.internal:9050") + rendered = _render( + ONION_BASE, socks_proxy="socks5h://host.docker.internal:9050" + ) self.assertIn( "$config['http_client'] = ['proxy' => 'socks5h://host.docker.internal:9050'];", rendered, @@ -75,14 +83,18 @@ class TestRoundcubeOauthScheme(unittest.TestCase): def test_the_proxy_must_hand_the_name_to_tor_to_resolve(self): """socks5:// resolves locally, which is what cURL refuses to do for .onion.""" - rendered = _render(ONION_BASE, socks_proxy="socks5h://host.docker.internal:9050") + rendered = _render( + ONION_BASE, socks_proxy="socks5h://host.docker.internal:9050" + ) self.assertNotIn("'proxy' => 'socks5://", rendered) def test_a_clearnet_issuer_gets_no_proxy_at_all(self): self.assertNotIn("http_client", _render(CLEARNET_BASE)) def test_nothing_is_emitted_without_sso(self): - rendered = _render(CLEARNET_BASE, sso_enabled=False, socks_proxy="socks5h://tor:9050") + rendered = _render( + CLEARNET_BASE, sso_enabled=False, socks_proxy="socks5h://tor:9050" + ) self.assertNotIn(FORCE_HTTPS, rendered) self.assertNotIn("oauth_client_id", rendered) self.assertNotIn("http_client", rendered)