summaryrefslogtreecommitdiff
path: root/test/web/plugs/federating_plug_test.exs
blob: 612db7e32e608cfeec6479bf04fda039e6140c11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Pleroma: A lightweight social networking server
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Web.FederatingPlugTest do
  use Pleroma.Web.ConnCase

  test "returns and halt the conn when federating is disabled" do
    instance =
      Application.get_env(:pleroma, :instance)
      |> Keyword.put(:federating, false)

    Application.put_env(:pleroma, :instance, instance)

    conn =
      build_conn()
      |> Pleroma.Web.FederatingPlug.call(%{})

    assert conn.status == 404
    assert conn.halted

    instance =
      Application.get_env(:pleroma, :instance)
      |> Keyword.put(:federating, true)

    Application.put_env(:pleroma, :instance, instance)
  end

  test "does nothing when federating is enabled" do
    conn =
      build_conn()
      |> Pleroma.Web.FederatingPlug.call(%{})

    refute conn.status
    refute conn.halted
  end
end