1 defmodule Pleroma.Object.FetcherTest do
6 alias Pleroma.Object.Fetcher
8 describe "actor origin containment" do
9 test "it rejects objects with a bogus origin" do
10 {:error, _} = Fetcher.fetch_object_from_id("https://info.pleroma.site/activity.json")
13 test "it rejects objects when attributedTo is wrong (variant 1)" do
14 {:error, _} = Fetcher.fetch_object_from_id("https://info.pleroma.site/activity2.json")
17 test "it rejects objects when attributedTo is wrong (variant 2)" do
18 {:error, _} = Fetcher.fetch_object_from_id("https://info.pleroma.site/activity3.json")
22 describe "fetching an object" do
23 test "it fetches an object" do
25 Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367")
27 assert activity = Activity.get_create_activity_by_object_ap_id(object.data["id"])
28 assert activity.data["id"]
31 Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367")
33 assert [attachment] = object.data["attachment"]
34 assert is_list(attachment["url"])
36 assert object == object_again
39 test "it works with objects only available via Ostatus" do
40 {:ok, object} = Fetcher.fetch_object_from_id("https://shitposter.club/notice/2827873")
41 assert activity = Activity.get_create_activity_by_object_ap_id(object.data["id"])
42 assert activity.data["id"]
44 {:ok, object_again} = Fetcher.fetch_object_from_id("https://shitposter.club/notice/2827873")
46 assert object == object_again
49 test "it correctly stitches up conversations between ostatus and ap" do
50 last = "https://mstdn.io/users/mayuutann/statuses/99568293732299394"
51 {:ok, object} = Fetcher.fetch_object_from_id(last)
53 object = Object.get_by_ap_id(object.data["inReplyTo"])
58 describe "implementation quirks" do
59 test "it can fetch plume articles" do
61 Fetcher.fetch_object_from_id(
62 "https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/"
68 test "it can fetch peertube videos" do
70 Fetcher.fetch_object_from_id(
71 "https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3"
77 test "all objects with fake directions are rejected by the object fetcher" do
79 Fetcher.fetch_and_contain_remote_object_from_id(
80 "https://info.pleroma.site/activity4.json"