logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

update_validation_test.exs (1151B)


  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. defmodule Pleroma.Web.ActivityPub.ObjectValidators.UpdateHandlingTest do
  5. use Pleroma.DataCase
  6. alias Pleroma.Web.ActivityPub.Builder
  7. alias Pleroma.Web.ActivityPub.ObjectValidator
  8. import Pleroma.Factory
  9. describe "updates" do
  10. setup do
  11. user = insert(:user)
  12. object = %{
  13. "id" => user.ap_id,
  14. "name" => "A new name",
  15. "summary" => "A new bio"
  16. }
  17. {:ok, valid_update, []} = Builder.update(user, object)
  18. %{user: user, valid_update: valid_update}
  19. end
  20. test "validates a basic object", %{valid_update: valid_update} do
  21. assert {:ok, _update, []} = ObjectValidator.validate(valid_update, [])
  22. end
  23. test "returns an error if the object can't be updated by the actor", %{
  24. valid_update: valid_update
  25. } do
  26. other_user = insert(:user)
  27. update =
  28. valid_update
  29. |> Map.put("actor", other_user.ap_id)
  30. assert {:error, _cng} = ObjectValidator.validate(update, [])
  31. end
  32. end
  33. end