1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-23 00:14:48 +00:00
mobilizon/test/web/controllers/webfinger_controller_test.exs

49 lines
1.7 KiB
Elixir
Raw Normal View History

# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# SPDX-License-Identifier: AGPL-3.0-only
# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/test/web/web_finger/web_finger_test.exs
2020-01-26 20:36:50 +00:00
defmodule Mobilizon.Web.WebFingerControllerTest do
use Mobilizon.Web.ConnCase
2020-01-22 01:14:42 +00:00
import Mobilizon.Factory
2020-01-22 01:14:42 +00:00
alias Mobilizon.Actors.Actor
alias Mobilizon.Federation.WebFinger
2020-01-22 01:14:42 +00:00
alias Mobilizon.Web.Endpoint
setup_all do
Mobilizon.Config.put([:instance, :federating], true)
2020-01-22 01:14:42 +00:00
:ok
end
test "GET /.well-known/host-meta", %{conn: conn} do
conn = get(conn, "/.well-known/host-meta")
assert response(conn, 200) ==
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\"><Link rel=\"lrdd\" template=\"#{
Endpoint.url()
}/.well-known/webfinger?resource={uri}\" type=\"application/xrd+xml\" /></XRD>"
assert {"content-type", "application/xrd+xml; charset=utf-8"} in conn.resp_headers
end
test "GET /.well-known/webfinger with local actor", %{conn: conn} do
%Actor{preferred_username: username} = actor = insert(:actor)
conn = get(conn, "/.well-known/webfinger?resource=acct:#{username}@mobilizon.test")
assert json_response(conn, 200) == WebFinger.represent_actor(actor)
end
test "GET /.well-known/webfinger with non existent actor", %{conn: conn} do
conn = get(conn, "/.well-known/webfinger?resource=acct:notme@mobilizon.test")
assert response(conn, 404) == "Couldn't find user"
end
test "GET /.well-known/webfinger with no query", %{conn: conn} do
conn = get(conn, "/.well-known/webfinger")
assert response(conn, 400) == "No query provided"
end
end