From 75cfd9d34dc4be83a1ad4329f93d5121a7968b09 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 21 May 2018 12:38:12 +0000 Subject: [PATCH] webfinger: fix finding the XRD uri for statusnet instances --- lib/pleroma/web/web_finger/web_finger.ex | 2 +- .../fixtures/httpoison_mock/status.alpicola.com_host_meta | 2 ++ test/support/httpoison_mock.ex | 8 ++++++++ test/web/web_finger/web_finger_test.exs | 6 ++++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/httpoison_mock/status.alpicola.com_host_meta diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex index 6e5fc1401..9c6f1cb68 100644 --- a/lib/pleroma/web/web_finger/web_finger.ex +++ b/lib/pleroma/web/web_finger/web_finger.ex @@ -214,7 +214,7 @@ defp webfinger_from_json(doc) do end def get_template_from_xml(body) do - xpath = "//Link[@rel='lrdd' and @type='application/xrd+xml']/@template" + xpath = "//Link[@rel='lrdd']/@template" with doc when doc != :error <- XML.parse_document(body), template when template != nil <- XML.string_from_xpath(xpath, doc) do diff --git a/test/fixtures/httpoison_mock/status.alpicola.com_host_meta b/test/fixtures/httpoison_mock/status.alpicola.com_host_meta new file mode 100644 index 000000000..6948c30ea --- /dev/null +++ b/test/fixtures/httpoison_mock/status.alpicola.com_host_meta @@ -0,0 +1,2 @@ + +status.alpicola.comResource Descriptor \ No newline at end of file diff --git a/test/support/httpoison_mock.ex b/test/support/httpoison_mock.ex index f28557975..6e8336a93 100644 --- a/test/support/httpoison_mock.ex +++ b/test/support/httpoison_mock.ex @@ -531,6 +531,14 @@ def get("http://social.heldscal.la/.well-known/host-meta", [], follow_redirect: }} end + def get("http://status.alpicola.com/.well-known/host-meta", [], follow_redirect: true) do + {:ok, + %Response{ + status_code: 200, + body: File.read!("test/fixtures/httpoison_mock/status.alpicola.com_host_meta") + }} + end + def get("http://macgirvin.com/.well-known/host-meta", [], follow_redirect: true) do {:ok, %Response{ diff --git a/test/web/web_finger/web_finger_test.exs b/test/web/web_finger/web_finger_test.exs index 2d6ff2656..99bf210ea 100644 --- a/test/web/web_finger/web_finger_test.exs +++ b/test/web/web_finger/web_finger_test.exs @@ -88,6 +88,12 @@ test "it gets the xrd endpoint for hubzilla" do assert template == "https://macgirvin.com/xrd/?uri={uri}" end + + test "it gets the xrd endpoint for statusnet" do + {:ok, template} = WebFinger.find_lrdd_template("status.alpicola.com") + + assert template == "http://status.alpicola.com/main/xrd?uri={uri}" + end end describe "ensure_keys_present" do