1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Workers.ReceiverWorkerTest do
6 use Pleroma.DataCase, async: true
7 use Oban.Testing, repo: Pleroma.Repo
10 import Pleroma.Factory
12 alias Pleroma.Workers.ReceiverWorker
14 test "it does not retry MRF reject" do
15 params = insert(:note).data
17 with_mock Pleroma.Web.ActivityPub.Transmogrifier,
18 handle_incoming: fn _ -> {:reject, "MRF"} end do
19 assert {:cancel, "MRF"} =
20 ReceiverWorker.perform(%Oban.Job{
21 args: %{"op" => "incoming_ap_doc", "params" => params}
26 test "it does not retry ObjectValidator reject" do
28 insert(:note_activity).data
29 |> Map.put("id", Pleroma.Web.ActivityPub.Utils.generate_activity_id())
30 |> Map.put("object", %{
32 "id" => Pleroma.Web.ActivityPub.Utils.generate_object_id()
35 with_mock Pleroma.Web.ActivityPub.ObjectValidator, [:passthrough],
36 validate: fn _, _ -> {:error, %Ecto.Changeset{}} end do
37 assert {:cancel, {:error, %Ecto.Changeset{}}} =
38 ReceiverWorker.perform(%Oban.Job{
39 args: %{"op" => "incoming_ap_doc", "params" => params}
44 test "it does not retry duplicates" do
45 params = insert(:note_activity).data
47 assert {:cancel, :already_present} =
48 ReceiverWorker.perform(%Oban.Job{
49 args: %{"op" => "incoming_ap_doc", "params" => params}