diff options
author | Tusooa Zhu <tusooa@kazv.moe> | 2022-05-05 18:07:30 -0400 |
---|---|---|
committer | Tusooa Zhu <tusooa@kazv.moe> | 2022-05-06 13:54:21 -0400 |
commit | fe933b9bf2bd9787331db3a37e6bac472eace3d5 (patch) | |
tree | 437b2098f0e57110fbbf820868cafe98004b3851 /test | |
parent | 466568ae36fd247e635e5a1c4db2b5662eda1d02 (diff) | |
download | pleroma-fe933b9bf2bd9787331db3a37e6bac472eace3d5.tar.gz pleroma-fe933b9bf2bd9787331db3a37e6bac472eace3d5.zip |
Prevent remote access of local-only posts via /objects
Ref: fix-local-public
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/activity_pub/activity_pub_controller_test.exs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs index 1c5c40e84..b52c8e52e 100644 --- a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs +++ b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs @@ -247,6 +247,27 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do assert json_response(response, 200) == ObjectView.render("object.json", %{object: object}) end + test "does not return local-only objects for remote users", %{conn: conn} do + user = insert(:user) + reader = insert(:user, local: false) + + {:ok, post} = + CommonAPI.post(user, %{status: "test @#{reader.nickname}", visibility: "local"}) + + assert Pleroma.Web.ActivityPub.Visibility.is_local_public?(post) + + object = Object.normalize(post, fetch: false) + uuid = String.split(object.data["id"], "/") |> List.last() + + assert response = + conn + |> assign(:user, reader) + |> put_req_header("accept", "application/activity+json") + |> get("/objects/#{uuid}") + + json_response(response, 404) + end + test "it returns a json representation of the object with accept application/json", %{ conn: conn } do |