format
[akkoma] / test / web / activity_pub / activity_pub_controller_test.exs
index e63cd65839cddde275c42510e84e6636e6801c51..f22975f861979355051554857629df5a9a931328 100644 (file)
@@ -5,6 +5,36 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
   alias Pleroma.{Repo, User}
   alias Pleroma.Activity
 
+  describe "/relay" do
+    test "with the relay active, it returns the relay user", %{conn: conn} do
+      res =
+        conn
+        |> get(activity_pub_path(conn, :relay))
+        |> json_response(200)
+
+      assert res["id"] =~ "/relay"
+    end
+
+    test "with the relay disabled, it returns 404", %{conn: conn} do
+      instance =
+        Application.get_env(:pleroma, :instance)
+        |> Keyword.put(:allow_relay, false)
+
+      Application.put_env(:pleroma, :instance, instance)
+
+      res =
+        conn
+        |> get(activity_pub_path(conn, :relay))
+        |> json_response(404)
+
+      instance =
+        Application.get_env(:pleroma, :instance)
+        |> Keyword.put(:allow_relay, true)
+
+      Application.put_env(:pleroma, :instance, instance)
+    end
+  end
+
   describe "/users/:nickname" do
     test "it returns a json representation of the user", %{conn: conn} do
       user = insert(:user)