Document and test /api/ap/whoami
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Mon, 23 Sep 2019 16:54:23 +0000 (18:54 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Mon, 23 Sep 2019 17:47:35 +0000 (19:47 +0200)
lib/pleroma/web/activity_pub/activity_pub_controller.ex
test/web/activity_pub/activity_pub_controller_test.exs

index 01b34fb1d475df01dc3d2ce5f87f762e359360e8..34bf04a200f6b427e40ffc82879a9ece336a3192 100644 (file)
@@ -293,6 +293,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
     |> represent_service_actor(conn)
   end
 
+  @doc "Returns the authenticated user's ActivityPub User object or a 404 Not Found if non-authenticated"
   def whoami(%{assigns: %{user: %User{} = user}} = conn, _params) do
     conn
     |> put_resp_content_type("application/activity+json")
index 9e8e420ec35cd6edafd183868e1ed739e538932f..0f8638a9414248f75d46aa49dd4a9d57d373793f 100644 (file)
@@ -976,4 +976,19 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
       assert Delivery.get(object.id, other_user.id)
     end
   end
+
+  describe "Additionnal ActivityPub C2S endpoints" do
+    test "/api/ap/whoami", %{conn: conn} do
+      user = insert(:user)
+
+      conn =
+        conn
+        |> assign(:user, user)
+        |> get("/api/ap/whoami")
+
+      user = User.get_cached_by_id(user.id)
+
+      assert UserView.render("user.json", %{user: user}) == json_response(conn, 200)
+    end
+  end
 end