diff options
| author | Egor Kislitsyn <egor@kislitsyn.com> | 2019-04-22 13:08:30 +0700 |
|---|---|---|
| committer | Egor Kislitsyn <egor@kislitsyn.com> | 2019-04-22 13:08:30 +0700 |
| commit | e8c2f9a73a37636a9a8ed5c2998617b841f482da (patch) | |
| tree | 4b194e631d2bbb58b8522c3d74a0b0c2ea09fedd /test/object/containment_test.exs | |
| parent | 38926a063a39c4d4387049f5d364f72a9f8bd2de (diff) | |
| parent | 7fcbda702e76b6390076c28832f5aea80086d15a (diff) | |
| download | pleroma-e8c2f9a73a37636a9a8ed5c2998617b841f482da.tar.gz pleroma-e8c2f9a73a37636a9a8ed5c2998617b841f482da.zip | |
Merge remote-tracking branch 'pleroma/develop' into feature/disable-account
Diffstat (limited to 'test/object/containment_test.exs')
| -rw-r--r-- | test/object/containment_test.exs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/object/containment_test.exs b/test/object/containment_test.exs new file mode 100644 index 000000000..452064093 --- /dev/null +++ b/test/object/containment_test.exs @@ -0,0 +1,58 @@ +defmodule Pleroma.Object.ContainmentTest do + use Pleroma.DataCase + + alias Pleroma.Object.Containment + alias Pleroma.User + + import Pleroma.Factory + + describe "general origin containment" do + test "contain_origin_from_id() catches obvious spoofing attempts" do + data = %{ + "id" => "http://example.com/~alyssa/activities/1234.json" + } + + :error = + Containment.contain_origin_from_id( + "http://example.org/~alyssa/activities/1234.json", + data + ) + end + + test "contain_origin_from_id() allows alternate IDs within the same origin domain" do + data = %{ + "id" => "http://example.com/~alyssa/activities/1234.json" + } + + :ok = + Containment.contain_origin_from_id( + "http://example.com/~alyssa/activities/1234", + data + ) + end + + test "contain_origin_from_id() allows matching IDs" do + data = %{ + "id" => "http://example.com/~alyssa/activities/1234.json" + } + + :ok = + Containment.contain_origin_from_id( + "http://example.com/~alyssa/activities/1234.json", + data + ) + end + + test "users cannot be collided through fake direction spoofing attempts" do + _user = + insert(:user, %{ + nickname: "rye@niu.moe", + local: false, + ap_id: "https://niu.moe/users/rye", + follower_address: User.ap_followers(%User{nickname: "rye@niu.moe"}) + }) + + {:error, _} = User.get_or_fetch_by_ap_id("https://n1u.moe/users/rye") + end + end +end |
