Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added example test using new testing API #97

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading