mirror of
https://github.com/plausible/analytics.git
synced 2025-01-03 15:17:58 +03:00
Merge Plugins.API.Router
into main one (#3767)
* Merge `Plugins.API.Router` into main one In order to get grafana metrics reported See: https://github.com/akoutmos/prom_ex/issues/224 * Format
This commit is contained in:
parent
f5129f1b0d
commit
6a2d7fc0f5
@ -62,8 +62,7 @@ defmodule PlausibleWeb do
|
|||||||
quote do
|
quote do
|
||||||
use Phoenix.Controller, namespace: PlausibleWeb.Plugins.API
|
use Phoenix.Controller, namespace: PlausibleWeb.Plugins.API
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
import PlausibleWeb.Plugins.API.Router.Helpers
|
import PlausibleWeb.Router.Helpers
|
||||||
import PlausibleWeb.Plugins.API, only: [base_uri: 0]
|
|
||||||
|
|
||||||
alias PlausibleWeb.Plugins.API.Schemas
|
alias PlausibleWeb.Plugins.API.Schemas
|
||||||
alias PlausibleWeb.Plugins.API.Views
|
alias PlausibleWeb.Plugins.API.Views
|
||||||
@ -82,7 +81,7 @@ defmodule PlausibleWeb do
|
|||||||
namespace: PlausibleWeb.Plugins.API,
|
namespace: PlausibleWeb.Plugins.API,
|
||||||
root: ""
|
root: ""
|
||||||
|
|
||||||
alias PlausibleWeb.Plugins.API.Router.Helpers
|
alias PlausibleWeb.Router.Helpers
|
||||||
import PlausibleWeb.Plugins.API.Views.Pagination, only: [render_metadata_links: 4]
|
import PlausibleWeb.Plugins.API.Views.Pagination, only: [render_metadata_links: 4]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
defmodule PlausibleWeb.Plugins.API do
|
|
||||||
@moduledoc """
|
|
||||||
Plausible Plugins API
|
|
||||||
"""
|
|
||||||
|
|
||||||
@doc """
|
|
||||||
Returns the API base URI, so that complete URLs can
|
|
||||||
be generated from forwared Router helpers.
|
|
||||||
"""
|
|
||||||
@spec base_uri() :: URI.t()
|
|
||||||
def base_uri() do
|
|
||||||
PlausibleWeb.Endpoint.url()
|
|
||||||
|> Path.join("/api/plugins")
|
|
||||||
|> URI.new!()
|
|
||||||
end
|
|
||||||
end
|
|
@ -31,7 +31,8 @@ defmodule PlausibleWeb.Plugins.API.Controllers.Goals do
|
|||||||
|
|
||||||
case API.Goals.create(site, goal_or_goals) do
|
case API.Goals.create(site, goal_or_goals) do
|
||||||
{:ok, goals} ->
|
{:ok, goals} ->
|
||||||
location_headers = Enum.map(goals, &{"location", goals_url(base_uri(), :get, &1.id)})
|
location_headers =
|
||||||
|
Enum.map(goals, &{"location", plugins_api_goals_url(conn, :get, &1.id)})
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> prepend_resp_headers(location_headers)
|
|> prepend_resp_headers(location_headers)
|
||||||
|
@ -66,7 +66,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinks do
|
|||||||
conn
|
conn
|
||||||
|> put_view(Views.SharedLink)
|
|> put_view(Views.SharedLink)
|
||||||
|> put_status(:created)
|
|> put_status(:created)
|
||||||
|> put_resp_header("location", shared_links_url(base_uri(), :get, shared_link.id))
|
|> put_resp_header("location", plugins_api_shared_links_url(conn, :get, shared_link.id))
|
||||||
|> render("shared_link.json", shared_link: shared_link, authorized_site: site)
|
|> render("shared_link.json", shared_link: shared_link, authorized_site: site)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
defmodule PlausibleWeb.Plugins.API.Router do
|
|
||||||
use PlausibleWeb, :router
|
|
||||||
|
|
||||||
pipeline :auth do
|
|
||||||
plug(PlausibleWeb.Plugs.AuthorizePluginsAPI)
|
|
||||||
end
|
|
||||||
|
|
||||||
pipeline :api do
|
|
||||||
plug(:accepts, ["json"])
|
|
||||||
plug(OpenApiSpex.Plug.PutApiSpec, module: PlausibleWeb.Plugins.API.Spec)
|
|
||||||
end
|
|
||||||
|
|
||||||
scope "/spec" do
|
|
||||||
pipe_through(:api)
|
|
||||||
get("/openapi", OpenApiSpex.Plug.RenderSpec, [])
|
|
||||||
get("/swagger-ui", OpenApiSpex.Plug.SwaggerUI, path: "/api/plugins/spec/openapi")
|
|
||||||
end
|
|
||||||
|
|
||||||
scope "/v1", PlausibleWeb.Plugins.API.Controllers do
|
|
||||||
pipe_through([:api, :auth])
|
|
||||||
|
|
||||||
get("/shared_links", SharedLinks, :index)
|
|
||||||
get("/shared_links/:id", SharedLinks, :get)
|
|
||||||
put("/shared_links", SharedLinks, :create)
|
|
||||||
|
|
||||||
get("/goals", Goals, :index)
|
|
||||||
get("/goals/:id", Goals, :get)
|
|
||||||
put("/goals", Goals, :create)
|
|
||||||
|
|
||||||
delete("/goals/:id", Goals, :delete)
|
|
||||||
delete("/goals", Goals, :delete_bulk)
|
|
||||||
|
|
||||||
put("/custom_props", CustomProps, :enable)
|
|
||||||
delete("/custom_props", CustomProps, :disable)
|
|
||||||
end
|
|
||||||
end
|
|
@ -3,7 +3,7 @@ defmodule PlausibleWeb.Plugins.API.Spec do
|
|||||||
OpenAPI specification for the Plugins API
|
OpenAPI specification for the Plugins API
|
||||||
"""
|
"""
|
||||||
alias OpenApiSpex.{Components, Info, OpenApi, Paths, Server}
|
alias OpenApiSpex.{Components, Info, OpenApi, Paths, Server}
|
||||||
alias PlausibleWeb.Plugins.API.Router
|
alias PlausibleWeb.Router
|
||||||
@behaviour OpenApi
|
@behaviour OpenApi
|
||||||
|
|
||||||
@impl OpenApi
|
@impl OpenApi
|
||||||
@ -12,7 +12,7 @@ defmodule PlausibleWeb.Plugins.API.Spec do
|
|||||||
servers: [
|
servers: [
|
||||||
%Server{
|
%Server{
|
||||||
description: "This server",
|
description: "This server",
|
||||||
url: to_string(PlausibleWeb.Plugins.API.base_uri()),
|
url: PlausibleWeb.Endpoint.url(),
|
||||||
variables: %{}
|
variables: %{}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -12,7 +12,7 @@ defmodule PlausibleWeb.Plugins.API.Views.Goal do
|
|||||||
}) do
|
}) do
|
||||||
%{
|
%{
|
||||||
goals: render_many(goals, __MODULE__, "goal.json", authorized_site: site),
|
goals: render_many(goals, __MODULE__, "goal.json", authorized_site: site),
|
||||||
meta: render_metadata_links(metadata, :goals_url, :index, conn.query_params)
|
meta: render_metadata_links(metadata, :plugins_api_goals_url, :index, conn.query_params)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ defmodule PlausibleWeb.Plugins.API.Views.Goal do
|
|||||||
}) do
|
}) do
|
||||||
%{
|
%{
|
||||||
goals: render_many(goals, __MODULE__, "goal.json", authorized_site: site),
|
goals: render_many(goals, __MODULE__, "goal.json", authorized_site: site),
|
||||||
meta: render_metadata_links(%{}, :goals_url, :index, conn.query_params)
|
meta: render_metadata_links(%{}, :plugins_api_goals_url, :index, conn.query_params)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ defmodule PlausibleWeb.Plugins.API.Views.Pagination do
|
|||||||
namespace: PlausibleWeb.Plugins.API,
|
namespace: PlausibleWeb.Plugins.API,
|
||||||
root: ""
|
root: ""
|
||||||
|
|
||||||
alias PlausibleWeb.Plugins.API.Router.Helpers
|
alias PlausibleWeb.Router.Helpers
|
||||||
|
|
||||||
def render_metadata_links(meta, helper_fn, helper_fn_args, existing_params \\ %{}) do
|
def render_metadata_links(meta, helper_fn, helper_fn_args, existing_params \\ %{}) do
|
||||||
render(__MODULE__, "pagination.json", %{
|
render(__MODULE__, "pagination.json", %{
|
||||||
@ -21,7 +21,7 @@ defmodule PlausibleWeb.Plugins.API.Views.Pagination do
|
|||||||
|> Map.merge(existing_params)
|
|> Map.merge(existing_params)
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
PlausibleWeb.Plugins.API.base_uri()
|
PlausibleWeb.Endpoint
|
||||||
| List.wrap(helper_fn_args) ++ [query_params]
|
| List.wrap(helper_fn_args) ++ [query_params]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -13,7 +13,8 @@ defmodule PlausibleWeb.Plugins.API.Views.SharedLink do
|
|||||||
%{
|
%{
|
||||||
shared_links:
|
shared_links:
|
||||||
render_many(shared_links, __MODULE__, "shared_link.json", authorized_site: site),
|
render_many(shared_links, __MODULE__, "shared_link.json", authorized_site: site),
|
||||||
meta: render_metadata_links(metadata, :shared_links_url, :index, conn.query_params)
|
meta:
|
||||||
|
render_metadata_links(metadata, :plugins_api_shared_links_url, :index, conn.query_params)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -86,8 +86,39 @@ defmodule PlausibleWeb.Router do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scope path: "/api/plugins" do
|
scope path: "/api/plugins", as: :plugins_api do
|
||||||
forward "/", PlausibleWeb.Plugins.API.Router
|
pipeline :plugins_api_auth do
|
||||||
|
plug(PlausibleWeb.Plugs.AuthorizePluginsAPI)
|
||||||
|
end
|
||||||
|
|
||||||
|
pipeline :plugins_api do
|
||||||
|
plug(:accepts, ["json"])
|
||||||
|
plug(OpenApiSpex.Plug.PutApiSpec, module: PlausibleWeb.Plugins.API.Spec)
|
||||||
|
end
|
||||||
|
|
||||||
|
scope "/spec" do
|
||||||
|
pipe_through(:plugins_api)
|
||||||
|
get("/openapi", OpenApiSpex.Plug.RenderSpec, [])
|
||||||
|
get("/swagger-ui", OpenApiSpex.Plug.SwaggerUI, path: "/api/plugins/spec/openapi")
|
||||||
|
end
|
||||||
|
|
||||||
|
scope "/v1", PlausibleWeb.Plugins.API.Controllers, assigns: %{plugins_api: true} do
|
||||||
|
pipe_through([:plugins_api, :plugins_api_auth])
|
||||||
|
|
||||||
|
get("/shared_links", SharedLinks, :index)
|
||||||
|
get("/shared_links/:id", SharedLinks, :get)
|
||||||
|
put("/shared_links", SharedLinks, :create)
|
||||||
|
|
||||||
|
get("/goals", Goals, :index)
|
||||||
|
get("/goals/:id", Goals, :get)
|
||||||
|
put("/goals", Goals, :create)
|
||||||
|
|
||||||
|
delete("/goals/:id", Goals, :delete)
|
||||||
|
delete("/goals", Goals, :delete_bulk)
|
||||||
|
|
||||||
|
put("/custom_props", CustomProps, :enable)
|
||||||
|
delete("/custom_props", CustomProps, :disable)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/api/stats", PlausibleWeb.Api do
|
scope "/api/stats", PlausibleWeb.Api do
|
||||||
|
@ -2,7 +2,7 @@ defmodule PlausibleWeb.ErrorView do
|
|||||||
use Plausible
|
use Plausible
|
||||||
use PlausibleWeb, :view
|
use PlausibleWeb, :view
|
||||||
|
|
||||||
def render("500.json", %{conn: %{private: %{PlausibleWeb.Plugins.API.Router => _}}}) do
|
def render("500.json", %{conn: %{assigns: %{plugins_api: true}}}) do
|
||||||
contact_support_note =
|
contact_support_note =
|
||||||
on_full_build do
|
on_full_build do
|
||||||
"If the problem persists please contact support@plausible.io"
|
"If the problem persists please contact support@plausible.io"
|
||||||
|
@ -22,8 +22,8 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
|
|||||||
|
|
||||||
describe "unauthorized calls" do
|
describe "unauthorized calls" do
|
||||||
for {method, url} <- [
|
for {method, url} <- [
|
||||||
{:put, Routes.custom_props_url(base_uri(), :enable)},
|
{:put, Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)},
|
||||||
{:delete, Routes.custom_props_url(base_uri(), :disable)}
|
{:delete, Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :disable)}
|
||||||
] do
|
] do
|
||||||
test "unauthorized call: #{method} #{url}", %{conn: conn} do
|
test "unauthorized call: #{method} #{url}", %{conn: conn} do
|
||||||
conn
|
conn
|
||||||
@ -44,7 +44,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
|
|||||||
site = Plausible.Repo.preload(site, :owner)
|
site = Plausible.Repo.preload(site, :owner)
|
||||||
insert(:growth_subscription, user: site.owner)
|
insert(:growth_subscription, user: site.owner)
|
||||||
|
|
||||||
url = Routes.custom_props_url(base_uri(), :enable)
|
url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)
|
||||||
|
|
||||||
payload = %{
|
payload = %{
|
||||||
custom_prop: %{key: "author"}
|
custom_prop: %{key: "author"}
|
||||||
@ -68,7 +68,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
|
|||||||
site = Plausible.Repo.preload(site, :owner)
|
site = Plausible.Repo.preload(site, :owner)
|
||||||
insert(:growth_subscription, user: site.owner)
|
insert(:growth_subscription, user: site.owner)
|
||||||
|
|
||||||
url = Routes.custom_props_url(base_uri(), :enable)
|
url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)
|
||||||
|
|
||||||
payload = %{
|
payload = %{
|
||||||
custom_props: [
|
custom_props: [
|
||||||
@ -92,7 +92,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
|
|||||||
|
|
||||||
describe "put /custom_prop - enable single prop" do
|
describe "put /custom_prop - enable single prop" do
|
||||||
test "validates input according to the schema", %{conn: conn, token: token, site: site} do
|
test "validates input according to the schema", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.custom_props_url(base_uri(), :enable)
|
url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> authenticate(site.domain, token)
|
|> authenticate(site.domain, token)
|
||||||
@ -103,7 +103,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "enables single custom prop", %{conn: conn, token: token, site: site} do
|
test "enables single custom prop", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.custom_props_url(base_uri(), :enable)
|
url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)
|
||||||
|
|
||||||
payload = %{
|
payload = %{
|
||||||
custom_prop: %{key: "author"}
|
custom_prop: %{key: "author"}
|
||||||
@ -130,7 +130,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "is idempotent", %{conn: conn, token: token, site: site} do
|
test "is idempotent", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.custom_props_url(base_uri(), :enable)
|
url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)
|
||||||
|
|
||||||
initial_conn =
|
initial_conn =
|
||||||
conn
|
conn
|
||||||
@ -166,7 +166,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
|
|||||||
|
|
||||||
describe "put /custom_props - bulk creation" do
|
describe "put /custom_props - bulk creation" do
|
||||||
test "creates many custom props", %{conn: conn, token: token, site: site} do
|
test "creates many custom props", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.custom_props_url(base_uri(), :enable)
|
url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)
|
||||||
|
|
||||||
payload = %{
|
payload = %{
|
||||||
custom_props: [
|
custom_props: [
|
||||||
@ -209,7 +209,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
|
|||||||
test "disable one prop", %{conn: conn, site: site, token: token} do
|
test "disable one prop", %{conn: conn, site: site, token: token} do
|
||||||
{:ok, ["author"]} = Plausible.Plugins.API.CustomProps.enable(site, "author")
|
{:ok, ["author"]} = Plausible.Plugins.API.CustomProps.enable(site, "author")
|
||||||
|
|
||||||
url = Routes.custom_props_url(base_uri(), :enable)
|
url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)
|
||||||
|
|
||||||
payload = %{custom_prop: %{key: "author"}}
|
payload = %{custom_prop: %{key: "author"}}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
|
|||||||
{:ok, [_, _, _]} =
|
{:ok, [_, _, _]} =
|
||||||
Plausible.Plugins.API.CustomProps.enable(site, ["author", "category", "third"])
|
Plausible.Plugins.API.CustomProps.enable(site, ["author", "category", "third"])
|
||||||
|
|
||||||
url = Routes.custom_props_url(base_uri(), :enable)
|
url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)
|
||||||
|
|
||||||
payload = %{
|
payload = %{
|
||||||
custom_props: [
|
custom_props: [
|
||||||
|
@ -30,11 +30,11 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
|
|
||||||
describe "unauthorized calls" do
|
describe "unauthorized calls" do
|
||||||
for {method, url} <- [
|
for {method, url} <- [
|
||||||
{:get, Routes.goals_url(base_uri(), :index)},
|
{:get, Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :index)},
|
||||||
{:get, Routes.goals_url(base_uri(), :get, 1)},
|
{:get, Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :get, 1)},
|
||||||
{:put, Routes.goals_url(base_uri(), :create, %{})},
|
{:put, Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create, %{})},
|
||||||
{:delete, Routes.goals_url(base_uri(), :delete, 1)},
|
{:delete, Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :delete, 1)},
|
||||||
{:delete, Routes.goals_url(base_uri(), :delete_bulk, %{})}
|
{:delete, Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :delete_bulk, %{})}
|
||||||
] do
|
] do
|
||||||
test "unauthorized call: #{method} #{url}", %{conn: conn} do
|
test "unauthorized call: #{method} #{url}", %{conn: conn} do
|
||||||
conn
|
conn
|
||||||
@ -55,7 +55,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
site = Plausible.Repo.preload(site, :owner)
|
site = Plausible.Repo.preload(site, :owner)
|
||||||
insert(:growth_subscription, user: site.owner)
|
insert(:growth_subscription, user: site.owner)
|
||||||
|
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
payload = %{
|
payload = %{
|
||||||
goal_type: "Goal.Revenue",
|
goal_type: "Goal.Revenue",
|
||||||
@ -81,7 +81,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
site = Plausible.Repo.preload(site, :owner)
|
site = Plausible.Repo.preload(site, :owner)
|
||||||
insert(:growth_subscription, user: site.owner)
|
insert(:growth_subscription, user: site.owner)
|
||||||
|
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
payload = %{
|
payload = %{
|
||||||
goals: [
|
goals: [
|
||||||
@ -111,7 +111,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
|
|
||||||
describe "put /goals - create a single goal" do
|
describe "put /goals - create a single goal" do
|
||||||
test "validates input according to the schema", %{conn: conn, token: token, site: site} do
|
test "validates input according to the schema", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> authenticate(site.domain, token)
|
|> authenticate(site.domain, token)
|
||||||
@ -122,7 +122,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "creates a custom event goal", %{conn: conn, token: token, site: site} do
|
test "creates a custom event goal", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
payload = %{goal_type: "Goal.CustomEvent", goal: %{event_name: "Signup"}}
|
payload = %{goal_type: "Goal.CustomEvent", goal: %{event_name: "Signup"}}
|
||||||
|
|
||||||
@ -146,14 +146,18 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
[location] = get_resp_header(conn, "location")
|
[location] = get_resp_header(conn, "location")
|
||||||
|
|
||||||
assert location ==
|
assert location ==
|
||||||
Routes.goals_url(base_uri(), :get, List.first(resp.goals).goal.id)
|
Routes.plugins_api_goals_url(
|
||||||
|
PlausibleWeb.Endpoint,
|
||||||
|
:get,
|
||||||
|
List.first(resp.goals).goal.id
|
||||||
|
)
|
||||||
|
|
||||||
assert [%{event_name: "Signup"}] = Plausible.Goals.for_site(site)
|
assert [%{event_name: "Signup"}] = Plausible.Goals.for_site(site)
|
||||||
end
|
end
|
||||||
|
|
||||||
@tag :full_build_only
|
@tag :full_build_only
|
||||||
test "creates a revenue goal", %{conn: conn, token: token, site: site} do
|
test "creates a revenue goal", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
payload = %{
|
payload = %{
|
||||||
goal_type: "Goal.Revenue",
|
goal_type: "Goal.Revenue",
|
||||||
@ -180,7 +184,11 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
[location] = get_resp_header(conn, "location")
|
[location] = get_resp_header(conn, "location")
|
||||||
|
|
||||||
assert location ==
|
assert location ==
|
||||||
Routes.goals_url(base_uri(), :get, List.first(resp.goals).goal.id)
|
Routes.plugins_api_goals_url(
|
||||||
|
PlausibleWeb.Endpoint,
|
||||||
|
:get,
|
||||||
|
List.first(resp.goals).goal.id
|
||||||
|
)
|
||||||
|
|
||||||
assert [%{event_name: "Purchase", currency: :EUR}] = Plausible.Goals.for_site(site)
|
assert [%{event_name: "Purchase", currency: :EUR}] = Plausible.Goals.for_site(site)
|
||||||
end
|
end
|
||||||
@ -191,7 +199,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
token: token,
|
token: token,
|
||||||
site: site
|
site: site
|
||||||
} do
|
} do
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
payload = %{
|
payload = %{
|
||||||
goal_type: "Goal.Revenue",
|
goal_type: "Goal.Revenue",
|
||||||
@ -220,7 +228,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
token: token,
|
token: token,
|
||||||
site: site
|
site: site
|
||||||
} do
|
} do
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
{:ok, _} = Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "USD"})
|
{:ok, _} = Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "USD"})
|
||||||
|
|
||||||
@ -240,7 +248,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "creates a pageview goal", %{conn: conn, token: token, site: site} do
|
test "creates a pageview goal", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
payload = %{goal_type: "Goal.Pageview", goal: %{path: "/checkout"}}
|
payload = %{goal_type: "Goal.Pageview", goal: %{path: "/checkout"}}
|
||||||
assert_request_schema(payload, "Goal.CreateRequest.Pageview", spec())
|
assert_request_schema(payload, "Goal.CreateRequest.Pageview", spec())
|
||||||
@ -263,13 +271,17 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
[location] = get_resp_header(conn, "location")
|
[location] = get_resp_header(conn, "location")
|
||||||
|
|
||||||
assert location ==
|
assert location ==
|
||||||
Routes.goals_url(base_uri(), :get, List.first(resp.goals).goal.id)
|
Routes.plugins_api_goals_url(
|
||||||
|
PlausibleWeb.Endpoint,
|
||||||
|
:get,
|
||||||
|
List.first(resp.goals).goal.id
|
||||||
|
)
|
||||||
|
|
||||||
assert [%{page_path: "/checkout"}] = Plausible.Goals.for_site(site)
|
assert [%{page_path: "/checkout"}] = Plausible.Goals.for_site(site)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "is idempotent", %{conn: conn, token: token, site: site} do
|
test "is idempotent", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
initial_conn =
|
initial_conn =
|
||||||
conn
|
conn
|
||||||
@ -296,7 +308,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
describe "put /goals - bulk creation" do
|
describe "put /goals - bulk creation" do
|
||||||
@tag :full_build_only
|
@tag :full_build_only
|
||||||
test "creates a goal of each type", %{conn: conn, token: token, site: site} do
|
test "creates a goal of each type", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
payload = %{
|
payload = %{
|
||||||
goals: [
|
goals: [
|
||||||
@ -330,9 +342,26 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
|
|
||||||
[l1, l2, l3] = get_resp_header(conn, "location")
|
[l1, l2, l3] = get_resp_header(conn, "location")
|
||||||
|
|
||||||
assert l1 == Routes.goals_url(base_uri(), :get, Enum.at(resp.goals, 0).goal.id)
|
assert l1 ==
|
||||||
assert l2 == Routes.goals_url(base_uri(), :get, Enum.at(resp.goals, 1).goal.id)
|
Routes.plugins_api_goals_url(
|
||||||
assert l3 == Routes.goals_url(base_uri(), :get, Enum.at(resp.goals, 2).goal.id)
|
PlausibleWeb.Endpoint,
|
||||||
|
:get,
|
||||||
|
Enum.at(resp.goals, 0).goal.id
|
||||||
|
)
|
||||||
|
|
||||||
|
assert l2 ==
|
||||||
|
Routes.plugins_api_goals_url(
|
||||||
|
PlausibleWeb.Endpoint,
|
||||||
|
:get,
|
||||||
|
Enum.at(resp.goals, 1).goal.id
|
||||||
|
)
|
||||||
|
|
||||||
|
assert l3 ==
|
||||||
|
Routes.plugins_api_goals_url(
|
||||||
|
PlausibleWeb.Endpoint,
|
||||||
|
:get,
|
||||||
|
Enum.at(resp.goals, 2).goal.id
|
||||||
|
)
|
||||||
|
|
||||||
assert Enum.count(resp.goals) == 3
|
assert Enum.count(resp.goals) == 3
|
||||||
|
|
||||||
@ -347,7 +376,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
# if this test fails due to implementation change, consider what to do with the pagination meta
|
# if this test fails due to implementation change, consider what to do with the pagination meta
|
||||||
# object returned in the response and also revise how funnels are created based on a list of goals
|
# object returned in the response and also revise how funnels are created based on a list of goals
|
||||||
# - the funnels creation endpoint will likely reuse this schema's constraints
|
# - the funnels creation endpoint will likely reuse this schema's constraints
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
payload =
|
payload =
|
||||||
Enum.map(1..9, fn i ->
|
Enum.map(1..9, fn i ->
|
||||||
@ -371,7 +400,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
|
|
||||||
@tag :full_build_only
|
@tag :full_build_only
|
||||||
test "is idempotent", %{conn: conn, token: token, site: site} do
|
test "is idempotent", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
initial_conn =
|
initial_conn =
|
||||||
conn
|
conn
|
||||||
@ -410,7 +439,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
token: token,
|
token: token,
|
||||||
site: site
|
site: site
|
||||||
} do
|
} do
|
||||||
url = Routes.goals_url(base_uri(), :create)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
initial_conn =
|
initial_conn =
|
||||||
conn
|
conn
|
||||||
@ -438,7 +467,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
|
|
||||||
describe "get /goals/:id" do
|
describe "get /goals/:id" do
|
||||||
test "validates input out of the box", %{conn: conn, token: token, site: site} do
|
test "validates input out of the box", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.goals_url(base_uri(), :get, "hello")
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :get, "hello")
|
||||||
|
|
||||||
resp =
|
resp =
|
||||||
conn
|
conn
|
||||||
@ -455,7 +484,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
{:ok, goal} =
|
{:ok, goal} =
|
||||||
Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "EUR"})
|
Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "EUR"})
|
||||||
|
|
||||||
url = Routes.goals_url(base_uri(), :get, goal.id)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :get, goal.id)
|
||||||
|
|
||||||
resp =
|
resp =
|
||||||
conn
|
conn
|
||||||
@ -473,7 +502,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
test "retrieves pageview goal by ID", %{conn: conn, site: site, token: token} do
|
test "retrieves pageview goal by ID", %{conn: conn, site: site, token: token} do
|
||||||
{:ok, goal} = Plausible.Goals.create(site, %{"page_path" => "/checkout"})
|
{:ok, goal} = Plausible.Goals.create(site, %{"page_path" => "/checkout"})
|
||||||
|
|
||||||
url = Routes.goals_url(base_uri(), :get, goal.id)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :get, goal.id)
|
||||||
|
|
||||||
resp =
|
resp =
|
||||||
conn
|
conn
|
||||||
@ -491,7 +520,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
test "retrieves custom event goal by ID", %{conn: conn, site: site, token: token} do
|
test "retrieves custom event goal by ID", %{conn: conn, site: site, token: token} do
|
||||||
{:ok, goal} = Plausible.Goals.create(site, %{"event_name" => "Signup"})
|
{:ok, goal} = Plausible.Goals.create(site, %{"event_name" => "Signup"})
|
||||||
|
|
||||||
url = Routes.goals_url(base_uri(), :get, goal.id)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :get, goal.id)
|
||||||
|
|
||||||
resp =
|
resp =
|
||||||
conn
|
conn
|
||||||
@ -513,7 +542,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
token: token,
|
token: token,
|
||||||
site: site
|
site: site
|
||||||
} do
|
} do
|
||||||
url = Routes.goals_url(base_uri(), :index)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :index)
|
||||||
|
|
||||||
resp =
|
resp =
|
||||||
conn
|
conn
|
||||||
@ -538,7 +567,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
{:ok, g2} = Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "EUR"})
|
{:ok, g2} = Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "EUR"})
|
||||||
{:ok, g3} = Plausible.Goals.create(site, %{"page_path" => "/checkout"})
|
{:ok, g3} = Plausible.Goals.create(site, %{"page_path" => "/checkout"})
|
||||||
|
|
||||||
url = Routes.goals_url(base_uri(), :index)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :index)
|
||||||
|
|
||||||
resp =
|
resp =
|
||||||
conn
|
conn
|
||||||
@ -570,7 +599,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
insert(:goal, site: site, event_name: "Goal #{i}")
|
insert(:goal, site: site, event_name: "Goal #{i}")
|
||||||
end
|
end
|
||||||
|
|
||||||
url = Routes.goals_url(base_uri(), :index, limit: 2)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :index, limit: 2)
|
||||||
|
|
||||||
initial_conn = authenticate(conn, site.domain, token)
|
initial_conn = authenticate(conn, site.domain, token)
|
||||||
|
|
||||||
@ -612,7 +641,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
{:ok, %{id: goal_id}} =
|
{:ok, %{id: goal_id}} =
|
||||||
Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "USD"})
|
Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "USD"})
|
||||||
|
|
||||||
url = Routes.goals_url(base_uri(), :delete, goal_id)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :delete, goal_id)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> authenticate(site.domain, token)
|
|> authenticate(site.domain, token)
|
||||||
@ -623,7 +652,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "is idempotent", %{conn: conn, site: site, token: token} do
|
test "is idempotent", %{conn: conn, site: site, token: token} do
|
||||||
url = Routes.goals_url(base_uri(), :delete, 666)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :delete, 666)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> authenticate(site.domain, token)
|
|> authenticate(site.domain, token)
|
||||||
@ -643,7 +672,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
|
|||||||
{:ok, g3} =
|
{:ok, g3} =
|
||||||
Plausible.Goals.create(site, %{"page_path" => "/home"})
|
Plausible.Goals.create(site, %{"page_path" => "/home"})
|
||||||
|
|
||||||
url = Routes.goals_url(base_uri(), :delete_bulk)
|
url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :delete_bulk)
|
||||||
|
|
||||||
payload = %{
|
payload = %{
|
||||||
goal_ids: [
|
goal_ids: [
|
||||||
|
@ -13,9 +13,9 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do
|
|||||||
|
|
||||||
describe "unauthorized calls" do
|
describe "unauthorized calls" do
|
||||||
for {method, url} <- [
|
for {method, url} <- [
|
||||||
{:get, Routes.shared_links_url(base_uri(), :get, 1)},
|
{:get, Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :get, 1)},
|
||||||
{:put, Routes.shared_links_url(base_uri(), :create)},
|
{:put, Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :create)},
|
||||||
{:get, Routes.shared_links_url(base_uri(), :index)}
|
{:get, Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :index)}
|
||||||
] do
|
] do
|
||||||
test "unauthorized call: #{method} #{url}", %{conn: conn} do
|
test "unauthorized call: #{method} #{url}", %{conn: conn} do
|
||||||
conn
|
conn
|
||||||
@ -28,7 +28,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do
|
|||||||
|
|
||||||
describe "get /shared_links/:id" do
|
describe "get /shared_links/:id" do
|
||||||
test "validates input out of the box", %{conn: conn, token: token, site: site} do
|
test "validates input out of the box", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.shared_links_url(base_uri(), :get, "hello")
|
url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :get, "hello")
|
||||||
|
|
||||||
resp =
|
resp =
|
||||||
conn
|
conn
|
||||||
@ -43,7 +43,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do
|
|||||||
test "retrieve shared link by ID", %{conn: conn, site: site, token: token} do
|
test "retrieve shared link by ID", %{conn: conn, site: site, token: token} do
|
||||||
shared_link = insert(:shared_link, name: "Some Link Name", site: site)
|
shared_link = insert(:shared_link, name: "Some Link Name", site: site)
|
||||||
|
|
||||||
url = Routes.shared_links_url(base_uri(), :get, shared_link.id)
|
url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :get, shared_link.id)
|
||||||
|
|
||||||
resp =
|
resp =
|
||||||
conn
|
conn
|
||||||
@ -61,7 +61,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "fails to retrieve non-existing link", %{conn: conn, site: site, token: token} do
|
test "fails to retrieve non-existing link", %{conn: conn, site: site, token: token} do
|
||||||
url = Routes.shared_links_url(base_uri(), :get, 666)
|
url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :get, 666)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> authenticate(site.domain, token)
|
|> authenticate(site.domain, token)
|
||||||
@ -72,7 +72,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do
|
|||||||
|
|
||||||
test "fails to retrieve link from another site", %{conn: conn, site: site, token: token} do
|
test "fails to retrieve link from another site", %{conn: conn, site: site, token: token} do
|
||||||
shared_link = insert(:shared_link, name: "Some Link Name", site: build(:site))
|
shared_link = insert(:shared_link, name: "Some Link Name", site: build(:site))
|
||||||
url = Routes.shared_links_url(base_uri(), :get, shared_link.id)
|
url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :get, shared_link.id)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> authenticate(site.domain, token)
|
|> authenticate(site.domain, token)
|
||||||
@ -88,7 +88,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do
|
|||||||
site: site,
|
site: site,
|
||||||
token: token
|
token: token
|
||||||
} do
|
} do
|
||||||
url = Routes.shared_links_url(base_uri(), :create)
|
url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
initial_conn = authenticate(conn, site.domain, token)
|
initial_conn = authenticate(conn, site.domain, token)
|
||||||
|
|
||||||
@ -114,7 +114,11 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do
|
|||||||
[location] = get_resp_header(conn, "location")
|
[location] = get_resp_header(conn, "location")
|
||||||
|
|
||||||
assert location ==
|
assert location ==
|
||||||
Routes.shared_links_url(base_uri(), :get, resp.shared_link.id)
|
Routes.plugins_api_shared_links_url(
|
||||||
|
PlausibleWeb.Endpoint,
|
||||||
|
:get,
|
||||||
|
resp.shared_link.id
|
||||||
|
)
|
||||||
|
|
||||||
assert ^resp =
|
assert ^resp =
|
||||||
initial_conn
|
initial_conn
|
||||||
@ -128,7 +132,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do
|
|||||||
site: site,
|
site: site,
|
||||||
token: token
|
token: token
|
||||||
} do
|
} do
|
||||||
url = Routes.shared_links_url(base_uri(), :create)
|
url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
initial_conn = authenticate(conn, site.domain, token)
|
initial_conn = authenticate(conn, site.domain, token)
|
||||||
|
|
||||||
@ -161,7 +165,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "validates input out of the box", %{conn: conn, token: token, site: site} do
|
test "validates input out of the box", %{conn: conn, token: token, site: site} do
|
||||||
url = Routes.shared_links_url(base_uri(), :create)
|
url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :create)
|
||||||
|
|
||||||
resp =
|
resp =
|
||||||
conn
|
conn
|
||||||
@ -181,7 +185,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do
|
|||||||
token: token,
|
token: token,
|
||||||
site: site
|
site: site
|
||||||
} do
|
} do
|
||||||
url = Routes.shared_links_url(base_uri(), :index)
|
url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :index)
|
||||||
|
|
||||||
resp =
|
resp =
|
||||||
conn
|
conn
|
||||||
@ -205,7 +209,8 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do
|
|||||||
insert(:shared_link, site: site, name: "Shared Link #{i}")
|
insert(:shared_link, site: site, name: "Shared Link #{i}")
|
||||||
end
|
end
|
||||||
|
|
||||||
url = Routes.shared_links_url(base_uri(), :index, limit: 2)
|
url =
|
||||||
|
Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :index, limit: 2)
|
||||||
|
|
||||||
initial_conn = authenticate(conn, site.domain, token)
|
initial_conn = authenticate(conn, site.domain, token)
|
||||||
|
|
||||||
|
@ -15,13 +15,12 @@ defmodule PlausibleWeb.PluginsAPICase do
|
|||||||
use Plausible.TestUtils
|
use Plausible.TestUtils
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
import Phoenix.ConnTest
|
import Phoenix.ConnTest
|
||||||
import PlausibleWeb.Plugins.API, only: [base_uri: 0]
|
|
||||||
import PlausibleWeb.Plugins.API.Spec, only: [spec: 0]
|
import PlausibleWeb.Plugins.API.Spec, only: [spec: 0]
|
||||||
import Plausible.Factory
|
import Plausible.Factory
|
||||||
|
|
||||||
import OpenApiSpex.TestAssertions
|
import OpenApiSpex.TestAssertions
|
||||||
|
|
||||||
alias PlausibleWeb.Plugins.API.Router.Helpers, as: Routes
|
alias PlausibleWeb.Router.Helpers, as: Routes
|
||||||
alias PlausibleWeb.Plugins.API.Schemas
|
alias PlausibleWeb.Plugins.API.Schemas
|
||||||
|
|
||||||
def authenticate(conn, domain, raw_token) do
|
def authenticate(conn, domain, raw_token) do
|
||||||
|
Loading…
Reference in New Issue
Block a user