Merge branch 'remove-avatar-header' into 'develop'
[akkoma] / test / web / plugs / federating_plug_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.FederatingPlugTest do
6 use Pleroma.Web.ConnCase
7
8 setup_all do
9 config_path = [:instance, :federating]
10 initial_setting = Pleroma.Config.get(config_path)
11
12 on_exit(fn -> Pleroma.Config.put(config_path, initial_setting) end)
13
14 :ok
15 end
16
17 test "returns and halt the conn when federating is disabled" do
18 Pleroma.Config.put([:instance, :federating], false)
19
20 conn =
21 build_conn()
22 |> Pleroma.Web.FederatingPlug.call(%{})
23
24 assert conn.status == 404
25 assert conn.halted
26 end
27
28 test "does nothing when federating is enabled" do
29 Pleroma.Config.put([:instance, :federating], true)
30
31 conn =
32 build_conn()
33 |> Pleroma.Web.FederatingPlug.call(%{})
34
35 refute conn.status
36 refute conn.halted
37 end
38 end