test: add tests for smtp mailer config
This commit is contained in:
parent
f53a3ce3cc
commit
c4135308e6
9 changed files with 440 additions and 0 deletions
|
|
@ -449,4 +449,42 @@ defmodule Mv.Config do
|
|||
def oidc_admin_group_name_env_set?, do: env_set?("OIDC_ADMIN_GROUP_NAME")
|
||||
def oidc_groups_claim_env_set?, do: env_set?("OIDC_GROUPS_CLAIM")
|
||||
def oidc_only_env_set?, do: env_set?("OIDC_ONLY")
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# SMTP configuration (stubs for TDD – ENV overrides Settings; see docs/smtp-configuration-concept.md)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@doc "Returns SMTP host. ENV SMTP_HOST overrides Settings. Stub: always nil until implemented."
|
||||
@spec smtp_host() :: String.t() | nil
|
||||
def smtp_host, do: nil
|
||||
|
||||
@doc "Returns SMTP port (e.g. 587). ENV SMTP_PORT overrides Settings. Stub: always nil until implemented."
|
||||
@spec smtp_port() :: non_neg_integer() | nil
|
||||
def smtp_port, do: nil
|
||||
|
||||
@doc "Returns SMTP username. ENV SMTP_USERNAME overrides Settings. Stub: always nil until implemented."
|
||||
@spec smtp_username() :: String.t() | nil
|
||||
def smtp_username, do: nil
|
||||
|
||||
@doc "Returns SMTP password. ENV SMTP_PASSWORD overrides SMTP_PASSWORD_FILE overrides Settings. Stub: always nil until implemented."
|
||||
@spec smtp_password() :: String.t() | nil
|
||||
def smtp_password, do: nil
|
||||
|
||||
@doc "Returns SMTP TLS/SSL mode (e.g. 'tls', 'ssl', 'none'). Stub: always nil until implemented."
|
||||
@spec smtp_ssl() :: String.t() | nil
|
||||
def smtp_ssl, do: nil
|
||||
|
||||
@doc "Returns true when SMTP is configured (e.g. host present). Stub: always false until implemented."
|
||||
@spec smtp_configured?() :: boolean()
|
||||
def smtp_configured?, do: false
|
||||
|
||||
@doc "Returns true when any SMTP ENV variable is set (for Settings UI hint). Stub: always false until implemented."
|
||||
@spec smtp_env_configured?() :: boolean()
|
||||
def smtp_env_configured?, do: false
|
||||
|
||||
def smtp_host_env_set?, do: env_set?("SMTP_HOST")
|
||||
def smtp_port_env_set?, do: env_set?("SMTP_PORT")
|
||||
def smtp_username_env_set?, do: env_set?("SMTP_USERNAME")
|
||||
def smtp_password_env_set?, do: env_set?("SMTP_PASSWORD") or env_set?("SMTP_PASSWORD_FILE")
|
||||
def smtp_ssl_env_set?, do: env_set?("SMTP_SSL")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,4 +16,15 @@ defmodule Mv.Mailer do
|
|||
def mail_from do
|
||||
Application.get_env(:mv, :mail_from, {"Mila", "noreply@example.com"})
|
||||
end
|
||||
|
||||
@doc """
|
||||
Sends a test email to the given address. Used from Global Settings SMTP section.
|
||||
|
||||
Returns `{:ok, email}` on success, `{:error, reason}` on failure (e.g. invalid address,
|
||||
SMTP not configured, connection error). Stub: always returns error until implemented.
|
||||
"""
|
||||
@spec send_test_email(String.t()) :: {:ok, Swoosh.Email.t()} | {:error, term()}
|
||||
def send_test_email(_to_email) do
|
||||
{:error, :not_implemented}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue