alias Pleroma.Web.Plugs.OAuthScopesPlug
alias Pleroma.Web.Plugs.PlugHelper
+ @mix_env Mix.env()
+
def controller do
quote do
use Phoenix.Controller, namespace: Pleroma.Web
def get_api_routes do
Pleroma.Web.Router.__routes__()
- |> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
+ |> Enum.reject(fn
+ r ->
+ r.plug == Pleroma.Web.Fallback.RedirectController or
+ String.starts_with?(r.path, "/#{@mix_env}")
+ end)
|> Enum.map(fn r ->
r.path
|> String.split("/", trim: true)
assert %Plug.Conn{status: :success} = get(conn, url)
end
end
+
+ test "api routes are detected correctly" do
+ expected_routes = [
+ "api",
+ "main",
+ "ostatus_subscribe",
+ "oauth",
+ "objects",
+ "activities",
+ "notice",
+ "users",
+ "tags",
+ "mailer",
+ "inbox",
+ "relay",
+ "internal",
+ ".well-known",
+ "nodeinfo",
+ "web",
+ "auth",
+ "embed",
+ "proxy",
+ "user_exists",
+ "check_password"
+ ]
+
+ assert expected_routes == Pleroma.Web.get_api_routes()
+ end
end