Fix warnings in object tests
[akkoma] / test / object / fetcher_test.exs
1 defmodule Pleroma.Object.FetcherTest do
2 use Pleroma.DataCase
3
4 alias Pleroma.Activity
5 alias Pleroma.Object
6 alias Pleroma.Object.Fetcher
7
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")
11 end
12
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")
15 end
16
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")
19 end
20 end
21
22 describe "fetching an object" do
23 test "it fetches an object" do
24 {:ok, object} =
25 Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367")
26
27 assert activity = Activity.get_create_activity_by_object_ap_id(object.data["id"])
28 assert activity.data["id"]
29
30 {:ok, object_again} =
31 Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367")
32
33 assert [attachment] = object.data["attachment"]
34 assert is_list(attachment["url"])
35
36 assert object == object_again
37 end
38
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"]
43
44 {:ok, object_again} = Fetcher.fetch_object_from_id("https://shitposter.club/notice/2827873")
45
46 assert object == object_again
47 end
48
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)
52
53 object = Object.get_by_ap_id(object.data["inReplyTo"])
54 assert object
55 end
56 end
57
58 describe "implementation quirks" do
59 test "it can fetch plume articles" do
60 {:ok, object} =
61 Fetcher.fetch_object_from_id(
62 "https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/"
63 )
64
65 assert object
66 end
67
68 test "it can fetch peertube videos" do
69 {:ok, object} =
70 Fetcher.fetch_object_from_id(
71 "https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3"
72 )
73
74 assert object
75 end
76
77 test "all objects with fake directions are rejected by the object fetcher" do
78 {:error, _} =
79 Fetcher.fetch_and_contain_remote_object_from_id(
80 "https://info.pleroma.site/activity4.json"
81 )
82 end
83 end
84 end