Return 413 when an actor's banner or background exceeds the size limit
[akkoma] / test / pleroma / user / import_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.User.ImportTest do
6 alias Pleroma.Tests.ObanHelpers
7 alias Pleroma.User
8
9 use Pleroma.DataCase
10 use Oban.Testing, repo: Pleroma.Repo
11
12 import Pleroma.Factory
13
14 setup_all do
15 Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
16 :ok
17 end
18
19 describe "follow_import" do
20 test "it imports user followings from list" do
21 [user1, user2, user3] = insert_list(3, :user)
22
23 identifiers = [
24 user2.ap_id,
25 user3.nickname
26 ]
27
28 [{:ok, job1}, {:ok, job2}] = User.Import.follow_import(user1, identifiers)
29
30 assert {:ok, result} = ObanHelpers.perform(job1)
31 assert result == refresh_record(user2)
32
33 assert {:ok, result} = ObanHelpers.perform(job2)
34 assert result == refresh_record(user3)
35
36 assert User.following?(user1, user2)
37 assert User.following?(user1, user3)
38 end
39 end
40
41 describe "blocks_import" do
42 test "it imports user blocks from list" do
43 [user1, user2, user3] = insert_list(3, :user)
44
45 identifiers = [
46 user2.ap_id,
47 user3.nickname
48 ]
49
50 [{:ok, job1}, {:ok, job2}] = User.Import.blocks_import(user1, identifiers)
51
52 assert {:ok, result} = ObanHelpers.perform(job1)
53 assert result == user2
54
55 assert {:ok, result} = ObanHelpers.perform(job2)
56 assert result == user3
57
58 assert User.blocks?(user1, user2)
59 assert User.blocks?(user1, user3)
60 end
61 end
62
63 describe "mutes_import" do
64 test "it imports user mutes from list" do
65 [user1, user2, user3] = insert_list(3, :user)
66
67 identifiers = [
68 user2.ap_id,
69 user3.nickname
70 ]
71
72 [{:ok, job1}, {:ok, job2}] = User.Import.mutes_import(user1, identifiers)
73
74 assert {:ok, result} = ObanHelpers.perform(job1)
75 assert result == user2
76
77 assert {:ok, result} = ObanHelpers.perform(job2)
78 assert result == user3
79
80 assert User.mutes?(user1, user2)
81 assert User.mutes?(user1, user3)
82 end
83 end
84 end