From ff7ce9a9fb567380219f6c5b334fdb22ced5e726 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 15 Dec 2018 15:58:51 +0100 Subject: [PATCH 1/2] config/config.exs: Add application/jrd+json => jrd+json to fix webfinger Closes: https://git.pleroma.social/pleroma/pleroma/merge_requests/551 --- config/config.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.exs b/config/config.exs index 1401b0a3d..1777a54c0 100644 --- a/config/config.exs +++ b/config/config.exs @@ -65,6 +65,7 @@ config :mime, :types, %{ "application/xml" => ["xml"], "application/xrd+xml" => ["xrd+xml"], + "application/jrd+json" => ["jrd+json"], "application/activity+json" => ["activity+json"], "application/ld+json" => ["activity+json"] } From 5af91020f83acf3acad8511799e4b4e9ecda5b76 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 15 Dec 2018 16:17:44 +0100 Subject: [PATCH 2/2] Web.WebFinger.WebFingerControllerTest: test against XML and JRD webfinger endpoints --- .../web_finger/web_finger_controller_test.exs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/web/web_finger/web_finger_controller_test.exs 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 index 000000000..cac003e76 --- /dev/null +++ b/test/web/web_finger/web_finger_controller_test.exs @@ -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