tests: add legal boilerplate
[akkoma] / test / web / node_info_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.NodeInfoTest do
6 use Pleroma.Web.ConnCase
7
8 import Pleroma.Factory
9
10 test "nodeinfo shows staff accounts", %{conn: conn} do
11 user = insert(:user, %{local: true, info: %{is_moderator: true}})
12
13 conn =
14 conn
15 |> get("/nodeinfo/2.0.json")
16
17 assert result = json_response(conn, 200)
18
19 assert user.ap_id in result["metadata"]["staffAccounts"]
20 end
21
22 test "returns 404 when federation is disabled", %{conn: conn} do
23 instance =
24 Application.get_env(:pleroma, :instance)
25 |> Keyword.put(:federating, false)
26
27 Application.put_env(:pleroma, :instance, instance)
28
29 conn
30 |> get("/.well-known/nodeinfo")
31 |> json_response(404)
32
33 conn
34 |> get("/nodeinfo/2.0.json")
35 |> json_response(404)
36
37 instance =
38 Application.get_env(:pleroma, :instance)
39 |> Keyword.put(:federating, true)
40
41 Application.put_env(:pleroma, :instance, instance)
42 end
43
44 test "returns 200 when federation is enabled", %{conn: conn} do
45 conn
46 |> get("/.well-known/nodeinfo")
47 |> json_response(200)
48
49 conn
50 |> get("/nodeinfo/2.0.json")
51 |> json_response(200)
52 end
53 end