1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule HttpRequestMock do
8 def activitypub_object_headers, do: [{"content-type", "application/activity+json"}]
19 with {:ok, res} <- apply(__MODULE__, method, [url, query, body, headers]) do
23 with {:error, message} <- error do
24 Logger.warn(to_string(message))
33 def get(url, query \\ [], body \\ [], headers \\ [])
35 def get("https://osada.macgirvin.com/channel/mike", _, _, _) do
39 body: File.read!("test/fixtures/tesla_mock/https___osada.macgirvin.com_channel_mike.json"),
40 headers: activitypub_object_headers()
44 def get("https://shitposter.club/users/moonman", _, _, _) do
48 body: File.read!("test/fixtures/tesla_mock/moonman@shitposter.club.json"),
49 headers: activitypub_object_headers()
53 def get("https://mastodon.social/users/emelie/statuses/101849165031453009", _, _, _) do
57 body: File.read!("test/fixtures/tesla_mock/status.emelie.json"),
58 headers: activitypub_object_headers()
62 def get("https://mastodon.social/users/emelie/statuses/101849165031453404", _, _, _) do
70 def get("https://mastodon.social/users/emelie", _, _, _) do
74 body: File.read!("test/fixtures/tesla_mock/emelie.json"),
75 headers: activitypub_object_headers()
79 def get("https://mastodon.social/users/not_found", _, _, _) do
80 {:ok, %Tesla.Env{status: 404}}
83 def get("https://mastodon.sdf.org/users/rinpatch", _, _, _) do
87 body: File.read!("test/fixtures/tesla_mock/rinpatch.json"),
88 headers: activitypub_object_headers()
92 def get("https://patch.cx/objects/tesla_mock/poll_attachment", _, _, _) do
96 body: File.read!("test/fixtures/tesla_mock/poll_attachment.json"),
97 headers: activitypub_object_headers()
102 "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/emelie",
110 body: File.read!("test/fixtures/tesla_mock/webfinger_emelie.json"),
111 headers: activitypub_object_headers()
116 "https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com",
119 [{"accept", "application/xrd+xml,application/jrd+json"}]
124 body: File.read!("test/fixtures/tesla_mock/mike@osada.macgirvin.com.json"),
125 headers: activitypub_object_headers()
130 "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/29191",
133 [{"accept", "application/xrd+xml,application/jrd+json"}]
138 body: File.read!("test/fixtures/tesla_mock/https___social.heldscal.la_user_29191.xml")
143 "https://pawoo.net/.well-known/webfinger?resource=acct:https://pawoo.net/users/pekorino",
146 [{"accept", "application/xrd+xml,application/jrd+json"}]
151 body: File.read!("test/fixtures/tesla_mock/https___pawoo.net_users_pekorino.xml")
156 "https://social.stopwatchingus-heidelberg.de/.well-known/webfinger?resource=acct:https://social.stopwatchingus-heidelberg.de/user/18330",
159 [{"accept", "application/xrd+xml,application/jrd+json"}]
164 body: File.read!("test/fixtures/tesla_mock/atarifrosch_webfinger.xml")
169 "https://social.heldscal.la/.well-known/webfinger?resource=nonexistant@social.heldscal.la",
172 [{"accept", "application/xrd+xml,application/jrd+json"}]
177 body: File.read!("test/fixtures/tesla_mock/nonexistant@social.heldscal.la.xml")
182 "https://squeet.me/xrd/?uri=acct:lain@squeet.me",
185 [{"accept", "application/xrd+xml,application/jrd+json"}]
190 body: File.read!("test/fixtures/tesla_mock/lain_squeet.me_webfinger.xml")
195 "https://mst3k.interlinked.me/users/luciferMysticus",
198 [{"accept", "application/activity+json"}]
203 body: File.read!("test/fixtures/tesla_mock/lucifermysticus.json"),
204 headers: activitypub_object_headers()
208 def get("https://prismo.news/@mxb", _, _, _) do
212 body: File.read!("test/fixtures/tesla_mock/https___prismo.news__mxb.json"),
213 headers: activitypub_object_headers()
218 "https://hubzilla.example.org/channel/kaniini",
221 [{"accept", "application/activity+json"}]
226 body: File.read!("test/fixtures/tesla_mock/kaniini@hubzilla.example.org.json"),
227 headers: activitypub_object_headers()
231 def get("https://niu.moe/users/rye", _, _, [{"accept", "application/activity+json"}]) do
235 body: File.read!("test/fixtures/tesla_mock/rye.json"),
236 headers: activitypub_object_headers()
240 def get("https://n1u.moe/users/rye", _, _, [{"accept", "application/activity+json"}]) do
244 body: File.read!("test/fixtures/tesla_mock/rye.json"),
245 headers: activitypub_object_headers()
249 def get("http://mastodon.example.org/users/admin/statuses/100787282858396771", _, _, _) do
255 "test/fixtures/tesla_mock/http___mastodon.example.org_users_admin_status_1234.json"
260 def get("https://puckipedia.com/", _, _, [{"accept", "application/activity+json"}]) do
264 body: File.read!("test/fixtures/tesla_mock/puckipedia.com.json"),
265 headers: activitypub_object_headers()
269 def get("https://peertube.moe/accounts/7even", _, _, _) do
273 body: File.read!("test/fixtures/tesla_mock/7even.json"),
274 headers: activitypub_object_headers()
278 def get("https://peertube.stream/accounts/createurs", _, _, _) do
282 body: File.read!("test/fixtures/peertube/actor-person.json"),
283 headers: activitypub_object_headers()
287 def get("https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3", _, _, _) do
291 body: File.read!("test/fixtures/tesla_mock/peertube.moe-vid.json"),
292 headers: activitypub_object_headers()
296 def get("https://framatube.org/accounts/framasoft", _, _, _) do
300 body: File.read!("test/fixtures/tesla_mock/https___framatube.org_accounts_framasoft.json"),
301 headers: activitypub_object_headers()
305 def get("https://framatube.org/videos/watch/6050732a-8a7a-43d4-a6cd-809525a1d206", _, _, _) do
309 body: File.read!("test/fixtures/tesla_mock/framatube.org-video.json"),
310 headers: activitypub_object_headers()
314 def get("https://peertube.social/accounts/craigmaloney", _, _, _) do
318 body: File.read!("test/fixtures/tesla_mock/craigmaloney.json"),
319 headers: activitypub_object_headers()
323 def get("https://peertube.social/videos/watch/278d2b7c-0f38-4aaa-afe6-9ecc0c4a34fe", _, _, _) do
327 body: File.read!("test/fixtures/tesla_mock/peertube-social.json"),
328 headers: activitypub_object_headers()
332 def get("https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39", _, _, [
333 {"accept", "application/activity+json"}
338 body: File.read!("test/fixtures/tesla_mock/mobilizon.org-event.json"),
339 headers: activitypub_object_headers()
343 def get("https://mobilizon.org/@tcit", _, _, [{"accept", "application/activity+json"}]) do
347 body: File.read!("test/fixtures/tesla_mock/mobilizon.org-user.json"),
348 headers: activitypub_object_headers()
352 def get("https://baptiste.gelez.xyz/@/BaptisteGelez", _, _, _) do
356 body: File.read!("test/fixtures/tesla_mock/baptiste.gelex.xyz-user.json"),
357 headers: activitypub_object_headers()
361 def get("https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/", _, _, _) do
365 body: File.read!("test/fixtures/tesla_mock/baptiste.gelex.xyz-article.json"),
366 headers: activitypub_object_headers()
370 def get("https://wedistribute.org/wp-json/pterotype/v1/object/85810", _, _, _) do
374 body: File.read!("test/fixtures/tesla_mock/wedistribute-article.json"),
375 headers: activitypub_object_headers()
379 def get("https://wedistribute.org/wp-json/pterotype/v1/actor/-blog", _, _, _) do
383 body: File.read!("test/fixtures/tesla_mock/wedistribute-user.json"),
384 headers: activitypub_object_headers()
388 def get("http://mastodon.example.org/users/admin", _, _, _) do
392 body: File.read!("test/fixtures/tesla_mock/admin@mastdon.example.org.json"),
393 headers: activitypub_object_headers()
397 def get("http://mastodon.example.org/users/relay", _, _, [
398 {"accept", "application/activity+json"}
403 body: File.read!("test/fixtures/tesla_mock/relay@mastdon.example.org.json"),
404 headers: activitypub_object_headers()
408 def get("http://mastodon.example.org/users/gargron", _, _, [
409 {"accept", "application/activity+json"}
414 def get("http://osada.macgirvin.com/.well-known/host-meta", _, _, _) do
422 def get("https://osada.macgirvin.com/.well-known/host-meta", _, _, _) do
430 def get("http://mastodon.sdf.org/.well-known/host-meta", _, _, _) do
434 body: File.read!("test/fixtures/tesla_mock/sdf.org_host_meta")
438 def get("https://mastodon.sdf.org/.well-known/host-meta", _, _, _) do
442 body: File.read!("test/fixtures/tesla_mock/sdf.org_host_meta")
447 "https://mastodon.sdf.org/.well-known/webfinger?resource=https://mastodon.sdf.org/users/snowdusk",
455 body: File.read!("test/fixtures/tesla_mock/snowdusk@sdf.org_host_meta.json")
459 def get("http://mstdn.jp/.well-known/host-meta", _, _, _) do
463 body: File.read!("test/fixtures/tesla_mock/mstdn.jp_host_meta")
467 def get("https://mstdn.jp/.well-known/host-meta", _, _, _) do
471 body: File.read!("test/fixtures/tesla_mock/mstdn.jp_host_meta")
475 def get("https://mstdn.jp/.well-known/webfinger?resource=kpherox@mstdn.jp", _, _, _) do
479 body: File.read!("test/fixtures/tesla_mock/kpherox@mstdn.jp.xml")
483 def get("http://mamot.fr/.well-known/host-meta", _, _, _) do
487 body: File.read!("test/fixtures/tesla_mock/mamot.fr_host_meta")
491 def get("https://mamot.fr/.well-known/host-meta", _, _, _) do
495 body: File.read!("test/fixtures/tesla_mock/mamot.fr_host_meta")
499 def get("http://pawoo.net/.well-known/host-meta", _, _, _) do
503 body: File.read!("test/fixtures/tesla_mock/pawoo.net_host_meta")
507 def get("https://pawoo.net/.well-known/host-meta", _, _, _) do
511 body: File.read!("test/fixtures/tesla_mock/pawoo.net_host_meta")
516 "https://pawoo.net/.well-known/webfinger?resource=https://pawoo.net/users/pekorino",
524 body: File.read!("test/fixtures/tesla_mock/pekorino@pawoo.net_host_meta.json"),
525 headers: activitypub_object_headers()
529 def get("http://zetsubou.xn--q9jyb4c/.well-known/host-meta", _, _, _) do
533 body: File.read!("test/fixtures/tesla_mock/xn--q9jyb4c_host_meta")
537 def get("https://zetsubou.xn--q9jyb4c/.well-known/host-meta", _, _, _) do
541 body: File.read!("test/fixtures/tesla_mock/xn--q9jyb4c_host_meta")
545 def get("http://pleroma.soykaf.com/.well-known/host-meta", _, _, _) do
549 body: File.read!("test/fixtures/tesla_mock/soykaf.com_host_meta")
553 def get("https://pleroma.soykaf.com/.well-known/host-meta", _, _, _) do
557 body: File.read!("test/fixtures/tesla_mock/soykaf.com_host_meta")
561 def get("http://social.stopwatchingus-heidelberg.de/.well-known/host-meta", _, _, _) do
565 body: File.read!("test/fixtures/tesla_mock/stopwatchingus-heidelberg.de_host_meta")
569 def get("https://social.stopwatchingus-heidelberg.de/.well-known/host-meta", _, _, _) do
573 body: File.read!("test/fixtures/tesla_mock/stopwatchingus-heidelberg.de_host_meta")
578 "http://mastodon.example.org/@admin/99541947525187367",
586 body: File.read!("test/fixtures/mastodon-note-object.json"),
587 headers: activitypub_object_headers()
591 def get("http://mastodon.example.org/@admin/99541947525187368", _, _, _) do
599 def get("https://shitposter.club/notice/7369654", _, _, _) do
603 body: File.read!("test/fixtures/tesla_mock/7369654.html")
607 def get("https://mstdn.io/users/mayuutann", _, _, [{"accept", "application/activity+json"}]) do
611 body: File.read!("test/fixtures/tesla_mock/mayumayu.json"),
612 headers: activitypub_object_headers()
617 "https://mstdn.io/users/mayuutann/statuses/99568293732299394",
620 [{"accept", "application/activity+json"}]
625 body: File.read!("test/fixtures/tesla_mock/mayumayupost.json"),
626 headers: activitypub_object_headers()
630 def get(url, _, _, [{"accept", "application/xrd+xml,application/jrd+json"}])
632 "https://pleroma.soykaf.com/.well-known/webfinger?resource=acct:https://pleroma.soykaf.com/users/lain",
633 "https://pleroma.soykaf.com/.well-known/webfinger?resource=https://pleroma.soykaf.com/users/lain"
638 body: File.read!("test/fixtures/tesla_mock/https___pleroma.soykaf.com_users_lain.xml")
643 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/1",
646 [{"accept", "application/xrd+xml,application/jrd+json"}]
651 body: File.read!("test/fixtures/tesla_mock/https___shitposter.club_user_1.xml")
655 def get("https://testing.pleroma.lol/objects/b319022a-4946-44c5-9de9-34801f95507b", _, _, _) do
656 {:ok, %Tesla.Env{status: 200}}
660 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/5381",
663 [{"accept", "application/xrd+xml,application/jrd+json"}]
668 body: File.read!("test/fixtures/tesla_mock/spc_5381_xrd.xml")
672 def get("http://shitposter.club/.well-known/host-meta", _, _, _) do
676 body: File.read!("test/fixtures/tesla_mock/shitposter.club_host_meta")
680 def get("https://shitposter.club/notice/4027863", _, _, _) do
684 body: File.read!("test/fixtures/tesla_mock/7369654.html")
688 def get("http://social.sakamoto.gq/.well-known/host-meta", _, _, _) do
692 body: File.read!("test/fixtures/tesla_mock/social.sakamoto.gq_host_meta")
697 "https://social.sakamoto.gq/.well-known/webfinger?resource=https://social.sakamoto.gq/users/eal",
700 [{"accept", "application/xrd+xml,application/jrd+json"}]
705 body: File.read!("test/fixtures/tesla_mock/eal_sakamoto.xml")
709 def get("http://mastodon.social/.well-known/host-meta", _, _, _) do
713 body: File.read!("test/fixtures/tesla_mock/mastodon.social_host_meta")
718 "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/lambadalambda",
721 [{"accept", "application/xrd+xml,application/jrd+json"}]
727 File.read!("test/fixtures/tesla_mock/https___mastodon.social_users_lambadalambda.xml")
731 def get("http://gs.example.org/.well-known/host-meta", _, _, _) do
735 body: File.read!("test/fixtures/tesla_mock/gs.example.org_host_meta")
740 "http://gs.example.org/.well-known/webfinger?resource=http://gs.example.org:4040/index.php/user/1",
743 [{"accept", "application/xrd+xml,application/jrd+json"}]
749 File.read!("test/fixtures/tesla_mock/http___gs.example.org_4040_index.php_user_1.xml")
754 "http://gs.example.org:4040/index.php/user/1",
757 [{"accept", "application/activity+json"}]
759 {:ok, %Tesla.Env{status: 406, body: ""}}
762 def get("http://squeet.me/.well-known/host-meta", _, _, _) do
764 %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/squeet.me_host_meta")}}
768 "https://squeet.me/xrd?uri=lain@squeet.me",
771 [{"accept", "application/xrd+xml,application/jrd+json"}]
776 body: File.read!("test/fixtures/tesla_mock/lain_squeet.me_webfinger.xml")
781 "https://social.heldscal.la/.well-known/webfinger?resource=acct:shp@social.heldscal.la",
784 [{"accept", "application/xrd+xml,application/jrd+json"}]
789 body: File.read!("test/fixtures/tesla_mock/shp@social.heldscal.la.xml")
794 "https://social.heldscal.la/.well-known/webfinger?resource=acct:invalid_content@social.heldscal.la",
797 [{"accept", "application/xrd+xml,application/jrd+json"}]
799 {:ok, %Tesla.Env{status: 200, body: ""}}
802 def get("http://framatube.org/.well-known/host-meta", _, _, _) do
806 body: File.read!("test/fixtures/tesla_mock/framatube.org_host_meta")
811 "http://framatube.org/main/xrd?uri=acct:framasoft@framatube.org",
814 [{"accept", "application/xrd+xml,application/jrd+json"}]
819 headers: [{"content-type", "application/json"}],
820 body: File.read!("test/fixtures/tesla_mock/framasoft@framatube.org.json")
824 def get("http://gnusocial.de/.well-known/host-meta", _, _, _) do
828 body: File.read!("test/fixtures/tesla_mock/gnusocial.de_host_meta")
833 "http://gnusocial.de/main/xrd?uri=winterdienst@gnusocial.de",
836 [{"accept", "application/xrd+xml,application/jrd+json"}]
841 body: File.read!("test/fixtures/tesla_mock/winterdienst_webfinger.json"),
842 headers: activitypub_object_headers()
846 def get("http://status.alpicola.com/.well-known/host-meta", _, _, _) do
850 body: File.read!("test/fixtures/tesla_mock/status.alpicola.com_host_meta")
854 def get("http://macgirvin.com/.well-known/host-meta", _, _, _) do
858 body: File.read!("test/fixtures/tesla_mock/macgirvin.com_host_meta")
862 def get("http://gerzilla.de/.well-known/host-meta", _, _, _) do
866 body: File.read!("test/fixtures/tesla_mock/gerzilla.de_host_meta")
871 "https://gerzilla.de/xrd/?uri=acct:kaniini@gerzilla.de",
874 [{"accept", "application/xrd+xml,application/jrd+json"}]
879 headers: [{"content-type", "application/json"}],
880 body: File.read!("test/fixtures/tesla_mock/kaniini@gerzilla.de.json")
885 "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/23211",
893 body: File.read!("test/fixtures/tesla_mock/https___social.heldscal.la_user_23211.xml")
897 def get("http://social.heldscal.la/.well-known/host-meta", _, _, _) do
901 body: File.read!("test/fixtures/tesla_mock/social.heldscal.la_host_meta")
905 def get("https://social.heldscal.la/.well-known/host-meta", _, _, _) do
909 body: File.read!("test/fixtures/tesla_mock/social.heldscal.la_host_meta")
913 def get("https://mastodon.social/users/lambadalambda", _, _, _) do
917 body: File.read!("test/fixtures/lambadalambda.json"),
918 headers: activitypub_object_headers()
922 def get("https://apfed.club/channel/indio", _, _, _) do
926 body: File.read!("test/fixtures/tesla_mock/osada-user-indio.json"),
927 headers: activitypub_object_headers()
931 def get("https://social.heldscal.la/user/23211", _, _, [{"accept", "application/activity+json"}]) do
932 {:ok, Tesla.Mock.json(%{"id" => "https://social.heldscal.la/user/23211"}, status: 200)}
935 def get("http://example.com/ogp", _, _, _) do
936 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
939 def get("https://example.com/ogp", _, _, _) do
940 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
943 def get("https://pleroma.local/notice/9kCP7V", _, _, _) do
944 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
947 def get("http://localhost:4001/users/masto_closed/followers", _, _, _) do
951 body: File.read!("test/fixtures/users_mock/masto_closed_followers.json"),
952 headers: activitypub_object_headers()
956 def get("http://localhost:4001/users/masto_closed/followers?page=1", _, _, _) do
960 body: File.read!("test/fixtures/users_mock/masto_closed_followers_page.json"),
961 headers: activitypub_object_headers()
965 def get("http://localhost:4001/users/masto_closed/following", _, _, _) do
969 body: File.read!("test/fixtures/users_mock/masto_closed_following.json"),
970 headers: activitypub_object_headers()
974 def get("http://localhost:4001/users/masto_closed/following?page=1", _, _, _) do
978 body: File.read!("test/fixtures/users_mock/masto_closed_following_page.json"),
979 headers: activitypub_object_headers()
983 def get("http://localhost:8080/followers/fuser3", _, _, _) do
987 body: File.read!("test/fixtures/users_mock/friendica_followers.json"),
988 headers: activitypub_object_headers()
992 def get("http://localhost:8080/following/fuser3", _, _, _) do
996 body: File.read!("test/fixtures/users_mock/friendica_following.json"),
997 headers: activitypub_object_headers()
1001 def get("http://localhost:4001/users/fuser2/followers", _, _, _) do
1005 body: File.read!("test/fixtures/users_mock/pleroma_followers.json"),
1006 headers: activitypub_object_headers()
1010 def get("http://localhost:4001/users/fuser2/following", _, _, _) do
1014 body: File.read!("test/fixtures/users_mock/pleroma_following.json"),
1015 headers: activitypub_object_headers()
1019 def get("http://domain-with-errors:4001/users/fuser1/followers", _, _, _) do
1027 def get("http://domain-with-errors:4001/users/fuser1/following", _, _, _) do
1035 def get("http://example.com/ogp-missing-data", _, _, _) do
1039 body: File.read!("test/fixtures/rich_media/ogp-missing-data.html")
1043 def get("https://example.com/ogp-missing-data", _, _, _) do
1047 body: File.read!("test/fixtures/rich_media/ogp-missing-data.html")
1051 def get("http://example.com/malformed", _, _, _) do
1053 %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/malformed-data.html")}}
1056 def get("http://example.com/empty", _, _, _) do
1057 {:ok, %Tesla.Env{status: 200, body: "hello"}}
1060 def get("http://404.site" <> _, _, _, _) do
1069 "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=acct:lain@zetsubou.xn--q9jyb4c",
1072 [{"accept", "application/xrd+xml,application/jrd+json"}]
1077 body: File.read!("test/fixtures/lain.xml")
1082 "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=acct:https://zetsubou.xn--q9jyb4c/users/lain",
1085 [{"accept", "application/xrd+xml,application/jrd+json"}]
1090 body: File.read!("test/fixtures/lain.xml")
1095 "https://zetsubou.xn--q9jyb4c/.well-known/host-meta",
1103 body: File.read!("test/fixtures/host-meta-zetsubou.xn--q9jyb4c.xml")
1107 def get("https://info.pleroma.site/activity.json", _, _, [
1108 {"accept", "application/activity+json"}
1113 body: File.read!("test/fixtures/tesla_mock/https__info.pleroma.site_activity.json"),
1114 headers: activitypub_object_headers()
1118 def get("https://info.pleroma.site/activity.json", _, _, _) do
1119 {:ok, %Tesla.Env{status: 404, body: ""}}
1122 def get("https://info.pleroma.site/activity2.json", _, _, [
1123 {"accept", "application/activity+json"}
1128 body: File.read!("test/fixtures/tesla_mock/https__info.pleroma.site_activity2.json"),
1129 headers: activitypub_object_headers()
1133 def get("https://info.pleroma.site/activity2.json", _, _, _) do
1134 {:ok, %Tesla.Env{status: 404, body: ""}}
1137 def get("https://info.pleroma.site/activity3.json", _, _, [
1138 {"accept", "application/activity+json"}
1143 body: File.read!("test/fixtures/tesla_mock/https__info.pleroma.site_activity3.json"),
1144 headers: activitypub_object_headers()
1148 def get("https://info.pleroma.site/activity3.json", _, _, _) do
1149 {:ok, %Tesla.Env{status: 404, body: ""}}
1152 def get("https://mstdn.jp/.well-known/webfinger?resource=acct:kpherox@mstdn.jp", _, _, _) do
1156 body: File.read!("test/fixtures/tesla_mock/kpherox@mstdn.jp.xml")
1160 def get("https://10.111.10.1/notice/9kCP7V", _, _, _) do
1161 {:ok, %Tesla.Env{status: 200, body: ""}}
1164 def get("https://172.16.32.40/notice/9kCP7V", _, _, _) do
1165 {:ok, %Tesla.Env{status: 200, body: ""}}
1168 def get("https://192.168.10.40/notice/9kCP7V", _, _, _) do
1169 {:ok, %Tesla.Env{status: 200, body: ""}}
1172 def get("https://www.patreon.com/posts/mastodon-2-9-and-28121681", _, _, _) do
1173 {:ok, %Tesla.Env{status: 200, body: ""}}
1176 def get("http://mastodon.example.org/@admin/99541947525187367", _, _, _) do
1180 body: File.read!("test/fixtures/mastodon-post-activity.json"),
1181 headers: activitypub_object_headers()
1185 def get("https://info.pleroma.site/activity4.json", _, _, _) do
1186 {:ok, %Tesla.Env{status: 500, body: "Error occurred"}}
1189 def get("http://example.com/rel_me/anchor", _, _, _) do
1190 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor.html")}}
1193 def get("http://example.com/rel_me/anchor_nofollow", _, _, _) do
1194 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor_nofollow.html")}}
1197 def get("http://example.com/rel_me/link", _, _, _) do
1198 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_link.html")}}
1201 def get("http://example.com/rel_me/null", _, _, _) do
1202 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_null.html")}}
1205 def get("https://skippers-bin.com/notes/7x9tmrp97i", _, _, _) do
1209 body: File.read!("test/fixtures/tesla_mock/misskey_poll_no_end_date.json"),
1210 headers: activitypub_object_headers()
1214 def get("https://example.org/emoji/firedfox.png", _, _, _) do
1215 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/image.jpg")}}
1218 def get("https://skippers-bin.com/users/7v1w1r8ce6", _, _, _) do
1222 body: File.read!("test/fixtures/tesla_mock/sjw.json"),
1223 headers: activitypub_object_headers()
1227 def get("https://patch.cx/users/rin", _, _, _) do
1231 body: File.read!("test/fixtures/tesla_mock/rin.json"),
1232 headers: activitypub_object_headers()
1237 "https://channels.tests.funkwhale.audio/federation/music/uploads/42342395-0208-4fee-a38d-259a6dae0871",
1245 body: File.read!("test/fixtures/tesla_mock/funkwhale_audio.json"),
1246 headers: activitypub_object_headers()
1250 def get("https://channels.tests.funkwhale.audio/federation/actors/compositions", _, _, _) do
1254 body: File.read!("test/fixtures/tesla_mock/funkwhale_channel.json"),
1255 headers: activitypub_object_headers()
1259 def get("http://example.com/rel_me/error", _, _, _) do
1260 {:ok, %Tesla.Env{status: 404, body: ""}}
1263 def get("https://relay.mastodon.host/actor", _, _, _) do
1267 body: File.read!("test/fixtures/relay/relay.json"),
1268 headers: activitypub_object_headers()
1272 def get("http://localhost:4001/", _, "", [{"accept", "text/html"}]) do
1273 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/7369654.html")}}
1276 def get("https://osada.macgirvin.com/", _, "", [{"accept", "text/html"}]) do
1280 body: File.read!("test/fixtures/tesla_mock/https___osada.macgirvin.com.html")
1284 def get(url, query, body, headers) do
1286 "Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{
1294 def post(url, query \\ [], body \\ [], headers \\ [])
1296 def post("https://relay.mastodon.host/inbox", _, _, _) do
1297 {:ok, %Tesla.Env{status: 200, body: ""}}
1300 def post("http://example.org/needs_refresh", _, _, _) do
1308 def post("http://mastodon.example.org/inbox", _, _, _) do
1316 def post("https://hubzilla.example.org/inbox", _, _, _) do
1324 def post("http://gs.example.org/index.php/main/salmon/user/1", _, _, _) do
1332 def post("http://200.site" <> _, _, _, _) do
1340 def post("http://connrefused.site" <> _, _, _, _) do
1341 {:error, :connrefused}
1344 def post("http://404.site" <> _, _, _, _) do
1352 def post(url, query, body, headers) do
1354 "Mock response not implemented for POST #{inspect(url)}, #{query}, #{inspect(body)}, #{
1359 # Most of the rich media mocks are missing HEAD requests, so we just return 404.
1361 "https://example.com/ogp",
1362 "https://example.com/ogp-missing-data",
1363 "https://example.com/twitter-card"
1365 def head(url, _query, _body, _headers) when url in @rich_media_mocks do
1366 {:ok, %Tesla.Env{status: 404, body: ""}}
1369 def head(url, query, body, headers) do
1371 "Mock response not implemented for HEAD #{inspect(url)}, #{query}, #{inspect(body)}, #{