akkoma/test/pleroma/web/akkoma_api/metrics_controller_test.exs
2022-12-16 10:56:17 +00:00

25 lines
695 B
Elixir

defmodule Pleroma.Web.AkkomaAPI.MetricsControllerTest do
use Pleroma.Web.ConnCase, async: true
import Pleroma.Factory
alias Pleroma.Akkoma.FrontendSettingsProfile
describe "GET /api/v1/akkoma/metrics" do
test "should return metrics when the user has admin:metrics" do
%{conn: conn} = oauth_access(["admin:metrics"])
resp = conn
|> get("/api/v1/akkoma/metrics")
|> text_response(200)
assert resp =~ "# HELP"
end
test "should not allow users that do not have the admin:metrics scope" do
%{conn: conn} = oauth_access(["read:metrics"])
resp = conn
|> get("/api/v1/akkoma/metrics")
|> json_response(403)
end
end
end