Test more types we do not want to receive from strangers

This commit is contained in:
Mark Felder 2024-08-29 14:40:45 -04:00
parent 2b39956acb
commit 012132303f

View file

@ -688,10 +688,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
# we capture all the params and process it later in the Oban job. # we capture all the params and process it later in the Oban job.
# Once we begin processing it through Oban we risk fetching the actor to validate the # Once we begin processing it through Oban we risk fetching the actor to validate the
# activity which just leads to inserting a new user to process a Delete not relevant to us. # activity which just leads to inserting a new user to process a Delete not relevant to us.
test "Deletes from an unknown actor are discarded", %{conn: conn} do test "Activities of certain types from an unknown actor are discarded", %{conn: conn} do
example_bad_types = ["Announce", "Delete", "Undo"]
Enum.each(example_bad_types, fn bad_type ->
params = params =
%{ %{
"type" => "Delete", "type" => bad_type,
"actor" => "https://unknown.mastodon.instance/users/somebody" "actor" => "https://unknown.mastodon.instance/users/somebody"
} }
|> Jason.encode!() |> Jason.encode!()
@ -703,6 +706,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|> json_response(400) |> json_response(400)
assert all_enqueued() == [] assert all_enqueued() == []
end)
end end
test "accepts Add/Remove activities", %{conn: conn} do test "accepts Add/Remove activities", %{conn: conn} do