Fix smtp_authentication parsing edge cases
What does this MR do and why?
Addresses two review comments raised by GitLab Duo on the 19.0/19.1 backports (!9520 (merged) and !9519 (merged)) of !9516 (merged), fixing them in master first.
SmtpHelper.parse_smtp_authentication! had two edge-case bugs:
-
Missing
smtp_enableguard. The method raised on any unrecognizedsmtp_authenticationvalue even when SMTP was disabled. A user with SMTP off but a legacy/unsupported mechanism (e.g.'xoauth2') ingitlab.rbwould hit a reconfigure failure. This is now consistent withvalidate_smtp_settings!, which returns earlyunless rails_config['smtp_enable']. -
Mixed-case mechanisms not canonicalized. A valid but mixed-case value such as
'LOGIN'or:Plainpassed the membership check (which uses a downcased copy) but was left unchanged in the config. The template then rendered:LOGIN/:Plain, which net-smtp 0.5.x rejects with the sameArgumentError!9516 (merged) set out to fix. The method now writes the canonical lowercase mechanism back into the config.
Both behaviors are covered by unit tests in smtp_helper_spec.rb and an end-to-end render test in gitlab-rails_spec.rb.
Related:
- !9516 (merged) (original fix)
- !9520 (merged), !9519 (merged) (backports where the comments were raised)
- gitlab#603334 (closed)
MR acceptance checklist
- I have evaluated the MR acceptance checklist for this MR.