livebook/test/support/conn_case.ex
Alexandre de Souza 98561f927e
Improve integration tests and fix some intemittent tests (#3033)
Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
2025-07-16 17:07:42 -03:00

42 lines
984 B
Elixir

defmodule LivebookWeb.ConnCase do
use ExUnit.CaseTemplate
using do
quote do
# Import conveniences for testing with connections
import Plug.Conn
import Phoenix.ConnTest
import Livebook.Factory
import LivebookWeb.ConnCase
use LivebookWeb, :verified_routes
# The default endpoint for testing
@endpoint LivebookWeb.Endpoint
end
end
setup tags do
conn = Phoenix.ConnTest.build_conn()
conn =
if authentication = tags[:authentication] do
with_authentication(conn, authentication)
else
conn
end
[conn: conn]
end
def with_authentication(conn, authentication) do
Plug.Test.init_test_session(conn, %{authentication_test_override: authentication})
end
def with_authorization(conn, id, name) do
Plug.Test.init_test_session(conn, %{
identity_provider_test_override: {:zta, Livebook.ZTA.LivebookTeams, id},
zta_name_test_override: name
})
end
end