Updated env var
This commit is contained in:
parent
167dcb2694
commit
283a749fba
4 changed files with 11 additions and 11 deletions
|
|
@ -22,7 +22,7 @@ config :pinchflat,
|
||||||
# If either is unset, basic auth will not be used.
|
# If either is unset, basic auth will not be used.
|
||||||
basic_auth_username: "",
|
basic_auth_username: "",
|
||||||
basic_auth_password: "",
|
basic_auth_password: "",
|
||||||
expose_xml_feed: false,
|
expose_feed_endpoints: false,
|
||||||
file_watcher_poll_interval: 1000
|
file_watcher_poll_interval: 1000
|
||||||
|
|
||||||
# Configures the endpoint
|
# Configures the endpoint
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ if config_env() == :prod do
|
||||||
extras_path = System.get_env("EXTRAS_PATH", Path.join([config_path, "extras"]))
|
extras_path = System.get_env("EXTRAS_PATH", Path.join([config_path, "extras"]))
|
||||||
|
|
||||||
# For running PF as a podcast host on self-hosted environments
|
# For running PF as a podcast host on self-hosted environments
|
||||||
expose_xml_feed = String.length(System.get_env("EXPOSE_XML_FEED", "")) > 0
|
expose_feed_endpoints = String.length(System.get_env("EXPOSE_FEED_ENDPOINTS", "")) > 0
|
||||||
|
|
||||||
# We want to force _some_ level of useful logging in production
|
# We want to force _some_ level of useful logging in production
|
||||||
acceptable_log_levels = ~w(debug info)a
|
acceptable_log_levels = ~w(debug info)a
|
||||||
|
|
@ -68,7 +68,7 @@ if config_env() == :prod do
|
||||||
extras_directory: extras_path,
|
extras_directory: extras_path,
|
||||||
tmpfile_directory: Path.join([System.tmp_dir!(), "pinchflat", "data"]),
|
tmpfile_directory: Path.join([System.tmp_dir!(), "pinchflat", "data"]),
|
||||||
dns_cluster_query: System.get_env("DNS_CLUSTER_QUERY"),
|
dns_cluster_query: System.get_env("DNS_CLUSTER_QUERY"),
|
||||||
expose_xml_feed: expose_xml_feed
|
expose_feed_endpoints: expose_feed_endpoints
|
||||||
|
|
||||||
config :pinchflat, Pinchflat.Repo,
|
config :pinchflat, Pinchflat.Repo,
|
||||||
database: db_path,
|
database: db_path,
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ defmodule PinchflatWeb.Router do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_basic_auth(conn, opts) do
|
defp maybe_basic_auth(conn, opts) do
|
||||||
if Application.get_env(:pinchflat, :expose_xml_feed) do
|
if Application.get_env(:pinchflat, :expose_feed_endpoints) do
|
||||||
conn
|
conn
|
||||||
else
|
else
|
||||||
basic_auth(conn, opts)
|
basic_auth(conn, opts)
|
||||||
|
|
|
||||||
|
|
@ -61,23 +61,23 @@ defmodule PinchflatWeb.RoutingTest do
|
||||||
setup do
|
setup do
|
||||||
old_username = Application.get_env(:pinchflat, :basic_auth_username)
|
old_username = Application.get_env(:pinchflat, :basic_auth_username)
|
||||||
old_password = Application.get_env(:pinchflat, :basic_auth_password)
|
old_password = Application.get_env(:pinchflat, :basic_auth_password)
|
||||||
old_expore_xml_feed = Application.get_env(:pinchflat, :expose_xml_feed)
|
old_expose_feed_endpoints = Application.get_env(:pinchflat, :expose_feed_endpoints)
|
||||||
|
|
||||||
source = source_fixture()
|
source = source_fixture()
|
||||||
|
|
||||||
on_exit(fn ->
|
on_exit(fn ->
|
||||||
Application.put_env(:pinchflat, :basic_auth_username, old_username)
|
Application.put_env(:pinchflat, :basic_auth_username, old_username)
|
||||||
Application.put_env(:pinchflat, :basic_auth_password, old_password)
|
Application.put_env(:pinchflat, :basic_auth_password, old_password)
|
||||||
Application.put_env(:pinchflat, :expose_xml_feed, old_expore_xml_feed)
|
Application.put_env(:pinchflat, :expose_feed_endpoints, old_expose_feed_endpoints)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
{:ok, source: source}
|
{:ok, source: source}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "uses basic auth when expose_xml_feed is false", %{source: source} do
|
test "uses basic auth when expose_feed_endpoints is false", %{source: source} do
|
||||||
Application.put_env(:pinchflat, :basic_auth_username, "user")
|
Application.put_env(:pinchflat, :basic_auth_username, "user")
|
||||||
Application.put_env(:pinchflat, :basic_auth_password, "pass")
|
Application.put_env(:pinchflat, :basic_auth_password, "pass")
|
||||||
Application.put_env(:pinchflat, :expose_xml_feed, false)
|
Application.put_env(:pinchflat, :expose_feed_endpoints, false)
|
||||||
|
|
||||||
conn = get(build_conn(), "/sources/#{source.uuid}/feed")
|
conn = get(build_conn(), "/sources/#{source.uuid}/feed")
|
||||||
|
|
||||||
|
|
@ -85,10 +85,10 @@ defmodule PinchflatWeb.RoutingTest do
|
||||||
assert {"www-authenticate", "Basic realm=\"Pinchflat\""} in conn.resp_headers
|
assert {"www-authenticate", "Basic realm=\"Pinchflat\""} in conn.resp_headers
|
||||||
end
|
end
|
||||||
|
|
||||||
test "does not use basic auth when expose_xml_feed is true", %{source: source} do
|
test "does not use basic auth when expose_feed_endpoints is true", %{source: source} do
|
||||||
Application.put_env(:pinchflat, :basic_auth_username, "user")
|
Application.put_env(:pinchflat, :basic_auth_username, "user")
|
||||||
Application.put_env(:pinchflat, :basic_auth_password, "pass")
|
Application.put_env(:pinchflat, :basic_auth_password, "pass")
|
||||||
Application.put_env(:pinchflat, :expose_xml_feed, true)
|
Application.put_env(:pinchflat, :expose_feed_endpoints, true)
|
||||||
|
|
||||||
conn = get(build_conn(), "/sources/#{source.uuid}/feed")
|
conn = get(build_conn(), "/sources/#{source.uuid}/feed")
|
||||||
|
|
||||||
|
|
@ -98,7 +98,7 @@ defmodule PinchflatWeb.RoutingTest do
|
||||||
test "does not use basic auth when username/password aren't set", %{source: source} do
|
test "does not use basic auth when username/password aren't set", %{source: source} do
|
||||||
Application.put_env(:pinchflat, :basic_auth_username, nil)
|
Application.put_env(:pinchflat, :basic_auth_username, nil)
|
||||||
Application.put_env(:pinchflat, :basic_auth_password, nil)
|
Application.put_env(:pinchflat, :basic_auth_password, nil)
|
||||||
Application.put_env(:pinchflat, :expose_xml_feed, false)
|
Application.put_env(:pinchflat, :expose_feed_endpoints, false)
|
||||||
|
|
||||||
conn = get(build_conn(), "/sources/#{source.uuid}/feed")
|
conn = get(build_conn(), "/sources/#{source.uuid}/feed")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue