Web.WebFinger.WebFingerControllerTest: test against XML and JRD webfinger endpoints
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sat, 15 Dec 2018 15:17:44 +0000 (16:17 +0100)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sat, 15 Dec 2018 15:17:44 +0000 (16:17 +0100)
test/web/web_finger/web_finger_controller_test.exs [new file with mode: 0644]

diff --git a/test/web/web_finger/web_finger_controller_test.exs b/test/web/web_finger/web_finger_controller_test.exs
new file mode 100644 (file)
index 0000000..cac003e
--- /dev/null
@@ -0,0 +1,37 @@
+defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
+  use Pleroma.Web.ConnCase
+
+  alias Pleroma.User
+  alias Pleroma.Web.WebFinger.WebFingerController
+
+  import Pleroma.Factory
+  import ExUnit.CaptureLog
+  import Tesla.Mock
+
+  setup do
+    mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
+    :ok
+  end
+
+  test "Webfinger JRD" do
+    user = insert(:user)
+
+    response =
+      build_conn()
+      |> put_req_header("accept", "application/jrd+json")
+      |> get("/.well-known/webfinger?resource=acct:#{user.nickname}@localhost")
+
+    assert json_response(response, 200)["subject"] == "acct:#{user.nickname}@localhost"
+  end
+
+  test "Webfinger XML" do
+    user = insert(:user)
+
+    response =
+      build_conn()
+      |> put_req_header("accept", "application/jrd+json")
+      |> get("/.well-known/webfinger?resource=acct:#{user.nickname}@localhost")
+
+    assert response(response, 200)
+  end
+end