oliver-zehentleitner / maity

clean-up: mail settings are validated twice (environment and admin PATCH)

Sign in to report

tsk-k019dz7e9pzj Done An agent

Split from tsk-8vdegd61y70v (item 17 of the clean-up audit tsk-hgnbapyw7hnh, area 12). Line numbers are from 80647565; check them against current main.

Order: after tsk-q4zynccy5t0b, which changes mail/settings.py.

What: the mail settings are checked once for the environment (mail/environment.py) and again for the admin's PATCH (mail/settings.py):

  • "tls: none needs a loopback host" three times: environment.py:115, settings.py:258 (patch) and settings.py:292 (tls_refusal).
  • The ASCII printable username and password check: environment.py:121-122 and 194, and again as settings._ascii (settings.py:297-299).
  • The sender check: environment.parse_sender (environment.py:93-103), and again as settings._sender (settings.py:302-310).

Proposal: one set of validators in environment.py (for example ascii_secret, sender_ok, tls_host_refusal), used by parse, patch and tls_refusal. A pure refactor: same answers and error codes, the existing tests stay green.

Effort: S. Risk: low.