Make sure remote Update activities can't affect local actors other than
Groups Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -195,7 +195,7 @@ defmodule Mobilizon.Federation.ActivityPubTest do
|
||||
actor = insert(:actor)
|
||||
actor_data = %{summary: @updated_actor_summary}
|
||||
|
||||
{:ok, update, _} = Actions.Update.update(actor, actor_data, false)
|
||||
{:ok, update, _} = Actions.Update.update(actor, actor_data, true)
|
||||
|
||||
assert update.data["actor"] == actor.url
|
||||
assert update.data["to"] == [@activity_pub_public_audience]
|
||||
|
||||
@@ -3,12 +3,13 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.UpdateTest do
|
||||
use Oban.Testing, repo: Mobilizon.Storage.Repo
|
||||
import Mobilizon.Factory
|
||||
import Mox
|
||||
import ExUnit.CaptureLog
|
||||
|
||||
alias Mobilizon.{Actors, Events, Posts}
|
||||
alias Mobilizon.Actors.{Actor, Member}
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Posts.Post
|
||||
alias Mobilizon.Federation.ActivityPub.{Activity, Transmogrifier}
|
||||
alias Mobilizon.Federation.ActivityPub.{Activity, Relay, Transmogrifier}
|
||||
alias Mobilizon.Federation.ActivityStream.Convertible
|
||||
alias Mobilizon.Service.HTTP.ActivityPub.Mock
|
||||
|
||||
@@ -50,6 +51,29 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.UpdateTest do
|
||||
assert actor.summary == "<p>Some bio</p>"
|
||||
end
|
||||
|
||||
test "it fails for incoming update activies on local actors" do
|
||||
%Actor{url: relay_actor_url} = Relay.get_actor()
|
||||
|
||||
update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!()
|
||||
|
||||
object =
|
||||
update_data["object"]
|
||||
|> Map.put("actor", relay_actor_url)
|
||||
|> Map.put("id", relay_actor_url)
|
||||
|
||||
update_data =
|
||||
update_data
|
||||
|> Map.put("actor", relay_actor_url)
|
||||
|> Map.put("object", object)
|
||||
|
||||
assert capture_log([level: :warn], fn ->
|
||||
:error = Transmogrifier.handle_incoming(update_data)
|
||||
end) =~ "[warning] Activity tried to update an actor that's local or not a group"
|
||||
|
||||
{:ok, %Actor{keys: keys}} = Actors.get_actor_by_url(relay_actor_url)
|
||||
assert Regex.match?(~r/BEGIN RSA PRIVATE KEY/, keys)
|
||||
end
|
||||
|
||||
test "it works for incoming update activities on events" do
|
||||
data = File.read!("test/fixtures/mobilizon-post-activity.json") |> Jason.decode!()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user