1 defmodule Pleroma.Object.ContainmentTest do
4 alias Pleroma.Object.Containment
10 Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
14 describe "general origin containment" do
15 test "contain_origin_from_id() catches obvious spoofing attempts" do
17 "id" => "http://example.com/~alyssa/activities/1234.json"
21 Containment.contain_origin_from_id(
22 "http://example.org/~alyssa/activities/1234.json",
27 test "contain_origin_from_id() allows alternate IDs within the same origin domain" do
29 "id" => "http://example.com/~alyssa/activities/1234.json"
33 Containment.contain_origin_from_id(
34 "http://example.com/~alyssa/activities/1234",
39 test "contain_origin_from_id() allows matching IDs" do
41 "id" => "http://example.com/~alyssa/activities/1234.json"
45 Containment.contain_origin_from_id(
46 "http://example.com/~alyssa/activities/1234.json",
51 test "users cannot be collided through fake direction spoofing attempts" do
54 nickname: "rye@niu.moe",
56 ap_id: "https://niu.moe/users/rye",
57 follower_address: User.ap_followers(%User{nickname: "rye@niu.moe"})
60 {:error, _} = User.get_or_fetch_by_ap_id("https://n1u.moe/users/rye")