diff options
| author | lain <lain@soykaf.club> | 2019-06-05 14:10:46 +0200 | 
|---|---|---|
| committer | lain <lain@soykaf.club> | 2019-06-05 14:10:46 +0200 | 
| commit | 3115b64cfe220c1db61c71fc4cef51bdf167b9ab (patch) | |
| tree | 6bea358c2090544c51d21853c6cb0af1b5438e8b /test/web/activity_pub | |
| parent | 50afe5ab9e384676a7e64b476f3655ccf94acb5d (diff) | |
| download | pleroma-3115b64cfe220c1db61c71fc4cef51bdf167b9ab.tar.gz pleroma-3115b64cfe220c1db61c71fc4cef51bdf167b9ab.zip  | |
Transmogrifier: Add tests for incoming follows to locked accounts.
Diffstat (limited to 'test/web/activity_pub')
| -rw-r--r-- | test/web/activity_pub/transmogrifier/follow_handling_test.exs | 29 | 
1 files changed, 28 insertions, 1 deletions
diff --git a/test/web/activity_pub/transmogrifier/follow_handling_test.exs b/test/web/activity_pub/transmogrifier/follow_handling_test.exs index 5ddf6cd52..857d65564 100644 --- a/test/web/activity_pub/transmogrifier/follow_handling_test.exs +++ b/test/web/activity_pub/transmogrifier/follow_handling_test.exs @@ -27,14 +27,41 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do          |> Poison.decode!()          |> Map.put("object", user.ap_id) -      {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) +      {:ok, %Activity{data: data, local: false} = activity} = Transmogrifier.handle_incoming(data)        assert data["actor"] == "http://mastodon.example.org/users/admin"        assert data["type"] == "Follow"        assert data["id"] == "http://mastodon.example.org/users/admin#follows/2" + +      activity = Repo.get(Activity, activity.id) +      assert activity.data["state"] == "accept"        assert User.following?(User.get_cached_by_ap_id(data["actor"]), user)      end +    test "with locked accounts, it does not create a follow or an accept" do +      user = insert(:user, info: %{locked: true}) + +      data = +        File.read!("test/fixtures/mastodon-follow-activity.json") +        |> Poison.decode!() +        |> Map.put("object", user.ap_id) + +      {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) + +      assert data["state"] == "pending" + +      refute User.following?(User.get_cached_by_ap_id(data["actor"]), user) + +      accepts = +        from( +          a in Activity, +          where: fragment("?->>'type' = ?", a.data, "Accept") +        ) +        |> Repo.all() + +      assert length(accepts) == 0 +    end +      test "it works for follow requests when you are already followed, creating a new accept activity" do        # This is important because the remote might have the wrong idea about the        # current follow status. This can lead to instance A thinking that x@A is  | 
