Skip to content

Commit

Permalink
feat: Remove unused authentication_source env var
Browse files Browse the repository at this point in the history
Don't run OIDC worker in test.
  • Loading branch information
arkadyan committed Aug 23, 2023
1 parent 40d9905 commit 9d6fe86
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 23 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
3 changes: 2 additions & 1 deletion apps/concierge_site/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import Config
# General application configuration
config :concierge_site,
namespace: ConciergeSite,
ecto_repos: []
ecto_repos: [],
start_oidc_worker: true

# Configures the endpoint
config :concierge_site, ConciergeSite.Endpoint,
Expand Down
3 changes: 3 additions & 0 deletions apps/concierge_site/config/test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Config

config :concierge_site,
start_oidc_worker: false

# Run a server for browser-based feature tests
config :concierge_site, ConciergeSite.Endpoint, server: true, http: [port: 4001]

Expand Down
3 changes: 1 addition & 2 deletions apps/concierge_site/lib/concierge_site.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ defmodule ConciergeSite do

def start(_type, _args) do
auth_children =
if Application.get_env(:concierge_site, ConciergeSite.Endpoint)[:authentication_source] ==
"keycloak" do
if Application.get_env(:concierge_site, :start_oidc_worker) do
[
{OpenIDConnect.Worker, Application.get_env(:ueberauth, Ueberauth.Strategy.OIDC)}
]
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 9d6fe86

Please sign in to comment.