logo

pleroma

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

block_validation_test.exs (1051B)


  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.BlockValidationTest do
  5. use Pleroma.DataCase
  6. alias Pleroma.Web.ActivityPub.Builder
  7. alias Pleroma.Web.ActivityPub.ObjectValidator
  8. import Pleroma.Factory
  9. describe "blocks" do
  10. setup do
  11. user = insert(:user, local: false)
  12. blocked = insert(:user)
  13. {:ok, valid_block, []} = Builder.block(user, blocked)
  14. %{user: user, valid_block: valid_block}
  15. end
  16. test "validates a basic object", %{
  17. valid_block: valid_block
  18. } do
  19. assert {:ok, _block, []} = ObjectValidator.validate(valid_block, [])
  20. end
  21. test "returns an error if we don't know the blocked user", %{
  22. valid_block: valid_block
  23. } do
  24. block =
  25. valid_block
  26. |> Map.put("object", "https://gensokyo.2hu/users/raymoo")
  27. assert {:error, _cng} = ObjectValidator.validate(block, [])
  28. end
  29. end
  30. end