mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2025-01-03 05:48:42 +00:00
Add test confirming cancellation for activity by a deleted user
This commit is contained in:
parent
fc450fdefc
commit
60101e240d
1 changed files with 46 additions and 42 deletions
|
@ -51,52 +51,56 @@ defmodule Pleroma.Workers.ReceiverWorkerTest do
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it does not retry if a user fetch fails with a 403" do
|
describe "cancels on a failed user fetch" do
|
||||||
Tesla.Mock.mock(fn
|
setup do
|
||||||
%{url: "https://simpsons.com/users/bart"} ->
|
Tesla.Mock.mock(fn
|
||||||
%Tesla.Env{
|
%{url: "https://springfield.social/users/bart"} ->
|
||||||
status: 403,
|
%Tesla.Env{
|
||||||
body: ""
|
status: 403,
|
||||||
}
|
body: ""
|
||||||
end)
|
}
|
||||||
|
|
||||||
params =
|
%{url: "https://springfield.social/users/troymcclure"} ->
|
||||||
%{
|
%Tesla.Env{
|
||||||
"@context" => [
|
status: 404,
|
||||||
"https://www.w3.org/ns/activitystreams",
|
body: ""
|
||||||
"https://w3id.org/security/v1"
|
}
|
||||||
],
|
end)
|
||||||
"actor" => "https://simpsons.com/users/bart",
|
end
|
||||||
"cc" => [],
|
|
||||||
"id" => "https://simpsons.com/activity/eat-my-shorts",
|
|
||||||
"object" => %{},
|
|
||||||
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
|
||||||
"type" => "Create"
|
|
||||||
}
|
|
||||||
|
|
||||||
req_headers = [
|
test "when request returns a 403" do
|
||||||
["accept-encoding", "gzip"],
|
params =
|
||||||
["content-length", "31337"],
|
insert(:note_activity).data
|
||||||
["content-type", "application/activity+json"],
|
|> Map.put("actor", "https://springfield.social/users/bart")
|
||||||
["date", "Wed, 28 Aug 2024 15:36:31 GMT"],
|
|
||||||
["digest", "SHA-256=ouge/6HP2/QryG6F3JNtZ6vzs/hSwMk67xdxe87eH7A="],
|
|
||||||
["host", "bikeshed.party"],
|
|
||||||
[
|
|
||||||
"signature",
|
|
||||||
"does not matter as user needs to be fetched first"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|
|
||||||
{:ok, oban_job} =
|
{:ok, oban_job} =
|
||||||
Federator.incoming_ap_doc(%{
|
Federator.incoming_ap_doc(%{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
req_headers: req_headers,
|
req_headers: [],
|
||||||
request_path: "/inbox",
|
request_path: "/inbox",
|
||||||
params: params,
|
params: params,
|
||||||
query_string: ""
|
query_string: ""
|
||||||
})
|
})
|
||||||
|
|
||||||
assert {:cancel, {:error, :forbidden}} = ReceiverWorker.perform(oban_job)
|
assert {:cancel, {:error, :forbidden}} = ReceiverWorker.perform(oban_job)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "when request returns a 404" do
|
||||||
|
params =
|
||||||
|
insert(:note_activity).data
|
||||||
|
|> Map.put("actor", "https://springfield.social/users/troymcclure")
|
||||||
|
|
||||||
|
{:ok, oban_job} =
|
||||||
|
Federator.incoming_ap_doc(%{
|
||||||
|
method: "POST",
|
||||||
|
req_headers: [],
|
||||||
|
request_path: "/inbox",
|
||||||
|
params: params,
|
||||||
|
query_string: ""
|
||||||
|
})
|
||||||
|
|
||||||
|
assert {:cancel, {:error, :not_found}} = ReceiverWorker.perform(oban_job)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it can validate the signature" do
|
test "it can validate the signature" do
|
||||||
|
|
Loading…
Reference in a new issue