Skip to content

Commit

Permalink
feat: Remove unused authentication_source env var
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadyan committed Aug 23, 2023
1 parent 2018807 commit 9b38d7a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 37 deletions.
1 change: 0 additions & 1 deletion .envrc.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export ALERT_API_URL=http://s3.amazonaws.com/mbta-realtime-test/alerts_enhanced.
export API_KEY=
export API_URL=https://api-dev.mbtace.com/
export APP_COOKIE=
export AUTHENTICATION_SOURCE=
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export DATABASE_URL_DEV=postgresql://__username__:password@localhost:5432/alert_concierge_dev
Expand Down
23 changes: 6 additions & 17 deletions apps/concierge_site/lib/concierge_site.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,12 @@ defmodule ConciergeSite do
use Application

def start(_type, _args) do
auth_children =
if Application.get_env(:concierge_site, ConciergeSite.Endpoint)[:authentication_source] ==
"keycloak" do
[
{OpenIDConnect.Worker, Application.get_env(:ueberauth, Ueberauth.Strategy.OIDC)}
]
else
[]
end

children =
auth_children ++
[
{Phoenix.PubSub, name: ConciergeSite.PubSub},
ConciergeSite.Endpoint,
Guardian.DB.Token.SweeperServer
]
children = [
{OpenIDConnect.Worker, Application.get_env(:ueberauth, Ueberauth.Strategy.OIDC)},
{Phoenix.PubSub, name: ConciergeSite.PubSub},
ConciergeSite.Endpoint,
Guardian.DB.Token.SweeperServer
]

Supervisor.start_link(children, strategy: :one_for_one)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ defmodule ConciergeSite.AccountControllerTest do
@moduledoc false
use ConciergeSite.ConnCase, async: true
import AlertProcessor.Factory
import Test.Support.Helpers
alias AlertProcessor.Helpers.ConfigHelper
alias AlertProcessor.Model.{Notification, Subscription, Trip, User}
alias AlertProcessor.Repo

describe "new/4" do
test "redirects to the keycloak register route", %{conn: conn} do
reassign_env(:concierge_site, ConciergeSite.Endpoint, authentication_source: "keycloak")
conn = get(conn, account_path(conn, :new))
assert redirected_to(conn) == "/auth/keycloak/register"
end
Expand Down Expand Up @@ -69,7 +67,6 @@ defmodule ConciergeSite.AccountControllerTest do
end

test "POST /account/options with errors", %{conn: conn} do
reassign_env(:concierge_site, ConciergeSite.Endpoint, authentication_source: "keycloak")
user = insert(:user)

user_params = %{
Expand Down Expand Up @@ -100,7 +97,6 @@ defmodule ConciergeSite.AccountControllerTest do
end

test "POST /account/edit", %{conn: conn} do
reassign_env(:concierge_site, ConciergeSite.Endpoint, authentication_source: "keycloak")
user = insert(:user, phone_number: nil)

user_params = %{
Expand All @@ -124,7 +120,6 @@ defmodule ConciergeSite.AccountControllerTest do
end

test "POST /account/edit error must accept terms and conditions", %{conn: conn} do
reassign_env(:concierge_site, ConciergeSite.Endpoint, authentication_source: "keycloak")
user = insert(:user, communication_mode: "email", phone_number: "8888888888")

user_params = %{
Expand Down Expand Up @@ -240,8 +235,6 @@ defmodule ConciergeSite.AccountControllerTest do

describe "update password" do
test "GET /password/edit - for Keycloak auth", %{conn: conn} do
reassign_env(:concierge_site, ConciergeSite.Endpoint, authentication_source: "keycloak")

user = insert(:user)

conn =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ defmodule ConciergeSite.Web.AuthControllerTest do

describe "GET /auth/:provider/callback" do
setup do
reassign_env(:concierge_site, ConciergeSite.Endpoint, authentication_source: "keycloak")

reassign_env(:concierge_site, :token_verify_fn, fn _, _ ->
{:ok, %{"resource_access" => %{"t-alerts" => %{"roles" => ["admin", "user"]}}}}
end)
Expand Down Expand Up @@ -123,8 +121,6 @@ defmodule ConciergeSite.Web.AuthControllerTest do
end

test "redirects to the landing page for an ueberauth failure", %{conn: conn} do
reassign_env(:concierge_site, ConciergeSite.Endpoint, authentication_source: "keycloak")

conn =
conn
|> init_test_session(%{username: "test_username"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@ defmodule ConciergeSite.SessionControllerTest do
@moduledoc false
use ConciergeSite.ConnCase
import AlertProcessor.Factory
import Test.Support.Helpers
alias Hammer

describe "GET /login/new" do
test "redirects to Keycloak login page", %{conn: conn} do
reassign_env(:concierge_site, ConciergeSite.Endpoint, authentication_source: "keycloak")

conn = get(conn, session_path(conn, :new))

assert redirected_to(conn, 302) == "/auth/keycloak"
end
end

test "DELETE /login", %{conn: conn} do
reassign_env(:concierge_site, ConciergeSite.Endpoint, authentication_source: "keycloak")

user = insert(:user)

conn =
Expand Down
3 changes: 0 additions & 3 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import Config
config :alert_processor, AlertProcessor.Repo,
url: System.fetch_env!("DATABASE_URL_#{config_env() |> to_string() |> String.upcase()}")

config :concierge_site, ConciergeSite.Endpoint,
authentication_source: System.get_env("AUTHENTICATION_SOURCE", "local")

config :concierge_site,
keycloak_base_uri: System.get_env("KEYCLOAK_BASE_URI"),
keycloak_client_id: System.get_env("KEYCLOAK_CLIENT_ID"),
Expand Down

0 comments on commit 9b38d7a

Please sign in to comment.