Skip to content

Commit

Permalink
Added example test using new testing API
Browse files Browse the repository at this point in the history
  • Loading branch information
Hajto committed Nov 21, 2023
1 parent 386bc65 commit 6349b68
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ config :ueberauth_example, UeberauthExampleWeb.Endpoint,

# Print only warnings and errors during test
config :logger, level: :warn

config :ueberauth, Ueberauth,
providers: [{:testing, {Ueberauth.Strategy.Test, []}}]
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ defmodule UeberauthExample.MixProject do
{:jason, "~> 1.0"},
{:plug_cowboy, "~> 2.0"},
{:plug_crypto, "~> 1.2"},
{:ueberauth, "~> 0.6"},
{:ueberauth, path: "../ueberauth", override: true},
{:oauth2, "~> 2.0", override: true},
{:ueberauth_facebook, "~> 0.8"},
{:ueberauth_google, "~> 0.8"},
Expand Down
16 changes: 16 additions & 0 deletions test/ueberauth_example_web/controllers/auth_controller_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
defmodule UeberauthExampleWeb.AuthControllerTest do
alias Ecto.UUID
use UeberauthExampleWeb.ConnCase

alias Ueberauth.Strategy

test "GET /", %{conn: conn} do
user = %Strategy.Test.UserData{
uid: UUID.generate()
}
conn = Strategy.Test.put_testing_user(conn, user)
conn = get(conn, "/auth/testing/callback")
assert conn.status == 302
assert get_flash(conn) == %{"info" => "Successfully authenticated."}
end
end

0 comments on commit 6349b68

Please sign in to comment.