From 6349b68bcdc3aa2625ca435d47c3a659fdb5a7ef Mon Sep 17 00:00:00 2001 From: Haito Date: Wed, 22 Nov 2023 00:17:43 +0100 Subject: [PATCH] Added example test using new testing API --- config/test.exs | 3 +++ mix.exs | 2 +- .../controllers/auth_controller_test.exs | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/ueberauth_example_web/controllers/auth_controller_test.exs diff --git a/config/test.exs b/config/test.exs index 9c5ac97..41d4b5b 100644 --- a/config/test.exs +++ b/config/test.exs @@ -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, []}}] diff --git a/mix.exs b/mix.exs index 4a5d8f5..4192ba3 100644 --- a/mix.exs +++ b/mix.exs @@ -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"}, diff --git a/test/ueberauth_example_web/controllers/auth_controller_test.exs b/test/ueberauth_example_web/controllers/auth_controller_test.exs new file mode 100644 index 0000000..c62b63c --- /dev/null +++ b/test/ueberauth_example_web/controllers/auth_controller_test.exs @@ -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