tests: add test for user inbox
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 25 Oct 2018 05:24:17 +0000 (05:24 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 25 Oct 2018 05:24:17 +0000 (05:24 +0000)
test/fixtures/mastodon-post-activity.json
test/web/activity_pub/activity_pub_controller_test.exs

index 693e0ce393f914f9987df3ca6aaca5d45da528b0..b91263431844d5346079a62d1decbd32555d3ff1 100644 (file)
@@ -21,7 +21,6 @@
         "http://localtesting.pleroma.lol/users/lain"
     ],
     "id": "http://mastodon.example.org/users/admin/statuses/99512778738411822/activity",
-    "nickname": "lain",
     "object": {
         "atomUri": "http://mastodon.example.org/users/admin/statuses/99512778738411822",
         "attachment": [],
index 3ed7be40249858abb97036ff67f1517b06745f3e..e63cd65839cddde275c42510e84e6636e6801c51 100644 (file)
@@ -46,7 +46,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
     end
   end
 
-  describe "/users/:nickname/inbox" do
+  describe "/inbox" do
     test "it inserts an incoming activity into the database", %{conn: conn} do
       data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
 
@@ -62,6 +62,27 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
     end
   end
 
+  describe "/users/:nickname/inbox" do
+    test "it inserts an incoming activity into the database", %{conn: conn} do
+      user = insert(:user)
+
+      data =
+        File.read!("test/fixtures/mastodon-post-activity.json")
+        |> Poison.decode!()
+        |> Map.put("bcc", [user.ap_id])
+
+      conn =
+        conn
+        |> assign(:valid_signature, true)
+        |> put_req_header("content-type", "application/activity+json")
+        |> post("/users/#{user.nickname}/inbox", data)
+
+      assert "ok" == json_response(conn, 200)
+      :timer.sleep(500)
+      assert Activity.get_by_ap_id(data["id"])
+    end
+  end
+
   describe "/users/:nickname/outbox" do
     test "it returns a note activity in a collection", %{conn: conn} do
       note_activity = insert(:note_activity)