tests: add a testcase for user collision
authorWilliam Pitcock <nenolod@dereferenced.org>
Sat, 17 Nov 2018 20:20:45 +0000 (20:20 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sat, 17 Nov 2018 20:20:45 +0000 (20:20 +0000)
test/support/httpoison_mock.ex
test/web/activity_pub/transmogrifier_test.exs

index ebd1e9c4d3d9932ec200bd21c269d0b407fa1f91..e3310bb5df66badb125b8aaaef435331ba246636 100644 (file)
@@ -756,6 +756,14 @@ defmodule HTTPoisonMock do
      }}
   end
 
+  def get("https://n1u.moe/users/rye", [Accept: "application/activity+json"], _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/rye.json")
+     }}
+  end
+
   def get(
         "https://mst3k.interlinked.me/users/luciferMysticus",
         [Accept: "application/activity+json"],
index b8adf3b8acefea48bfa248884efaa3b92e53a92e..f8a82dd5bf1cde9ef18f019cf35636ecbe7a9be5 100644 (file)
@@ -955,5 +955,17 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
           data
         )
     end
+
+    test "users cannot be collided through fake direction spoofing attempts" do
+      user =
+        insert(:user, %{
+          nickname: "rye@niu.moe",
+          local: false,
+          ap_id: "https://niu.moe/users/rye",
+          follower_address: User.ap_followers(%User{nickname: "rye@niu.moe"})
+        })
+
+      {:error, _} = User.get_or_fetch_by_ap_id("https://n1u.moe/users/rye")
+    end
   end
 end