diff options
author | Mark Felder <feld@FreeBSD.org> | 2020-07-03 10:36:41 -0500 |
---|---|---|
committer | Mark Felder <feld@FreeBSD.org> | 2020-07-03 10:36:41 -0500 |
commit | 4695bdd81bf9d2caed4337473d35ba021527e8a8 (patch) | |
tree | 0bc60c1bbc03d994701a282f47d32e856b54cff0 /test/web/activity_pub/object_validator_test.exs | |
parent | cc837f9d157f9d43a015a8908f5e2ee178442041 (diff) | |
parent | c2a052a346d5104c3657343a885255d4d7179c75 (diff) | |
download | pleroma-4695bdd81bf9d2caed4337473d35ba021527e8a8.tar.gz pleroma-4695bdd81bf9d2caed4337473d35ba021527e8a8.zip |
Merge branch 'develop' into issue/1790-updated-oban
Diffstat (limited to 'test/web/activity_pub/object_validator_test.exs')
-rw-r--r-- | test/web/activity_pub/object_validator_test.exs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/web/activity_pub/object_validator_test.exs b/test/web/activity_pub/object_validator_test.exs index 31224abe0..f38bf7e08 100644 --- a/test/web/activity_pub/object_validator_test.exs +++ b/test/web/activity_pub/object_validator_test.exs @@ -622,4 +622,63 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do assert {:actor, {"can not announce this object publicly", []}} in cng.errors end end + + describe "updates" do + setup do + user = insert(:user) + + object = %{ + "id" => user.ap_id, + "name" => "A new name", + "summary" => "A new bio" + } + + {:ok, valid_update, []} = Builder.update(user, object) + + %{user: user, valid_update: valid_update} + end + + test "validates a basic object", %{valid_update: valid_update} do + assert {:ok, _update, []} = ObjectValidator.validate(valid_update, []) + end + + test "returns an error if the object can't be updated by the actor", %{ + valid_update: valid_update + } do + other_user = insert(:user) + + update = + valid_update + |> Map.put("actor", other_user.ap_id) + + assert {:error, _cng} = ObjectValidator.validate(update, []) + end + end + + describe "blocks" do + setup do + user = insert(:user, local: false) + 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 end |