Correctly stitch mastodon -> ostatus replies.
[akkoma] / test / web / activity_pub / activity_pub_controller_test.exs
1 defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
2 use Pleroma.Web.ConnCase
3 import Pleroma.Factory
4 alias Pleroma.Web.ActivityPub.{UserView, ObjectView}
5 alias Pleroma.{Repo, User}
6
7 describe "/users/:nickname" do
8 test "it returns a json representation of the user", %{conn: conn} do
9 user = insert(:user)
10
11 conn = conn
12 |> put_req_header("accept", "application/activity+json")
13 |> get("/users/#{user.nickname}")
14
15 user = Repo.get(User, user.id)
16
17 assert json_response(conn, 200) == UserView.render("user.json", %{user: user})
18 end
19 end
20
21 describe "/object/:uuid" do
22 test "it returns a json representation of the object", %{conn: conn} do
23 note = insert(:note)
24 uuid = String.split(note.data["id"], "/") |> List.last
25
26 conn = conn
27 |> put_req_header("accept", "application/activity+json")
28 |> get("/objects/#{uuid}")
29
30 assert json_response(conn, 200) == ObjectView.render("object.json", %{object: note})
31 end
32 end
33
34 describe "/users/:nickname/inbox" do
35 test "it inserts an incoming activity into the database", %{conn: conn} do
36 data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!
37
38 conn = conn
39 |> assign(:valid_signature, true)
40 |> put_req_header("content-type", "application/activity+json")
41 |> post("/users/doesntmatter/inbox", data)
42
43 assert "ok" == json_response(conn, 200)
44 end
45 end
46 end