X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fakkoma_api%2Fmetrics_controller_test.exs;h=9482f1312d250e39348a2183e81565a1bcfc6ea5;hb=ca70d42541d4a17d5015df011a92b4e8db18a18a;hp=4b7214e6f689e61108a1294d8f9fadfe3810e8a9;hpb=6d8e4d5e05fcd0729d4639bd96d0f63268f26054;p=akkoma diff --git a/test/pleroma/web/akkoma_api/metrics_controller_test.exs b/test/pleroma/web/akkoma_api/metrics_controller_test.exs index 4b7214e6f..9482f1312 100644 --- a/test/pleroma/web/akkoma_api/metrics_controller_test.exs +++ b/test/pleroma/web/akkoma_api/metrics_controller_test.exs @@ -1,24 +1,33 @@ 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) + + 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 + + conn |> get("/api/v1/akkoma/metrics") |> json_response(403) end + + test "should be disabled by export_prometheus_metrics" do + clear_config([:instance, :export_prometheus_metrics], false) + %{conn: conn} = oauth_access(["admin:metrics"]) + + conn + |> get("/api/v1/akkoma/metrics") + |> response(404) + end end end