mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-22 16:16:34 +00:00
Switch test to the inbox
This commit is contained in:
parent
27fcc42171
commit
7bcc21ad6f
2 changed files with 21 additions and 22 deletions
|
@ -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"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue