tests: add tests to verify the accept request is discarded if no follow activity...
authorWilliam Pitcock <nenolod@dereferenced.org>
Sat, 26 May 2018 11:16:05 +0000 (11:16 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sat, 26 May 2018 11:20:53 +0000 (11:20 +0000)
test/web/activity_pub/transmogrifier_test.exs

index b51e02b08ba18c285db31d29ec8e1e3f71342bf8..e4cff898d6da699b103ef869da969a5634c10ce5 100644 (file)
@@ -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}})