fix: make sure smtp can be set either via env or ui
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
2bb01bd201
commit
01acea6838
9 changed files with 238 additions and 42 deletions
|
|
@ -124,6 +124,71 @@ defmodule MvWeb.GlobalSettingsLiveTest do
|
|||
{:ok, _view, html} = live(conn, ~p"/settings")
|
||||
assert html =~ "SMTP" or html =~ "E-Mail" or html =~ "Settings"
|
||||
end
|
||||
|
||||
@tag :ui
|
||||
test "disables all SMTP inputs when SMTP_HOST is set", %{conn: conn} do
|
||||
clear_smtp_env()
|
||||
System.put_env("SMTP_HOST", "smtp.env-only.example")
|
||||
on_exit(fn -> clear_smtp_env() end)
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/settings")
|
||||
|
||||
assert has_element?(view, "#setting_smtp_host[disabled]")
|
||||
assert has_element?(view, "#setting_smtp_port[disabled]")
|
||||
assert has_element?(view, "#setting_smtp_ssl[disabled]")
|
||||
assert has_element?(view, "#setting_smtp_username[disabled]")
|
||||
assert has_element?(view, "#setting_smtp_password[disabled]")
|
||||
assert has_element?(view, "#setting_smtp_from_email[disabled]")
|
||||
assert has_element?(view, "#setting_smtp_from_name[disabled]")
|
||||
end
|
||||
|
||||
@tag :ui
|
||||
test "does not render SMTP save action when SMTP_HOST is set", %{conn: conn} do
|
||||
clear_smtp_env()
|
||||
System.put_env("SMTP_HOST", "smtp.env-only.example")
|
||||
on_exit(fn -> clear_smtp_env() end)
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/settings")
|
||||
refute has_element?(view, "#smtp-form button", "Save SMTP Settings")
|
||||
end
|
||||
|
||||
@tag :ui
|
||||
test "shows explicit ENV-only mode hint when SMTP_HOST is set", %{conn: conn} do
|
||||
clear_smtp_env()
|
||||
System.put_env("SMTP_HOST", "smtp.env-only.example")
|
||||
on_exit(fn -> clear_smtp_env() end)
|
||||
|
||||
{:ok, _view, html} = live(conn, ~p"/settings")
|
||||
assert html =~ "SMTP is fully managed via environment variables"
|
||||
end
|
||||
|
||||
@tag :ui
|
||||
test "shows warning block for missing required SMTP ENV values in ENV-only mode", %{
|
||||
conn: conn
|
||||
} do
|
||||
clear_smtp_env()
|
||||
System.put_env("SMTP_HOST", "smtp.env-only.example")
|
||||
on_exit(fn -> clear_smtp_env() end)
|
||||
|
||||
{:ok, _view, html} = live(conn, ~p"/settings")
|
||||
assert html =~ "SMTP environment configuration appears incomplete"
|
||||
assert html =~ "SMTP_USERNAME"
|
||||
assert html =~ "SMTP_PASSWORD/SMTP_PASSWORD_FILE"
|
||||
end
|
||||
|
||||
@tag :ui
|
||||
test "does not enter ENV-only mode when SMTP_HOST is not set", %{conn: conn} do
|
||||
clear_smtp_env()
|
||||
System.put_env("SMTP_USERNAME", "leftover@example.com")
|
||||
on_exit(fn -> clear_smtp_env() end)
|
||||
|
||||
{:ok, view, html} = live(conn, ~p"/settings")
|
||||
|
||||
refute html =~ "SMTP is fully managed via environment variables"
|
||||
refute html =~ "SMTP environment configuration appears incomplete"
|
||||
refute has_element?(view, "#setting_smtp_host[disabled]")
|
||||
refute has_element?(view, "#setting_smtp_username[disabled]")
|
||||
end
|
||||
end
|
||||
|
||||
describe "Authentication section when OIDC-only is enabled" do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue