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:

  1. Missing smtp_enable guard. The method raised on any unrecognized smtp_authentication value even when SMTP was disabled. A user with SMTP off but a legacy/unsupported mechanism (e.g. 'xoauth2') in gitlab.rb would hit a reconfigure failure. This is now consistent with validate_smtp_settings!, which returns early unless rails_config['smtp_enable'].

  2. Mixed-case mechanisms not canonicalized. A valid but mixed-case value such as 'LOGIN' or :Plain passed 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 same ArgumentError !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:

MR acceptance checklist

Merge request reports

Loading