add tests for unauthed reqs to liked/reblogged_by
authorSadposter <hannah+pleroma@coffee-and-dreams.uk>
Tue, 23 Jul 2019 14:05:19 +0000 (15:05 +0100)
committerSadposter <hannah+pleroma@coffee-and-dreams.uk>
Tue, 23 Jul 2019 14:08:41 +0000 (15:08 +0100)
test/web/mastodon_api/mastodon_api_controller_test.exs

index a3e4c413674e7d04cbcd517cbf1f18134e3e2845..00ca320d34ff1777a6e174e24d00bbcd5e6ece75 100644 (file)
@@ -3786,6 +3786,20 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
 
       assert Enum.empty?(response)
     end
+
+    test "does not fail on an unauthententicated request", %{conn: conn, activity: activity} do
+        other_user = insert(:user)
+        {:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
+
+        response =
+            conn
+            |> assign(:user, nil)
+            |> get("/api/v1/#{activity.id}/favourited_by")
+            |> json_response(:ok)
+
+        [%{"id" => id}] = response
+        assert id == other_user.id
+    end
   end
 
   describe "GET /api/v1/statuses/:id/reblogged_by" do
@@ -3843,6 +3857,20 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
 
       assert Enum.empty?(response)
     end
+
+    test "does not fail on an unauthententicated request", %{conn: conn, activity: activity} do
+        other_user = insert(:user)
+        {:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
+
+        response =
+            conn
+            |> assign(:user, nil)
+            |> get("/api/v1/#{activity.id}/reblogged_by")
+            |> json_response(:ok)
+
+        [%{"id" => id}] = response
+        assert id == other_user.id
+    end
   end
 
   describe "POST /auth/password, with valid parameters" do