Skip to content

Commit

Permalink
Tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaddox5 committed Oct 15, 2024
1 parent 0193c3b commit d225f0d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/screenplay_web/auth_manager/error_handler_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ defmodule ScreenplayWeb.AuthManager.ErrorHandlerTest do
alias ScreenplayWeb.AuthManager.ErrorHandler

describe "auth_error/3" do
test "returns 403 for API endpoints if there's no refresh key", %{conn: conn} do
conn =
conn
|> init_test_session(%{previous_path: "api/test"})
|> ErrorHandler.auth_error({:some_type, :reason}, [])

assert %{status: 403} = conn
end

test "redirects to Keycloak login if there's no refresh key", %{conn: conn} do
conn =
conn
|> init_test_session(%{})
|> init_test_session(%{previous_path: "test"})
|> ErrorHandler.auth_error({:some_type, :reason}, [])

assert html_response(conn, 302) =~ "\"/auth/keycloak\?prompt%3Dlogin"
Expand Down

0 comments on commit d225f0d

Please sign in to comment.