diff options
| author | William Pitcock <nenolod@dereferenced.org> | 2018-05-26 11:16:05 +0000 | 
|---|---|---|
| committer | William Pitcock <nenolod@dereferenced.org> | 2018-05-26 11:20:53 +0000 | 
| commit | 1db0dc30728a64cf5a9905bcc5df5af9ff3c677b (patch) | |
| tree | 33025b9fe751dc0effbae044773e038499316e64 | |
| parent | 7e873756e7e2c669f9dc460b7d6356fb7d25b9dd (diff) | |
| download | pleroma-1db0dc30728a64cf5a9905bcc5df5af9ff3c677b.tar.gz pleroma-1db0dc30728a64cf5a9905bcc5df5af9ff3c677b.zip | |
tests: add tests to verify the accept request is discarded if no follow activity could be found
| -rw-r--r-- | test/web/activity_pub/transmogrifier_test.exs | 21 | 
1 files changed, 21 insertions, 0 deletions
| diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index b51e02b08..e4cff898d 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -394,6 +394,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do        {:ok, follower} = User.follow(follower, followed)        assert User.following?(follower, followed) == true +      {:ok, follow_activity} = ActivityPub.follow(follower, followed) +        accept_data =          File.read!("test/fixtures/mastodon-accept-activity.json")          |> Poison.decode!() @@ -449,6 +451,25 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do        assert User.following?(follower, followed) == true      end +    test "it fails for incoming accepts which cannot be correlated" do +      follower = insert(:user) +      followed = insert(:user, %{info: %{"locked" => true}}) + +      accept_data = +        File.read!("test/fixtures/mastodon-accept-activity.json") +        |> Poison.decode!() +        |> Map.put("actor", followed.ap_id) + +      accept_data = +        Map.put(accept_data, "object", Map.put(accept_data["object"], "actor", follower.ap_id)) + +      :error = Transmogrifier.handle_incoming(accept_data) + +      follower = Repo.get(User, follower.id) + +      refute User.following?(follower, followed) == true +    end +      test "it works for incoming rejects which are orphaned" do        follower = insert(:user)        followed = insert(:user, %{info: %{"locked" => true}}) | 
