2020-07-06 10:59:06 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-10-17 16:36:52 +00:00
|
|
|
defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
|
|
|
|
use Pleroma.DataCase
|
|
|
|
|
2020-04-20 10:29:19 +00:00
|
|
|
alias Pleroma.Web.ActivityPub.Builder
|
2019-10-17 16:36:52 +00:00
|
|
|
alias Pleroma.Web.ActivityPub.ObjectValidator
|
2019-10-23 10:18:05 +00:00
|
|
|
|
2019-10-17 16:36:52 +00:00
|
|
|
import Pleroma.Factory
|
|
|
|
|
2020-06-25 09:13:35 +00:00
|
|
|
describe "blocks" do
|
|
|
|
setup do
|
2020-06-26 09:58:40 +00:00
|
|
|
user = insert(:user, local: false)
|
2020-06-25 09:13:35 +00:00
|
|
|
blocked = insert(:user)
|
|
|
|
|
|
|
|
{:ok, valid_block, []} = Builder.block(user, blocked)
|
|
|
|
|
|
|
|
%{user: user, valid_block: valid_block}
|
|
|
|
end
|
|
|
|
|
|
|
|
test "validates a basic object", %{
|
|
|
|
valid_block: valid_block
|
|
|
|
} do
|
|
|
|
assert {:ok, _block, []} = ObjectValidator.validate(valid_block, [])
|
|
|
|
end
|
|
|
|
|
|
|
|
test "returns an error if we don't know the blocked user", %{
|
|
|
|
valid_block: valid_block
|
|
|
|
} do
|
|
|
|
block =
|
|
|
|
valid_block
|
|
|
|
|> Map.put("object", "https://gensokyo.2hu/users/raymoo")
|
|
|
|
|
|
|
|
assert {:error, _cng} = ObjectValidator.validate(block, [])
|
|
|
|
end
|
|
|
|
end
|
2019-10-17 16:36:52 +00:00
|
|
|
end
|