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.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
6 use Pleroma.DataCase, async: true
10 alias Pleroma.Web.ActivityPub.Transmogrifier
11 alias Pleroma.Web.CommonAPI
13 import Pleroma.Factory
15 test "it fails for incoming rejects which cannot be correlated" do
16 follower = insert(:user)
17 followed = insert(:user, is_locked: true)
20 File.read!("test/fixtures/mastodon-reject-activity.json")
22 |> Map.put("actor", followed.ap_id)
25 Map.put(accept_data, "object", Map.put(accept_data["object"], "actor", follower.ap_id))
27 {:error, _} = Transmogrifier.handle_incoming(accept_data)
29 follower = User.get_cached_by_id(follower.id)
31 refute User.following?(follower, followed) == true
34 test "it works for incoming rejects which are referenced by IRI only" do
35 follower = insert(:user)
36 followed = insert(:user, is_locked: true)
38 {:ok, follower, followed} = User.follow(follower, followed)
39 {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
41 assert User.following?(follower, followed) == true
44 File.read!("test/fixtures/mastodon-reject-activity.json")
46 |> Map.put("actor", followed.ap_id)
47 |> Map.put("object", follow_activity.data["id"])
49 {:ok, %Activity{data: _}} = Transmogrifier.handle_incoming(reject_data)
51 follower = User.get_cached_by_id(follower.id)
53 assert User.following?(follower, followed) == false
56 test "it rejects activities without a valid ID" do
60 File.read!("test/fixtures/mastodon-follow-activity.json")
62 |> Map.put("object", user.ap_id)
65 :error = Transmogrifier.handle_incoming(data)