Skip to content

Commit

Permalink
[WiP] update to auth_plug 1.4.3 with end_session/1 ... some tests fai…
Browse files Browse the repository at this point in the history
…ling because of #163
  • Loading branch information
nelsonic committed Nov 23, 2021
1 parent b5e4a1a commit 73b0403
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
5 changes: 5 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ config :logger, level: :warn
config :elixir_auth_google,
client_id: "631770888008-6n0oruvsm16kbkqg6u76p5cv5kfkcekt.apps.googleusercontent.com",
client_secret: "MHxv6-RGF5nheXnxh1b0LNDq",
httpoison_mock: true

config :auth_plug,
api_key:
"2PzB7PPnpuLsbWmWtXpGyI+kfSQSQ1zUW2Atz/+8PdZuSEJzHgzGnJWV35nTKRwx/authdev.herokuapp.com",
httpoison_mock: true
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ defmodule Auth.Mixfile do
# https://github.com/dwyl/elixir-auth-google
{:elixir_auth_google, "~> 1.6.1"},
# https://github.com/dwyl/auth_plug
{:auth_plug, "~> 1.4.1"},
{:auth_plug, "~> 1.4.3"},
# https://github.com/dwyl/rbac
{:rbac, "~> 0.5.3"},

Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%{
"argon2_elixir": {:hex, :argon2_elixir, "2.4.0", "2a22ea06e979f524c53b42b598fc6ba38cdcbc977a155e33e057732cfb1fb311", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "4ea82e183cf8e7f66dab1f767fedcfe6a195e140357ef2b0423146b72e0a551d"},
"auth_plug": {:hex, :auth_plug, "1.4.1", "a4dea02fd27fd541f99d0b3cc56e32d331698200324547a0a989717ea8c190a8", [:mix], [{:httpoison, "~> 1.8.0", [hex: :httpoison, repo: "hexpm", optional: false]}, {:jason, "~> 1.2.2", [hex: :jason, repo: "hexpm", optional: false]}, {:joken, "~> 2.4.1", [hex: :joken, repo: "hexpm", optional: false]}, {:plug, "~> 1.12.1", [hex: :plug, repo: "hexpm", optional: false]}, {:useful, "~> 0.4.0", [hex: :useful, repo: "hexpm", optional: false]}], "hexpm", "1e81c26461559f412c234f2e81ecfa3ffb402cfe530f457d0014ef15c15a36fe"},
"auth_plug": {:hex, :auth_plug, "1.4.3", "b5ebfe644025d01c6beb6f4374d44e079cfe2e5e04a6841c014d8a5e94f19a81", [:mix], [{:httpoison, "~> 1.8.0", [hex: :httpoison, repo: "hexpm", optional: false]}, {:jason, "~> 1.2.2", [hex: :jason, repo: "hexpm", optional: false]}, {:joken, "~> 2.4.1", [hex: :joken, repo: "hexpm", optional: false]}, {:plug, "~> 1.12.1", [hex: :plug, repo: "hexpm", optional: false]}, {:useful, "~> 0.4.0", [hex: :useful, repo: "hexpm", optional: false]}], "hexpm", "d7e573a4d09a3551f4e1a403c90ba7a226dae0879e054918cde3fb4d10e986be"},
"b58": {:hex, :b58, "1.0.2", "d758f42d89fbe84052f18b2f310bed2a8c8c5b38dd0af86970026974cc7daeda", [:mix], [], "hexpm", "148e299e2753eae222b13f399f461a0c4910fed608b8723fca3c33d1d4f82c17"},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"castore": {:hex, :castore, "0.1.13", "ccf3ab251ffaebc4319f41d788ce59a6ab3f42b6c27e598ad838ffecee0b04f9", [:mix], [], "hexpm", "a14a7eecfec7e20385493dbb92b0d12c5d77ecfd6307de10102d58c94e8c49c0"},
Expand Down
15 changes: 12 additions & 3 deletions priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ defmodule Auth.Seeds do
import Ecto.Changeset

def create_admin do
if is_nil(System.get_env("TRAVIS")) && is_nil(System.get_env("HEROKU")) &&
is_nil(System.get_env("GITHUB_TOKEN")) do
if is_nil(System.get_env("HEROKU")) && is_nil(System.get_env("GITHUB_TOKEN")) do
load_env()
end

Expand Down Expand Up @@ -42,6 +41,16 @@ defmodule Auth.Seeds do
person
end

# this is used exclusivvely in seeds
defp get_auth_url do
# see .env_sample for example
api_key = System.get_env("AUTH_API_KEY")

parts = String.split(api_key, "/");
# should return "dwylauth.herokuapp.com"
List.last(parts)
end

def create_apikey_for_admin(person) do
{:ok, app} =
%{
Expand All @@ -64,7 +73,7 @@ defmodule Auth.Seeds do
|> cast(update_attrs, [:client_id, :client_secret])
|> Repo.update()

api_key = key.client_id <> "/" <> key.client_secret
api_key = key.client_id <> "/" <> key.client_secret <> "/" <> get_auth_url()
# set the AUTH_API_KEY environment variable during test run:
IO.inspect(Mix.env(), label: "Mix.env()")
# IO.inspect(person)
Expand Down
8 changes: 4 additions & 4 deletions test/auth_web/controllers/auth_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,10 @@ defmodule AuthWeb.AuthControllerTest do
assert html_response(conn, 200) =~ "password is incorrect"
end

test "Attempt to /logout", %{conn: conn} do
conn = conn |> non_admin_login() |> Auth.Session.start_session()
test "/logout of the auth app", %{conn: conn} do
conn1 = conn |> non_admin_login() |> Auth.Session.start_session()

conn = get(conn, "/logout", %{})
assert html_response(conn, 302) =~ "Successfully logged out."
conn2 = get(conn1, "/logout", %{})
assert html_response(conn2, 200) =~ "Successfully logged out."
end
end

0 comments on commit 73b0403

Please sign in to comment.