2018-05-17 11:32:23 +02:00
|
|
|
defmodule Eventos.Service.WebFingerTest do
|
|
|
|
use Eventos.DataCase
|
|
|
|
alias Eventos.Service.WebFinger
|
|
|
|
import Eventos.Factory
|
|
|
|
|
|
|
|
describe "host meta" do
|
|
|
|
test "returns a link to the xml lrdd" do
|
|
|
|
host_info = WebFinger.host_meta()
|
|
|
|
|
|
|
|
assert String.contains?(host_info, EventosWeb.Endpoint.url())
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "incoming webfinger request" do
|
|
|
|
test "works for fqns" do
|
2018-06-14 17:25:55 +02:00
|
|
|
actor = insert(:actor)
|
2018-05-17 11:32:23 +02:00
|
|
|
|
|
|
|
{:ok, result} =
|
2018-06-14 17:25:55 +02:00
|
|
|
WebFinger.webfinger("#{actor.preferred_username}@#{EventosWeb.Endpoint.host()}", "JSON")
|
2018-07-27 10:45:35 +02:00
|
|
|
|
2018-05-17 11:32:23 +02:00
|
|
|
assert is_map(result)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "works for urls" do
|
2018-06-14 17:25:55 +02:00
|
|
|
actor = insert(:actor)
|
2018-05-17 11:32:23 +02:00
|
|
|
|
2018-06-14 17:25:55 +02:00
|
|
|
{:ok, result} = WebFinger.webfinger(actor.url, "JSON")
|
2018-05-17 11:32:23 +02:00
|
|
|
assert is_map(result)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "fingering" do
|
2018-06-14 17:25:55 +02:00
|
|
|
test "a mastodon actor" do
|
|
|
|
actor = "tcit@social.tcit.fr"
|
2018-05-17 11:32:23 +02:00
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
assert {:ok, %{"subject" => "acct:" <> actor, "url" => "https://social.tcit.fr/users/tcit"}} =
|
|
|
|
WebFinger.finger(actor)
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
|
2018-06-14 17:25:55 +02:00
|
|
|
test "a pleroma actor" do
|
|
|
|
actor = "@lain@pleroma.soykaf.com"
|
2018-05-17 11:32:23 +02:00
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
assert {:ok,
|
|
|
|
%{"subject" => "acct:" <> actor, "url" => "https://pleroma.soykaf.com/users/lain"}} =
|
|
|
|
WebFinger.finger(actor)
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
|
2018-06-14 17:25:55 +02:00
|
|
|
test "a peertube actor" do
|
|
|
|
actor = "framasoft@framatube.org"
|
2018-05-17 11:32:23 +02:00
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
assert {:ok,
|
|
|
|
%{
|
|
|
|
"subject" => "acct:" <> actor,
|
|
|
|
"url" => "https://framatube.org/accounts/framasoft"
|
|
|
|
}} = WebFinger.finger(actor)
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
|
2018-06-14 17:25:55 +02:00
|
|
|
test "a friendica actor" do
|
2018-10-09 16:07:31 +02:00
|
|
|
# Now with ActivityPub !
|
2018-06-14 17:25:55 +02:00
|
|
|
actor = "lain@squeet.me"
|
2018-05-17 11:32:23 +02:00
|
|
|
|
2018-10-09 16:07:31 +02:00
|
|
|
assert {:ok,
|
|
|
|
%{
|
|
|
|
"subject" => "acct:" <> actor,
|
|
|
|
"url" => "https://squeet.me/profile/lain"
|
|
|
|
}} = WebFinger.finger(actor)
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|