1 defmodule Pleroma.Web.AkkomaAPI.MetricsControllerTest do
2 use Pleroma.Web.ConnCase, async: true
4 describe "GET /api/v1/akkoma/metrics" do
5 test "should return metrics when the user has admin:metrics" do
6 %{conn: conn} = oauth_access(["admin:metrics"])
8 Pleroma.PrometheusExporter.gather()
12 |> get("/api/v1/akkoma/metrics")
15 assert resp =~ "# HELP"
18 test "should not allow users that do not have the admin:metrics scope" do
19 %{conn: conn} = oauth_access(["read:metrics"])
22 |> get("/api/v1/akkoma/metrics")
26 test "should be disabled by export_prometheus_metrics" do
27 clear_config([:instance, :export_prometheus_metrics], false)
28 %{conn: conn} = oauth_access(["admin:metrics"])
31 |> get("/api/v1/akkoma/metrics")