X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Factivity_pub%2Fpublisher_test.exs;h=93bf5c345e95084a7f6b4d3abb9e13f63895196b;hb=1f863f0a36ebb0648c3d39ecb7ea9e3d01deab60;hp=b50e22bbe794ccf24733b5ab404849ae3793b1e9;hpb=bd77243981f037b4f7b3aeef5291baed67028aef;p=akkoma diff --git a/test/pleroma/web/activity_pub/publisher_test.exs b/test/pleroma/web/activity_pub/publisher_test.exs index b50e22bbe..93bf5c345 100644 --- a/test/pleroma/web/activity_pub/publisher_test.exs +++ b/test/pleroma/web/activity_pub/publisher_test.exs @@ -23,7 +23,11 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do :ok end - setup_all do: clear_config([:instance, :federating], true) + setup_all do + clear_config([:instance, :federating], true) + clear_config([:instance, :quarantined_instances], []) + clear_config([:mrf_simple, :reject], []) + end describe "gather_webfinger_links/1" do test "it returns links" do @@ -267,12 +271,14 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do end describe "publish/2" do - test_with_mock "doesn't publish a non-public activity to quarantined instances.", + test_with_mock "doesn't publish any activity to quarantined or rejected instances.", Pleroma.Web.Federator.Publisher, [:passthrough], [] do Config.put([:instance, :quarantined_instances], [{"domain.com", "some reason"}]) + Config.put([:mrf_simple, :reject], [{"rejected.com", "some reason"}]) + follower = insert(:user, %{ local: false, @@ -280,9 +286,18 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do ap_enabled: true }) + another_follower = + insert(:user, %{ + local: false, + inbox: "https://rejected.com/users/nick2/inbox", + ap_enabled: true + }) + actor = insert(:user, follower_address: follower.ap_id) {:ok, follower, actor} = Pleroma.User.follow(follower, actor) + {:ok, _another_follower, actor} = Pleroma.User.follow(another_follower, actor) + actor = refresh_record(actor) note_activity = @@ -291,10 +306,18 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do recipients: [follower.ap_id] ) + public_note_activity = + insert(:note_activity, + user: actor, + recipients: [follower.ap_id, @as_public] + ) + res = Publisher.publish(actor, note_activity) assert res == :ok + :ok = Publisher.publish(actor, public_note_activity) + assert not called( Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{ inbox: "https://domain.com/users/nick1/inbox", @@ -302,6 +325,30 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do id: note_activity.data["id"] }) ) + + assert not called( + Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{ + inbox: "https://domain.com/users/nick1/inbox", + actor_id: actor.id, + id: public_note_activity.data["id"] + }) + ) + + assert not called( + Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{ + inbox: "https://rejected.com/users/nick2/inbox", + actor_id: actor.id, + id: note_activity.data["id"] + }) + ) + + assert not called( + Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{ + inbox: "https://rejected.com/users/nick2/inbox", + actor_id: actor.id, + id: public_note_activity.data["id"] + }) + ) end test_with_mock "Publishes a non-public activity to non-quarantined instances.", @@ -345,6 +392,8 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do Pleroma.Web.Federator.Publisher, [:passthrough], [] do + Config.put([:instance, :quarantined_instances], []) + follower = insert(:user, %{ local: false, @@ -379,6 +428,8 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do Pleroma.Web.Federator.Publisher, [:passthrough], [] do + clear_config([:instance, :quarantined_instances], []) + fetcher = insert(:user, local: false,