commit: 7bcc21ad6f1fdf9dbc16990e9891f9de7a21011d
parent 27fcc421719062d5de9bf4dc90f3349595eb278d
Author: Mark Felder <feld@feld.me>
Date: Sat, 24 Aug 2024 13:01:28 -0400
Switch test to the inbox
Diffstat:
2 files changed, 21 insertions(+), 22 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
@@ -684,6 +684,27 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|> json_response(400)
end
+ # When activity is delivered to the inbox and we cannot immediately verify signature
+ # 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
+ # 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
+ params =
+ %{
+ "type" => "Delete",
+ "actor" => "https://unknown.mastodon.instance/users/somebody"
+ }
+ |> Jason.encode!()
+
+ conn
+ |> assign(:valid_signature, false)
+ |> put_req_header("content-type", "application/activity+json")
+ |> post("/inbox", params)
+ |> json_response(200)
+
+ assert all_enqueued() == []
+ end
+
test "accepts Add/Remove activities", %{conn: conn} do
object_id = "c61d6733-e256-4fe1-ab13-1e369789423f"
diff --git a/test/pleroma/workers/receiver_worker_test.exs b/test/pleroma/workers/receiver_worker_test.exs
@@ -245,26 +245,4 @@ defmodule Pleroma.Workers.ReceiverWorkerTest do
assert {:ok, %Pleroma.Activity{}} = ReceiverWorker.perform(oban_job)
end
-
- # When activity is delivered to the inbox and we cannot immediately verify signature
- # we capture all the params and process it later in the Oban job.
- # This requires we replicate the same scenario by including additional fields in the params
- test "Deletes cancelled for an unknown actor" do
- params = %{
- "type" => "Delete",
- "actor" => "https://unknown.mastodon.instance/users/somebody"
- }
-
- assert {:cancel, "Delete from unknown actor"} =
- ReceiverWorker.perform(%Oban.Job{
- args: %{
- "op" => "incoming_ap_doc",
- "method" => :post,
- "req_headers" => [],
- "request_path" => "/inbox",
- "query_string" => "",
- "params" => params
- }
- })
- end
end