[#3213] Hashtag-filtering functions in ActivityPub. Mix task for migrating hashtags...
[akkoma] / test / pleroma / web / activity_pub / object_validators / update_handling_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ActivityPub.ObjectValidators.UpdateHandlingTest do
6 use Pleroma.DataCase
7
8 alias Pleroma.Web.ActivityPub.Builder
9 alias Pleroma.Web.ActivityPub.ObjectValidator
10
11 import Pleroma.Factory
12
13 describe "updates" do
14 setup do
15 user = insert(:user)
16
17 object = %{
18 "id" => user.ap_id,
19 "name" => "A new name",
20 "summary" => "A new bio"
21 }
22
23 {:ok, valid_update, []} = Builder.update(user, object)
24
25 %{user: user, valid_update: valid_update}
26 end
27
28 test "validates a basic object", %{valid_update: valid_update} do
29 assert {:ok, _update, []} = ObjectValidator.validate(valid_update, [])
30 end
31
32 test "returns an error if the object can't be updated by the actor", %{
33 valid_update: valid_update
34 } do
35 other_user = insert(:user)
36
37 update =
38 valid_update
39 |> Map.put("actor", other_user.ap_id)
40
41 assert {:error, _cng} = ObjectValidator.validate(update, [])
42 end
43 end
44 end