mix format
[akkoma] / test / pleroma / web / akkoma_api / metrics_controller_test.exs
1 defmodule Pleroma.Web.AkkomaAPI.MetricsControllerTest do
2 use Pleroma.Web.ConnCase, async: true
3
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"])
7
8 resp =
9 conn
10 |> get("/api/v1/akkoma/metrics")
11 |> text_response(200)
12
13 assert resp =~ "# HELP"
14 end
15
16 test "should not allow users that do not have the admin:metrics scope" do
17 %{conn: conn} = oauth_access(["read:metrics"])
18
19 conn
20 |> get("/api/v1/akkoma/metrics")
21 |> json_response(403)
22 end
23
24 test "should be disabled by export_prometheus_metrics" do
25 clear_config([:instance, :export_prometheus_metrics], false)
26 %{conn: conn} = oauth_access(["admin:metrics"])
27
28 conn
29 |> get("/api/v1/akkoma/metrics")
30 |> response(404)
31 end
32 end
33 end