build musl on develop
[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 Pleroma.PrometheusExporter.gather()
9
10 resp =
11 conn
12 |> get("/api/v1/akkoma/metrics")
13 |> text_response(200)
14
15 assert resp =~ "# HELP"
16 end
17
18 test "should not allow users that do not have the admin:metrics scope" do
19 %{conn: conn} = oauth_access(["read:metrics"])
20
21 conn
22 |> get("/api/v1/akkoma/metrics")
23 |> json_response(403)
24 end
25
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"])
29
30 conn
31 |> get("/api/v1/akkoma/metrics")
32 |> response(404)
33 end
34 end
35 end