X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fobject%2Fcontainment_test.exs;h=7636803a63a97f6f313d91798d40f3ae39874770;hb=646016c403f6ed10f00f9c67b477a231f71aa706;hp=61cd1b41228d896e72f4596789e331ce3e2a2f66;hpb=ffb4eb9779ddd28ecee84c06e8dc58f4a4daaa38;p=akkoma diff --git a/test/object/containment_test.exs b/test/object/containment_test.exs index 61cd1b412..7636803a6 100644 --- a/test/object/containment_test.exs +++ b/test/object/containment_test.exs @@ -17,6 +17,16 @@ defmodule Pleroma.Object.ContainmentTest do end describe "general origin containment" do + test "works for completely actorless posts" do + assert :error == + Containment.contain_origin("https://glaceon.social/users/monorail", %{ + "deleted" => "2019-10-30T05:48:50.249606Z", + "formerType" => "Note", + "id" => "https://glaceon.social/users/monorail/statuses/103049757364029187", + "type" => "Tombstone" + }) + end + test "contain_origin_from_id() catches obvious spoofing attempts" do data = %{ "id" => "http://example.com/~alyssa/activities/1234.json" @@ -65,7 +75,21 @@ defmodule Pleroma.Object.ContainmentTest do assert capture_log(fn -> {:error, _} = User.get_or_fetch_by_ap_id("https://n1u.moe/users/rye") end) =~ - "[error] Could not decode user at fetch https://n1u.moe/users/rye, {:error, :error}" + "[error] Could not decode user at fetch https://n1u.moe/users/rye" + end + + test "contain_origin_from_id() gracefully handles cases where no ID is present" do + data = %{ + "type" => "Create", + "object" => %{ + "id" => "http://example.net/~alyssa/activities/1234", + "attributedTo" => "http://example.org/~alyssa" + }, + "actor" => "http://example.com/~bob" + } + + :error = + Containment.contain_origin_from_id("http://example.net/~alyssa/activities/1234", data) end end