X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fweb_finger%2Fweb_finger_controller_test.exs;h=0023f1e810e4cee2bed55d0cc49f73b51fe9f334;hb=643664d58365c88beb8a6da9c02a15ec6c8ef48d;hp=43fccfc7ab5241f948027589d807d9b66c821a94;hpb=627e5a0a4992cc19fc65a7e93a09c470c8e2bf33;p=akkoma
diff --git a/test/web/web_finger/web_finger_controller_test.exs b/test/web/web_finger/web_finger_controller_test.exs
index 43fccfc7a..0023f1e81 100644
--- a/test/web/web_finger/web_finger_controller_test.exs
+++ b/test/web/web_finger/web_finger_controller_test.exs
@@ -1,10 +1,11 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
use Pleroma.Web.ConnCase
+ import ExUnit.CaptureLog
import Pleroma.Factory
import Tesla.Mock
@@ -13,6 +14,21 @@ defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
:ok
end
+ setup_all do: clear_config([:instance, :federating], true)
+
+ test "GET host-meta" do
+ response =
+ build_conn()
+ |> get("/.well-known/host-meta")
+
+ assert response.status == 200
+
+ assert response.resp_body ==
+ ~s()
+ end
+
test "Webfinger JRD" do
user = insert(:user)
@@ -24,6 +40,16 @@ defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
assert json_response(response, 200)["subject"] == "acct:#{user.nickname}@localhost"
end
+ test "it returns 404 when user isn't found (JSON)" do
+ result =
+ build_conn()
+ |> put_req_header("accept", "application/jrd+json")
+ |> get("/.well-known/webfinger?resource=acct:jimm@localhost")
+ |> json_response(404)
+
+ assert result == "Couldn't find user"
+ end
+
test "Webfinger XML" do
user = insert(:user)
@@ -35,6 +61,28 @@ defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
assert response(response, 200)
end
+ test "it returns 404 when user isn't found (XML)" do
+ result =
+ build_conn()
+ |> put_req_header("accept", "application/xrd+xml")
+ |> get("/.well-known/webfinger?resource=acct:jimm@localhost")
+ |> response(404)
+
+ assert result == "Couldn't find user"
+ end
+
+ test "Sends a 404 when invalid format" do
+ user = insert(:user)
+
+ assert capture_log(fn ->
+ assert_raise Phoenix.NotAcceptableError, fn ->
+ build_conn()
+ |> put_req_header("accept", "text/html")
+ |> get("/.well-known/webfinger?resource=acct:#{user.nickname}@localhost")
+ end
+ end) =~ "no supported media type in accept header"
+ end
+
test "Sends a 400 when resource param is missing" do
response =
build_conn()