diff options
| author | rinpatch <rinpatch@sdf.org> | 2019-09-13 11:36:49 +0300 | 
|---|---|---|
| committer | rinpatch <rinpatch@sdf.org> | 2019-09-13 11:38:17 +0300 | 
| commit | ce23529d917c1830b270a29e774e4ed7768bfeff (patch) | |
| tree | b7ad9de686a323b0c9c77cb805285a08ed77ac10 /test/web | |
| parent | b0e60580215e26caae6452099fa1fbace525937c (diff) | |
| download | pleroma-ce23529d917c1830b270a29e774e4ed7768bfeff.tar.gz pleroma-ce23529d917c1830b270a29e774e4ed7768bfeff.zip | |
Use delivery info when federating deletes
Diffstat (limited to 'test/web')
| -rw-r--r-- | test/web/activity_pub/publisher_test.exs | 68 | 
1 files changed, 67 insertions, 1 deletions
| diff --git a/test/web/activity_pub/publisher_test.exs b/test/web/activity_pub/publisher_test.exs index 36a39c84c..32b7a242c 100644 --- a/test/web/activity_pub/publisher_test.exs +++ b/test/web/activity_pub/publisher_test.exs @@ -3,15 +3,17 @@  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.Web.ActivityPub.PublisherTest do -  use Pleroma.DataCase +  use Pleroma.Web.ConnCase    import Pleroma.Factory    import Tesla.Mock    import Mock    alias Pleroma.Activity +  alias Pleroma.Object    alias Pleroma.Instances    alias Pleroma.Web.ActivityPub.Publisher +  alias Pleroma.Web.CommonAPI    @as_public "https://www.w3.org/ns/activitystreams#Public" @@ -262,5 +264,69 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do                 })               )      end + +    test_with_mock "publishes a delete activity to peers who signed fetch requests to the create acitvity/object.", +                   Pleroma.Web.Federator.Publisher, +                   [:passthrough], +                   [] do +      fetcher = +        insert(:user, +          local: false, +          info: %{ +            ap_enabled: true, +            source_data: %{"inbox" => "https://domain.com/users/nick1/inbox"} +          } +        ) + +      another_fetcher = +        insert(:user, +          local: false, +          info: %{ +            ap_enabled: true, +            source_data: %{"inbox" => "https://domain2.com/users/nick1/inbox"} +          } +        ) + +      actor = insert(:user) + +      note_activity = insert(:note_activity, user: actor) +      object = Object.normalize(note_activity) + +      activity_path = String.trim_leading(note_activity.data["id"], Pleroma.Web.Endpoint.url()) +      object_path = String.trim_leading(object.data["id"], Pleroma.Web.Endpoint.url()) + +      build_conn() +      |> put_req_header("accept", "application/activity+json") +      |> assign(:user, fetcher) +      |> get(object_path) +      |> json_response(200) + +      build_conn() +      |> put_req_header("accept", "application/activity+json") +      |> assign(:user, another_fetcher) +      |> get(activity_path) +      |> json_response(200) + +      {:ok, delete} = CommonAPI.delete(note_activity.id, actor) + +      res = Publisher.publish(actor, delete) +      assert res == :ok + +      assert called( +               Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{ +                 inbox: "https://domain.com/users/nick1/inbox", +                 actor: actor, +                 id: delete.data["id"] +               }) +             ) + +      assert called( +               Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{ +                 inbox: "https://domain2.com/users/nick1/inbox", +                 actor: actor, +                 id: delete.data["id"] +               }) +             ) +    end    end  end | 
