Correct elixir tests back-end link to actor refresh for new federation - issue #1776
This commit is contained in:
@@ -7,6 +7,8 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.FollowTest do
|
|||||||
alias Mobilizon.Actors.Follower
|
alias Mobilizon.Actors.Follower
|
||||||
alias Mobilizon.Federation.ActivityPub.{Actions, Activity, Relay, Transmogrifier}
|
alias Mobilizon.Federation.ActivityPub.{Actions, Activity, Relay, Transmogrifier}
|
||||||
alias Mobilizon.Service.HTTP.ActivityPub.Mock
|
alias Mobilizon.Service.HTTP.ActivityPub.Mock
|
||||||
|
alias Mobilizon.Service.HTTP.HostMetaClient.Mock, as: HostMetaClientMock
|
||||||
|
alias Mobilizon.Service.HTTP.WebfingerClient.Mock, as: WebfingerClientMock
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
import Swoosh.TestAssertions
|
import Swoosh.TestAssertions
|
||||||
@@ -45,6 +47,52 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.FollowTest do
|
|||||||
test "it works for incoming follow requests" do
|
test "it works for incoming follow requests" do
|
||||||
actor = insert(:group)
|
actor = insert(:group)
|
||||||
|
|
||||||
|
HostMetaClientMock
|
||||||
|
|> expect(:call, 3, fn
|
||||||
|
%{method: :get, url: "https://social.tcit.fr/.well-known/host-meta"}, _opts ->
|
||||||
|
{:ok, %Tesla.Env{status: 404, body: ""}}
|
||||||
|
end)
|
||||||
|
|
||||||
|
webfinger_data =
|
||||||
|
"{}"
|
||||||
|
|> Jason.decode!()
|
||||||
|
|
||||||
|
WebfingerClientMock
|
||||||
|
|> expect(:call, 4, fn
|
||||||
|
%{method: :get, url: "https://social.tcit.fr/.well-known/nodeinfo"}, _opts ->
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: webfinger_data,
|
||||||
|
headers: [{"content-type", "application/json"}]
|
||||||
|
}}
|
||||||
|
|
||||||
|
%{
|
||||||
|
method: :get,
|
||||||
|
url: "https://social.tcit.fr/.well-known/webfinger?resource=acct:relay@social.tcit.fr"
|
||||||
|
},
|
||||||
|
_opts ->
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: webfinger_data,
|
||||||
|
headers: [{"content-type", "application/json"}]
|
||||||
|
}}
|
||||||
|
|
||||||
|
%{
|
||||||
|
method: :get,
|
||||||
|
url:
|
||||||
|
"https://social.tcit.fr/.well-known/webfinger?resource=acct:social.tcit.fr@social.tcit.fr"
|
||||||
|
},
|
||||||
|
_opts ->
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: webfinger_data,
|
||||||
|
headers: [{"content-type", "application/json"}]
|
||||||
|
}}
|
||||||
|
end)
|
||||||
|
|
||||||
actor_data =
|
actor_data =
|
||||||
File.read!("test/fixtures/mastodon-actor.json")
|
File.read!("test/fixtures/mastodon-actor.json")
|
||||||
|> Jason.decode!()
|
|> Jason.decode!()
|
||||||
@@ -110,6 +158,52 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.FollowTest do
|
|||||||
%User{} = insert(:user, email: "loulou@example.com", role: :administrator)
|
%User{} = insert(:user, email: "loulou@example.com", role: :administrator)
|
||||||
relay = Relay.get_actor()
|
relay = Relay.get_actor()
|
||||||
|
|
||||||
|
HostMetaClientMock
|
||||||
|
|> expect(:call, 3, fn
|
||||||
|
%{method: :get, url: "https://social.tcit.fr/.well-known/host-meta"}, _opts ->
|
||||||
|
{:ok, %Tesla.Env{status: 404, body: ""}}
|
||||||
|
end)
|
||||||
|
|
||||||
|
webfinger_data =
|
||||||
|
"{}"
|
||||||
|
|> Jason.decode!()
|
||||||
|
|
||||||
|
WebfingerClientMock
|
||||||
|
|> expect(:call, 4, fn
|
||||||
|
%{method: :get, url: "https://social.tcit.fr/.well-known/nodeinfo"}, _opts ->
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: webfinger_data,
|
||||||
|
headers: [{"content-type", "application/json"}]
|
||||||
|
}}
|
||||||
|
|
||||||
|
%{
|
||||||
|
method: :get,
|
||||||
|
url: "https://social.tcit.fr/.well-known/webfinger?resource=acct:relay@social.tcit.fr"
|
||||||
|
},
|
||||||
|
_opts ->
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: webfinger_data,
|
||||||
|
headers: [{"content-type", "application/json"}]
|
||||||
|
}}
|
||||||
|
|
||||||
|
%{
|
||||||
|
method: :get,
|
||||||
|
url:
|
||||||
|
"https://social.tcit.fr/.well-known/webfinger?resource=acct:social.tcit.fr@social.tcit.fr"
|
||||||
|
},
|
||||||
|
_opts ->
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: webfinger_data,
|
||||||
|
headers: [{"content-type", "application/json"}]
|
||||||
|
}}
|
||||||
|
end)
|
||||||
|
|
||||||
actor_data =
|
actor_data =
|
||||||
File.read!("test/fixtures/mastodon-actor.json")
|
File.read!("test/fixtures/mastodon-actor.json")
|
||||||
|> Jason.decode!()
|
|> Jason.decode!()
|
||||||
@@ -146,6 +240,52 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.FollowTest do
|
|||||||
%User{email: admin_email} = insert(:user, email: "loulou@example.com", role: :administrator)
|
%User{email: admin_email} = insert(:user, email: "loulou@example.com", role: :administrator)
|
||||||
relay = Relay.get_actor()
|
relay = Relay.get_actor()
|
||||||
|
|
||||||
|
HostMetaClientMock
|
||||||
|
|> expect(:call, 3, fn
|
||||||
|
%{method: :get, url: "https://mobilizon.fr/.well-known/host-meta"}, _opts ->
|
||||||
|
{:ok, %Tesla.Env{status: 404, body: ""}}
|
||||||
|
end)
|
||||||
|
|
||||||
|
webfinger_data =
|
||||||
|
"{}"
|
||||||
|
|> Jason.decode!()
|
||||||
|
|
||||||
|
WebfingerClientMock
|
||||||
|
|> expect(:call, 4, fn
|
||||||
|
%{method: :get, url: "https://mobilizon.fr/.well-known/nodeinfo"}, _opts ->
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: webfinger_data,
|
||||||
|
headers: [{"content-type", "application/json"}]
|
||||||
|
}}
|
||||||
|
|
||||||
|
%{
|
||||||
|
method: :get,
|
||||||
|
url: "https://mobilizon.fr/.well-known/webfinger?resource=acct:relay@mobilizon.fr"
|
||||||
|
},
|
||||||
|
_opts ->
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: webfinger_data,
|
||||||
|
headers: [{"content-type", "application/json"}]
|
||||||
|
}}
|
||||||
|
|
||||||
|
%{
|
||||||
|
method: :get,
|
||||||
|
url:
|
||||||
|
"https://mobilizon.fr/.well-known/webfinger?resource=acct:mobilizon.fr@mobilizon.fr"
|
||||||
|
},
|
||||||
|
_opts ->
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: webfinger_data,
|
||||||
|
headers: [{"content-type", "application/json"}]
|
||||||
|
}}
|
||||||
|
end)
|
||||||
|
|
||||||
actor_data =
|
actor_data =
|
||||||
File.read!("test/fixtures/mastodon-actor.json")
|
File.read!("test/fixtures/mastodon-actor.json")
|
||||||
|> Jason.decode!()
|
|> Jason.decode!()
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.UndoTest do
|
|||||||
alias Mobilizon.Discussions.Comment
|
alias Mobilizon.Discussions.Comment
|
||||||
alias Mobilizon.Federation.ActivityPub.{Activity, Transmogrifier}
|
alias Mobilizon.Federation.ActivityPub.{Activity, Transmogrifier}
|
||||||
alias Mobilizon.Service.HTTP.ActivityPub.Mock
|
alias Mobilizon.Service.HTTP.ActivityPub.Mock
|
||||||
|
alias Mobilizon.Service.HTTP.HostMetaClient.Mock, as: HostMetaClientMock
|
||||||
|
alias Mobilizon.Service.HTTP.WebfingerClient.Mock, as: WebfingerClientMock
|
||||||
|
|
||||||
describe "handle incoming undo activities" do
|
describe "handle incoming undo activities" do
|
||||||
test "it works for incoming unannounces with an existing notice" do
|
test "it works for incoming unannounces with an existing notice" do
|
||||||
@@ -51,6 +53,52 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.UndoTest do
|
|||||||
test "it works for incomming unfollows with an existing follow" do
|
test "it works for incomming unfollows with an existing follow" do
|
||||||
actor = insert(:group)
|
actor = insert(:group)
|
||||||
|
|
||||||
|
HostMetaClientMock
|
||||||
|
|> expect(:call, 3, fn
|
||||||
|
%{method: :get, url: "https://social.tcit.fr/.well-known/host-meta"}, _opts ->
|
||||||
|
{:ok, %Tesla.Env{status: 404, body: ""}}
|
||||||
|
end)
|
||||||
|
|
||||||
|
webfinger_data =
|
||||||
|
"{}"
|
||||||
|
|> Jason.decode!()
|
||||||
|
|
||||||
|
WebfingerClientMock
|
||||||
|
|> expect(:call, 4, fn
|
||||||
|
%{method: :get, url: "https://social.tcit.fr/.well-known/nodeinfo"}, _opts ->
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: webfinger_data,
|
||||||
|
headers: [{"content-type", "application/json"}]
|
||||||
|
}}
|
||||||
|
|
||||||
|
%{
|
||||||
|
method: :get,
|
||||||
|
url: "https://social.tcit.fr/.well-known/webfinger?resource=acct:relay@social.tcit.fr"
|
||||||
|
},
|
||||||
|
_opts ->
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: webfinger_data,
|
||||||
|
headers: [{"content-type", "application/json"}]
|
||||||
|
}}
|
||||||
|
|
||||||
|
%{
|
||||||
|
method: :get,
|
||||||
|
url:
|
||||||
|
"https://social.tcit.fr/.well-known/webfinger?resource=acct:social.tcit.fr@social.tcit.fr"
|
||||||
|
},
|
||||||
|
_opts ->
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: webfinger_data,
|
||||||
|
headers: [{"content-type", "application/json"}]
|
||||||
|
}}
|
||||||
|
end)
|
||||||
|
|
||||||
follow_data =
|
follow_data =
|
||||||
File.read!("test/fixtures/mastodon-follow-activity.json")
|
File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||||
|> Jason.decode!()
|
|> Jason.decode!()
|
||||||
|
|||||||
Reference in New Issue
Block a user