@@ -4,7 +4,6 @@
|
||||
# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/test/web/activity_pub/activity_pub_test.exs
|
||||
|
||||
defmodule Mobilizon.Federation.ActivityPubTest do
|
||||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
||||
use Mobilizon.DataCase
|
||||
|
||||
import Mock
|
||||
|
||||
@@ -9,6 +9,8 @@ defmodule Mobilizon.Federation.ActivityPub.ActorTest do
|
||||
alias Mobilizon.Federation.ActivityPub.Actor, as: ActivityPubActor
|
||||
alias Mobilizon.Federation.ActivityPub.Relay
|
||||
alias Mobilizon.Service.HTTP.ActivityPub.Mock
|
||||
alias Mobilizon.Service.HTTP.HostMetaClient.Mock, as: HostMetaClientMock
|
||||
alias Mobilizon.Service.HTTP.WebfingerClient.Mock, as: WebfingerClientMock
|
||||
|
||||
describe "fetching actor from its url" do
|
||||
@actor_url "https://framapiaf.org/users/tcit"
|
||||
@@ -26,6 +28,27 @@ defmodule Mobilizon.Federation.ActivityPub.ActorTest do
|
||||
{:ok, %Tesla.Env{status: 200, body: actor_data}}
|
||||
end)
|
||||
|
||||
HostMetaClientMock
|
||||
|> expect(:call, fn
|
||||
%{method: :get, url: "http://framapiaf.org/.well-known/host-meta"}, _opts ->
|
||||
{:ok, %Tesla.Env{status: 404, body: ""}}
|
||||
end)
|
||||
|
||||
webfinger_data =
|
||||
File.read!("test/fixtures/webfinger/mastodon-webfinger.json")
|
||||
|> String.replace("social.tcit.fr", "framapiaf.org")
|
||||
|> Jason.decode!()
|
||||
|
||||
WebfingerClientMock
|
||||
|> expect(:call, fn
|
||||
%{
|
||||
method: :get,
|
||||
url: "http://framapiaf.org/.well-known/webfinger?resource=acct:tcit@framapiaf.org"
|
||||
},
|
||||
_opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: webfinger_data}}
|
||||
end)
|
||||
|
||||
assert {:ok,
|
||||
%Actor{preferred_username: "tcit", domain: "framapiaf.org", visibility: :public} =
|
||||
_actor} = ActivityPubActor.make_actor_from_nickname("tcit@framapiaf.org")
|
||||
@@ -44,6 +67,27 @@ defmodule Mobilizon.Federation.ActivityPub.ActorTest do
|
||||
{:ok, %Tesla.Env{status: 200, body: actor_data}}
|
||||
end)
|
||||
|
||||
HostMetaClientMock
|
||||
|> expect(:call, fn
|
||||
%{method: :get, url: "http://framapiaf.org/.well-known/host-meta"}, _opts ->
|
||||
{:ok, %Tesla.Env{status: 404, body: ""}}
|
||||
end)
|
||||
|
||||
webfinger_data =
|
||||
File.read!("test/fixtures/webfinger/mastodon-webfinger.json")
|
||||
|> String.replace("social.tcit.fr", "framapiaf.org")
|
||||
|> Jason.decode!()
|
||||
|
||||
WebfingerClientMock
|
||||
|> expect(:call, fn
|
||||
%{
|
||||
method: :get,
|
||||
url: "http://framapiaf.org/.well-known/webfinger?resource=acct:tcit@framapiaf.org"
|
||||
},
|
||||
_opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: webfinger_data}}
|
||||
end)
|
||||
|
||||
assert {:ok,
|
||||
%Actor{preferred_username: "tcit", domain: "framapiaf.org", visibility: :unlisted} =
|
||||
_actor} = ActivityPubActor.make_actor_from_nickname("tcit@framapiaf.org")
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.DeleteTest do
|
||||
use Mobilizon.DataCase
|
||||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
||||
use Oban.Testing, repo: Mobilizon.Storage.Repo
|
||||
import Mobilizon.Factory
|
||||
import Mox
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
defmodule Mobilizon.Federation.ActivityPub.UtilsTest do
|
||||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
||||
|
||||
use Mobilizon.DataCase
|
||||
|
||||
import Mobilizon.Factory
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/test/web/web_finger/web_finger_test.exs
|
||||
|
||||
defmodule Mobilizon.Federation.WebFingerTest do
|
||||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
||||
use Mobilizon.DataCase
|
||||
|
||||
import Mox
|
||||
import Mobilizon.Factory
|
||||
|
||||
alias Mobilizon.Federation.WebFinger
|
||||
|
||||
alias Mobilizon.Service.HTTP.HostMetaClient.Mock, as: HostMetaClientMock
|
||||
alias Mobilizon.Service.HTTP.WebfingerClient.Mock, as: WebfingerClientMock
|
||||
alias Mobilizon.Web.Endpoint
|
||||
|
||||
@mastodon_account "tcit@social.tcit.fr"
|
||||
@@ -21,6 +21,8 @@ defmodule Mobilizon.Federation.WebFingerTest do
|
||||
@peertube_account_username "framasoft"
|
||||
@friendica_account "lain@squeet.me"
|
||||
@friendica_account_username "lain"
|
||||
@gancio_account "gancio@demo.gancio.org"
|
||||
@gancio_account_username "gancio"
|
||||
|
||||
describe "host meta" do
|
||||
test "returns a link to the xml lrdd" do
|
||||
@@ -53,35 +55,140 @@ defmodule Mobilizon.Federation.WebFingerTest do
|
||||
|
||||
describe "fingering" do
|
||||
test "a mastodon actor" do
|
||||
use_cassette "webfinger/mastodon" do
|
||||
res = "https://social.tcit.fr/users/#{@mastodon_account_username}"
|
||||
host_meta_xml = File.read!("test/fixtures/webfinger/mastodon-host-meta.xml")
|
||||
|
||||
assert {:ok, res} == WebFinger.finger(@mastodon_account)
|
||||
end
|
||||
webfinger_data =
|
||||
File.read!("test/fixtures/webfinger/mastodon-webfinger.json") |> Jason.decode!()
|
||||
|
||||
WebfingerClientMock
|
||||
|> expect(:call, fn
|
||||
%{
|
||||
method: :get,
|
||||
url: "https://social.tcit.fr/.well-known/webfinger?resource=acct:tcit@social.tcit.fr"
|
||||
},
|
||||
_opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: webfinger_data}}
|
||||
end)
|
||||
|
||||
HostMetaClientMock
|
||||
|> expect(:call, fn
|
||||
%{method: :get, url: "http://social.tcit.fr/.well-known/host-meta"}, _opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: host_meta_xml}}
|
||||
end)
|
||||
|
||||
res = "https://social.tcit.fr/users/#{@mastodon_account_username}"
|
||||
|
||||
assert {:ok, res} == WebFinger.finger(@mastodon_account)
|
||||
end
|
||||
|
||||
test "a pleroma actor" do
|
||||
use_cassette "webfinger/pleroma" do
|
||||
res = "https://pleroma.soykaf.com/users/#{@pleroma_account_username}"
|
||||
host_meta_xml = File.read!("test/fixtures/webfinger/pleroma-host-meta.xml")
|
||||
|
||||
assert {:ok, res} == WebFinger.finger(@pleroma_account)
|
||||
end
|
||||
webfinger_data =
|
||||
File.read!("test/fixtures/webfinger/pleroma-webfinger.json") |> Jason.decode!()
|
||||
|
||||
WebfingerClientMock
|
||||
|> expect(:call, fn
|
||||
%{
|
||||
method: :get,
|
||||
url:
|
||||
"https://pleroma.soykaf.com/.well-known/webfinger?resource=acct:lain@pleroma.soykaf.com"
|
||||
},
|
||||
_opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: webfinger_data}}
|
||||
end)
|
||||
|
||||
HostMetaClientMock
|
||||
|> expect(:call, fn
|
||||
%{method: :get, url: "http://pleroma.soykaf.com/.well-known/host-meta"}, _opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: host_meta_xml}}
|
||||
end)
|
||||
|
||||
res = "https://pleroma.soykaf.com/users/#{@pleroma_account_username}"
|
||||
|
||||
assert {:ok, res} == WebFinger.finger(@pleroma_account)
|
||||
end
|
||||
|
||||
test "a peertube actor" do
|
||||
use_cassette "webfinger/peertube" do
|
||||
res = "https://framatube.org/accounts/#{@peertube_account_username}"
|
||||
host_meta_xml = File.read!("test/fixtures/webfinger/peertube-host-meta.xml")
|
||||
|
||||
assert {:ok, res} == WebFinger.finger(@peertube_account)
|
||||
end
|
||||
webfinger_data =
|
||||
File.read!("test/fixtures/webfinger/peertube-webfinger.json") |> Jason.decode!()
|
||||
|
||||
WebfingerClientMock
|
||||
|> expect(:call, fn
|
||||
%{
|
||||
method: :get,
|
||||
url: "https://framatube.org/.well-known/webfinger?resource=acct:framasoft@framatube.org"
|
||||
},
|
||||
_opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: webfinger_data}}
|
||||
end)
|
||||
|
||||
HostMetaClientMock
|
||||
|> expect(:call, fn
|
||||
%{method: :get, url: "http://framatube.org/.well-known/host-meta"}, _opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: host_meta_xml}}
|
||||
end)
|
||||
|
||||
res = "https://framatube.org/accounts/#{@peertube_account_username}"
|
||||
|
||||
assert {:ok, res} == WebFinger.finger(@peertube_account)
|
||||
end
|
||||
|
||||
test "a friendica actor" do
|
||||
use_cassette "webfinger/friendica" do
|
||||
res = "https://squeet.me/profile/#{@friendica_account_username}"
|
||||
host_meta_xml = File.read!("test/fixtures/webfinger/friendica-host-meta.xml")
|
||||
|
||||
assert {:ok, res} == WebFinger.finger(@friendica_account)
|
||||
end
|
||||
webfinger_data =
|
||||
File.read!("test/fixtures/webfinger/friendica-webfinger.json") |> Jason.decode!()
|
||||
|
||||
WebfingerClientMock
|
||||
|> expect(:call, fn
|
||||
%{
|
||||
method: :get,
|
||||
url: "https://squeet.me/.well-known/webfinger?resource=acct:lain@squeet.me"
|
||||
},
|
||||
_opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: webfinger_data}}
|
||||
end)
|
||||
|
||||
HostMetaClientMock
|
||||
|> expect(:call, fn
|
||||
%{method: :get, url: "http://squeet.me/.well-known/host-meta"}, _opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: host_meta_xml}}
|
||||
end)
|
||||
|
||||
res = "https://squeet.me/profile/#{@friendica_account_username}"
|
||||
|
||||
assert {:ok, res} == WebFinger.finger(@friendica_account)
|
||||
end
|
||||
|
||||
test "a Gancio actor" do
|
||||
host_meta_xml = File.read!("test/fixtures/webfinger/gancio-host-meta.xml")
|
||||
|
||||
webfinger_data =
|
||||
File.read!("test/fixtures/webfinger/gancio-webfinger.json") |> Jason.decode!()
|
||||
|
||||
WebfingerClientMock
|
||||
|> expect(:call, fn
|
||||
%{
|
||||
method: :get,
|
||||
url:
|
||||
"https://demo.gancio.org/.well-known/webfinger?resource=acct:gancio@demo.gancio.org"
|
||||
},
|
||||
_opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: webfinger_data}}
|
||||
end)
|
||||
|
||||
HostMetaClientMock
|
||||
|> expect(:call, fn
|
||||
%{method: :get, url: "http://demo.gancio.org/.well-known/host-meta"}, _opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: host_meta_xml}}
|
||||
end)
|
||||
|
||||
res = "https://demo.gancio.org/federation/u/#{@gancio_account_username}"
|
||||
|
||||
assert {:ok, res} == WebFinger.finger(@gancio_account)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user