diff options
| author | lain <lain@soykaf.club> | 2018-03-03 18:37:40 +0100 | 
|---|---|---|
| committer | lain <lain@soykaf.club> | 2018-03-03 18:38:40 +0100 | 
| commit | d2ad99298e095f8c738efc95d0f8f077f8bfa23a (patch) | |
| tree | 6dc981f0beb9758f44e153b5bd4335feae011d6f /test | |
| parent | 1377b2e569e91b4f51ba4715b343e1a8a7feb8ba (diff) | |
| download | pleroma-d2ad99298e095f8c738efc95d0f8f077f8bfa23a.tar.gz pleroma-d2ad99298e095f8c738efc95d0f8f077f8bfa23a.zip  | |
Handle incoming deletes.
Diffstat (limited to 'test')
| -rw-r--r-- | test/fixtures/mastodon-delete.json | 33 | ||||
| -rw-r--r-- | test/web/activity_pub/transmogrifier_test.exs | 30 | 
2 files changed, 50 insertions, 13 deletions
diff --git a/test/fixtures/mastodon-delete.json b/test/fixtures/mastodon-delete.json new file mode 100644 index 000000000..87a582002 --- /dev/null +++ b/test/fixtures/mastodon-delete.json @@ -0,0 +1,33 @@ +{ +  "type": "Delete", +  "signature": { +    "type": "RsaSignature2017", +    "signatureValue": "cw0RlfNREf+5VdsOYcCBDrv521eiLsDTAYNHKffjF0bozhCnOh+wHkFik7WamUk$ +uEiN4L2H6vPlGRprAZGRhEwgy+A7rIFQNmLrpW5qV5UNVI/2F7kngEHqZQgbQYj9hW+5GMYmPkHdv3D72ZefGw$ +4Xa2NBLGFpAjQllfzt7kzZLKKY2DM99FdUa64I2Wj3iD04Hs23SbrUdAeuGk/c1Cg6bwGNG4vxoiwn1jikgJLA$ +NAlSGjsRGdR7LfbC7GqWWsW3cSNsLFPoU6FyALjgTrrYoHiXe0QHggw+L3yMLfzB2S/L46/VRbyb+WDKMBIXUL$ +5owmzHSi6e/ZtCI3w==", +    "creator": "http://mastodon.example.org/users/gargron#main-key",                       "created": "2018-03-03T16:24:11Z" +  }, +  "object": { +    "type": "Tombstone", +    "id": "http://mastodon.example.org/users/gargron/statuses/99620895606148759", +    "atomUri": "http://mastodon.example.org/users/gargron/statuses/99620895606148759" +  }, +  "id": "http://mastodon.example.org/users/gargron/statuses/99620895606148759#delete", +  "actor": "http://mastodon.example.org/users/gargron", +  "@context": [ +    { +      "toot": "http://joinmastodon.org/ns#", +      "sensitive": "as:sensitive", +      "ostatus": "http://ostatus.org#", +      "movedTo": "as:movedTo", +      "manuallyApprovesFollowers": "as:manuallyApprovesFollowers", +      "inReplyToAtomUri": "ostatus:inReplyToAtomUri", +      "conversation": "ostatus:conversation", +      "atomUri": "ostatus:atomUri", +      "Hashtag": "as:Hashtag", +      "Emoji": "toot:Emoji" +    } +  ] +} diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 2803f1a05..c0ee209f1 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -148,6 +148,23 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do        assert user.info["banner"]["url"] == [%{"href" => "https://cd.niu.moe/accounts/headers/000/033/323/original/850b3448fa5fd477.png"}]        assert user.bio == "<p>Some bio</p>"      end + +    test "it works for incoming deletes" do +      activity = insert(:note_activity) +      data = File.read!("test/fixtures/mastodon-delete.json") +      |> Poison.decode! + +      object = data["object"] +      |> Map.put("id", activity.data["object"]["id"]) + +      data = data +      |> Map.put("object", object) +      |> Map.put("actor", activity.data["actor"]) + +      {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) + +      refute Repo.get(Activity, activity.id) +    end    end    describe "prepare outgoing" do @@ -256,18 +273,5 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do        refute Repo.get(WebsubClientSubscription, ws.id)        assert Repo.get(WebsubClientSubscription, ws2.id)      end - -    test "it deletes all websub server subscriptions with the server as callback" do -      subscription = %WebsubClientSubscription{topic: "https://niu.moe/users/rye.atom"} -      {:ok, ws} = Repo.insert(subscription) - -      subscription = %WebsubClientSubscription{topic: "https://niu.moe/users/pasty.atom"} -      {:ok, ws2} = Repo.insert(subscription) - -      Transmogrifier.maybe_retire_websub("https://niu.moe/users/rye") - -      refute Repo.get(WebsubClientSubscription, ws.id) -      assert Repo.get(WebsubClientSubscription, ws2.id) -    end    end  end  | 
