@@ -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
|
||||
|
||||
Reference in New Issue
Block a user