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: [{"content-type", "application/jrd+json"}]
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"),
191 headers: [{"content-type", "application/xrd+xml"}]
196 "https://mst3k.interlinked.me/users/luciferMysticus",
199 [{"accept", "application/activity+json"}]
204 body: File.read!("test/fixtures/tesla_mock/lucifermysticus.json"),
205 headers: activitypub_object_headers()
209 def get("https://prismo.news/@mxb", _, _, _) do
213 body: File.read!("test/fixtures/tesla_mock/https___prismo.news__mxb.json"),
214 headers: activitypub_object_headers()
219 "https://hubzilla.example.org/channel/kaniini",
222 [{"accept", "application/activity+json"}]
227 body: File.read!("test/fixtures/tesla_mock/kaniini@hubzilla.example.org.json"),
228 headers: activitypub_object_headers()
232 def get("https://niu.moe/users/rye", _, _, [{"accept", "application/activity+json"}]) do
236 body: File.read!("test/fixtures/tesla_mock/rye.json"),
237 headers: activitypub_object_headers()
241 def get("https://n1u.moe/users/rye", _, _, [{"accept", "application/activity+json"}]) do
245 body: File.read!("test/fixtures/tesla_mock/rye.json"),
246 headers: activitypub_object_headers()
250 def get("http://mastodon.example.org/users/admin/statuses/100787282858396771", _, _, _) do
256 "test/fixtures/tesla_mock/http___mastodon.example.org_users_admin_status_1234.json"
261 def get("https://puckipedia.com/", _, _, [{"accept", "application/activity+json"}]) do
265 body: File.read!("test/fixtures/tesla_mock/puckipedia.com.json"),
266 headers: activitypub_object_headers()
270 def get("https://peertube.moe/accounts/7even", _, _, _) do
274 body: File.read!("test/fixtures/tesla_mock/7even.json"),
275 headers: activitypub_object_headers()
279 def get("https://peertube.stream/accounts/createurs", _, _, _) do
283 body: File.read!("test/fixtures/peertube/actor-person.json"),
284 headers: activitypub_object_headers()
288 def get("https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3", _, _, _) do
292 body: File.read!("test/fixtures/tesla_mock/peertube.moe-vid.json"),
293 headers: activitypub_object_headers()
297 def get("https://framatube.org/accounts/framasoft", _, _, _) do
301 body: File.read!("test/fixtures/tesla_mock/https___framatube.org_accounts_framasoft.json"),
302 headers: activitypub_object_headers()
306 def get("https://framatube.org/videos/watch/6050732a-8a7a-43d4-a6cd-809525a1d206", _, _, _) do
310 body: File.read!("test/fixtures/tesla_mock/framatube.org-video.json"),
311 headers: activitypub_object_headers()
315 def get("https://peertube.social/accounts/craigmaloney", _, _, _) do
319 body: File.read!("test/fixtures/tesla_mock/craigmaloney.json"),
320 headers: activitypub_object_headers()
324 def get("https://peertube.social/videos/watch/278d2b7c-0f38-4aaa-afe6-9ecc0c4a34fe", _, _, _) do
328 body: File.read!("test/fixtures/tesla_mock/peertube-social.json"),
329 headers: activitypub_object_headers()
333 def get("https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39", _, _, [
334 {"accept", "application/activity+json"}
339 body: File.read!("test/fixtures/tesla_mock/mobilizon.org-event.json"),
340 headers: activitypub_object_headers()
344 def get("https://mobilizon.org/@tcit", _, _, [{"accept", "application/activity+json"}]) do
348 body: File.read!("test/fixtures/tesla_mock/mobilizon.org-user.json"),
349 headers: activitypub_object_headers()
353 def get("https://baptiste.gelez.xyz/@/BaptisteGelez", _, _, _) do
357 body: File.read!("test/fixtures/tesla_mock/baptiste.gelex.xyz-user.json"),
358 headers: activitypub_object_headers()
362 def get("https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/", _, _, _) do
366 body: File.read!("test/fixtures/tesla_mock/baptiste.gelex.xyz-article.json"),
367 headers: activitypub_object_headers()
371 def get("https://wedistribute.org/wp-json/pterotype/v1/object/85810", _, _, _) do
375 body: File.read!("test/fixtures/tesla_mock/wedistribute-article.json"),
376 headers: activitypub_object_headers()
380 def get("https://wedistribute.org/wp-json/pterotype/v1/actor/-blog", _, _, _) do
384 body: File.read!("test/fixtures/tesla_mock/wedistribute-user.json"),
385 headers: activitypub_object_headers()
389 def get("http://mastodon.example.org/users/admin", _, _, _) do
393 body: File.read!("test/fixtures/tesla_mock/admin@mastdon.example.org.json"),
394 headers: activitypub_object_headers()
398 def get("http://mastodon.example.org/users/relay", _, _, [
399 {"accept", "application/activity+json"}
404 body: File.read!("test/fixtures/tesla_mock/relay@mastdon.example.org.json"),
405 headers: activitypub_object_headers()
409 def get("http://mastodon.example.org/users/gargron", _, _, [
410 {"accept", "application/activity+json"}
415 def get("http://osada.macgirvin.com/.well-known/host-meta", _, _, _) do
423 def get("https://osada.macgirvin.com/.well-known/host-meta", _, _, _) do
431 def get("http://mastodon.sdf.org/.well-known/host-meta", _, _, _) do
435 body: File.read!("test/fixtures/tesla_mock/sdf.org_host_meta")
439 def get("https://mastodon.sdf.org/.well-known/host-meta", _, _, _) do
443 body: File.read!("test/fixtures/tesla_mock/sdf.org_host_meta")
448 "https://mastodon.sdf.org/.well-known/webfinger?resource=https://mastodon.sdf.org/users/snowdusk",
456 body: File.read!("test/fixtures/tesla_mock/snowdusk@sdf.org_host_meta.json")
460 def get("http://mstdn.jp/.well-known/host-meta", _, _, _) do
464 body: File.read!("test/fixtures/tesla_mock/mstdn.jp_host_meta")
468 def get("https://mstdn.jp/.well-known/host-meta", _, _, _) do
472 body: File.read!("test/fixtures/tesla_mock/mstdn.jp_host_meta")
476 def get("https://mstdn.jp/.well-known/webfinger?resource=kpherox@mstdn.jp", _, _, _) do
480 body: File.read!("test/fixtures/tesla_mock/kpherox@mstdn.jp.xml")
484 def get("http://mamot.fr/.well-known/host-meta", _, _, _) do
488 body: File.read!("test/fixtures/tesla_mock/mamot.fr_host_meta")
492 def get("https://mamot.fr/.well-known/host-meta", _, _, _) do
496 body: File.read!("test/fixtures/tesla_mock/mamot.fr_host_meta")
500 def get("http://pawoo.net/.well-known/host-meta", _, _, _) do
504 body: File.read!("test/fixtures/tesla_mock/pawoo.net_host_meta")
508 def get("https://pawoo.net/.well-known/host-meta", _, _, _) do
512 body: File.read!("test/fixtures/tesla_mock/pawoo.net_host_meta")
517 "https://pawoo.net/.well-known/webfinger?resource=https://pawoo.net/users/pekorino",
525 body: File.read!("test/fixtures/tesla_mock/pekorino@pawoo.net_host_meta.json"),
526 headers: activitypub_object_headers()
530 def get("http://pleroma.soykaf.com/.well-known/host-meta", _, _, _) do
534 body: File.read!("test/fixtures/tesla_mock/soykaf.com_host_meta")
538 def get("https://pleroma.soykaf.com/.well-known/host-meta", _, _, _) do
542 body: File.read!("test/fixtures/tesla_mock/soykaf.com_host_meta")
546 def get("http://social.stopwatchingus-heidelberg.de/.well-known/host-meta", _, _, _) do
550 body: File.read!("test/fixtures/tesla_mock/stopwatchingus-heidelberg.de_host_meta")
554 def get("https://social.stopwatchingus-heidelberg.de/.well-known/host-meta", _, _, _) do
558 body: File.read!("test/fixtures/tesla_mock/stopwatchingus-heidelberg.de_host_meta")
563 "http://mastodon.example.org/@admin/99541947525187367",
571 body: File.read!("test/fixtures/mastodon-note-object.json"),
572 headers: activitypub_object_headers()
576 def get("http://mastodon.example.org/@admin/99541947525187368", _, _, _) do
584 def get("https://shitposter.club/notice/7369654", _, _, _) do
588 body: File.read!("test/fixtures/tesla_mock/7369654.html")
592 def get("https://mstdn.io/users/mayuutann", _, _, [{"accept", "application/activity+json"}]) do
596 body: File.read!("test/fixtures/tesla_mock/mayumayu.json"),
597 headers: activitypub_object_headers()
602 "https://mstdn.io/users/mayuutann/statuses/99568293732299394",
605 [{"accept", "application/activity+json"}]
610 body: File.read!("test/fixtures/tesla_mock/mayumayupost.json"),
611 headers: activitypub_object_headers()
615 def get(url, _, _, [{"accept", "application/xrd+xml,application/jrd+json"}])
617 "https://pleroma.soykaf.com/.well-known/webfinger?resource=acct:https://pleroma.soykaf.com/users/lain",
618 "https://pleroma.soykaf.com/.well-known/webfinger?resource=https://pleroma.soykaf.com/users/lain"
623 body: File.read!("test/fixtures/tesla_mock/https___pleroma.soykaf.com_users_lain.xml")
628 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/1",
631 [{"accept", "application/xrd+xml,application/jrd+json"}]
636 body: File.read!("test/fixtures/tesla_mock/https___shitposter.club_user_1.xml")
640 def get("https://testing.pleroma.lol/objects/b319022a-4946-44c5-9de9-34801f95507b", _, _, _) do
641 {:ok, %Tesla.Env{status: 200}}
645 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/5381",
648 [{"accept", "application/xrd+xml,application/jrd+json"}]
653 body: File.read!("test/fixtures/tesla_mock/spc_5381_xrd.xml")
657 def get("http://shitposter.club/.well-known/host-meta", _, _, _) do
661 body: File.read!("test/fixtures/tesla_mock/shitposter.club_host_meta")
665 def get("https://shitposter.club/notice/4027863", _, _, _) do
669 body: File.read!("test/fixtures/tesla_mock/7369654.html")
673 def get("http://social.sakamoto.gq/.well-known/host-meta", _, _, _) do
677 body: File.read!("test/fixtures/tesla_mock/social.sakamoto.gq_host_meta")
682 "https://social.sakamoto.gq/.well-known/webfinger?resource=https://social.sakamoto.gq/users/eal",
685 [{"accept", "application/xrd+xml,application/jrd+json"}]
690 body: File.read!("test/fixtures/tesla_mock/eal_sakamoto.xml")
694 def get("http://mastodon.social/.well-known/host-meta", _, _, _) do
698 body: File.read!("test/fixtures/tesla_mock/mastodon.social_host_meta")
703 "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/lambadalambda",
706 [{"accept", "application/xrd+xml,application/jrd+json"}]
712 File.read!("test/fixtures/tesla_mock/https___mastodon.social_users_lambadalambda.xml")
716 def get("http://gs.example.org/.well-known/host-meta", _, _, _) do
720 body: File.read!("test/fixtures/tesla_mock/gs.example.org_host_meta")
725 "http://gs.example.org/.well-known/webfinger?resource=http://gs.example.org:4040/index.php/user/1",
728 [{"accept", "application/xrd+xml,application/jrd+json"}]
734 File.read!("test/fixtures/tesla_mock/http___gs.example.org_4040_index.php_user_1.xml")
739 "http://gs.example.org:4040/index.php/user/1",
742 [{"accept", "application/activity+json"}]
744 {:ok, %Tesla.Env{status: 406, body: ""}}
747 def get("http://squeet.me/.well-known/host-meta", _, _, _) do
749 %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/squeet.me_host_meta")}}
753 "https://squeet.me/xrd?uri=lain@squeet.me",
756 [{"accept", "application/xrd+xml,application/jrd+json"}]
761 body: File.read!("test/fixtures/tesla_mock/lain_squeet.me_webfinger.xml")
766 "https://social.heldscal.la/.well-known/webfinger?resource=acct:shp@social.heldscal.la",
769 [{"accept", "application/xrd+xml,application/jrd+json"}]
774 body: File.read!("test/fixtures/tesla_mock/shp@social.heldscal.la.xml"),
775 headers: [{"content-type", "application/xrd+xml"}]
780 "https://social.heldscal.la/.well-known/webfinger?resource=acct:invalid_content@social.heldscal.la",
783 [{"accept", "application/xrd+xml,application/jrd+json"}]
785 {:ok, %Tesla.Env{status: 200, body: "", headers: [{"content-type", "application/jrd+json"}]}}
788 def get("http://framatube.org/.well-known/host-meta", _, _, _) do
792 body: File.read!("test/fixtures/tesla_mock/framatube.org_host_meta")
797 "http://framatube.org/main/xrd?uri=acct:framasoft@framatube.org",
800 [{"accept", "application/xrd+xml,application/jrd+json"}]
805 headers: [{"content-type", "application/jrd+json"}],
806 body: File.read!("test/fixtures/tesla_mock/framasoft@framatube.org.json")
810 def get("http://gnusocial.de/.well-known/host-meta", _, _, _) do
814 body: File.read!("test/fixtures/tesla_mock/gnusocial.de_host_meta")
819 "http://gnusocial.de/main/xrd?uri=winterdienst@gnusocial.de",
822 [{"accept", "application/xrd+xml,application/jrd+json"}]
827 body: File.read!("test/fixtures/tesla_mock/winterdienst_webfinger.json"),
828 headers: activitypub_object_headers()
832 def get("http://status.alpicola.com/.well-known/host-meta", _, _, _) do
836 body: File.read!("test/fixtures/tesla_mock/status.alpicola.com_host_meta")
840 def get("http://macgirvin.com/.well-known/host-meta", _, _, _) do
844 body: File.read!("test/fixtures/tesla_mock/macgirvin.com_host_meta")
848 def get("http://gerzilla.de/.well-known/host-meta", _, _, _) do
852 body: File.read!("test/fixtures/tesla_mock/gerzilla.de_host_meta")
857 "https://gerzilla.de/xrd/?uri=acct:kaniini@gerzilla.de",
860 [{"accept", "application/xrd+xml,application/jrd+json"}]
865 headers: [{"content-type", "application/jrd+json"}],
866 body: File.read!("test/fixtures/tesla_mock/kaniini@gerzilla.de.json")
871 "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/23211",
879 body: File.read!("test/fixtures/tesla_mock/https___social.heldscal.la_user_23211.xml")
883 def get("http://social.heldscal.la/.well-known/host-meta", _, _, _) do
887 body: File.read!("test/fixtures/tesla_mock/social.heldscal.la_host_meta")
891 def get("https://social.heldscal.la/.well-known/host-meta", _, _, _) do
895 body: File.read!("test/fixtures/tesla_mock/social.heldscal.la_host_meta")
899 def get("https://mastodon.social/users/lambadalambda", _, _, _) do
903 body: File.read!("test/fixtures/lambadalambda.json"),
904 headers: activitypub_object_headers()
908 def get("https://apfed.club/channel/indio", _, _, _) do
912 body: File.read!("test/fixtures/tesla_mock/osada-user-indio.json"),
913 headers: activitypub_object_headers()
917 def get("https://social.heldscal.la/user/23211", _, _, [{"accept", "application/activity+json"}]) do
918 {:ok, Tesla.Mock.json(%{"id" => "https://social.heldscal.la/user/23211"}, status: 200)}
921 def get("http://example.com/ogp", _, _, _) do
922 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
925 def get("https://example.com/ogp", _, _, _) do
926 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
929 def get("https://pleroma.local/notice/9kCP7V", _, _, _) do
930 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
933 def get("http://localhost:4001/users/masto_closed/followers", _, _, _) do
937 body: File.read!("test/fixtures/users_mock/masto_closed_followers.json"),
938 headers: activitypub_object_headers()
942 def get("http://localhost:4001/users/masto_closed/followers?page=1", _, _, _) do
946 body: File.read!("test/fixtures/users_mock/masto_closed_followers_page.json"),
947 headers: activitypub_object_headers()
951 def get("http://localhost:4001/users/masto_closed/following", _, _, _) do
955 body: File.read!("test/fixtures/users_mock/masto_closed_following.json"),
956 headers: activitypub_object_headers()
960 def get("http://localhost:4001/users/masto_closed/following?page=1", _, _, _) do
964 body: File.read!("test/fixtures/users_mock/masto_closed_following_page.json"),
965 headers: activitypub_object_headers()
969 def get("http://localhost:8080/followers/fuser3", _, _, _) do
973 body: File.read!("test/fixtures/users_mock/friendica_followers.json"),
974 headers: activitypub_object_headers()
978 def get("http://localhost:8080/following/fuser3", _, _, _) do
982 body: File.read!("test/fixtures/users_mock/friendica_following.json"),
983 headers: activitypub_object_headers()
987 def get("http://localhost:4001/users/fuser2/followers", _, _, _) do
991 body: File.read!("test/fixtures/users_mock/pleroma_followers.json"),
992 headers: activitypub_object_headers()
996 def get("http://localhost:4001/users/fuser2/following", _, _, _) do
1000 body: File.read!("test/fixtures/users_mock/pleroma_following.json"),
1001 headers: activitypub_object_headers()
1005 def get("http://domain-with-errors:4001/users/fuser1/followers", _, _, _) do
1013 def get("http://domain-with-errors:4001/users/fuser1/following", _, _, _) do
1021 def get("http://example.com/ogp-missing-data", _, _, _) do
1025 body: File.read!("test/fixtures/rich_media/ogp-missing-data.html")
1029 def get("https://example.com/ogp-missing-data", _, _, _) do
1033 body: File.read!("test/fixtures/rich_media/ogp-missing-data.html")
1037 def get("http://example.com/malformed", _, _, _) do
1039 %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/malformed-data.html")}}
1042 def get("http://example.com/empty", _, _, _) do
1043 {:ok, %Tesla.Env{status: 200, body: "hello"}}
1046 def get("http://404.site" <> _, _, _, _) do
1055 "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=acct:lain@zetsubou.xn--q9jyb4c",
1058 [{"accept", "application/xrd+xml,application/jrd+json"}]
1063 body: File.read!("test/fixtures/lain.xml"),
1064 headers: [{"content-type", "application/xrd+xml"}]
1069 "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=acct:https://zetsubou.xn--q9jyb4c/users/lain",
1072 [{"accept", "application/xrd+xml,application/jrd+json"}]
1077 body: File.read!("test/fixtures/lain.xml"),
1078 headers: [{"content-type", "application/xrd+xml"}]
1082 def get("http://zetsubou.xn--q9jyb4c/.well-known/host-meta", _, _, _) do
1086 body: File.read!("test/fixtures/host-meta-zetsubou.xn--q9jyb4c.xml")
1091 "https://zetsubou.xn--q9jyb4c/.well-known/host-meta",
1099 body: File.read!("test/fixtures/host-meta-zetsubou.xn--q9jyb4c.xml")
1103 def get("https://info.pleroma.site/activity.json", _, _, [
1104 {"accept", "application/activity+json"}
1109 body: File.read!("test/fixtures/tesla_mock/https__info.pleroma.site_activity.json"),
1110 headers: activitypub_object_headers()
1114 def get("https://info.pleroma.site/activity.json", _, _, _) do
1115 {:ok, %Tesla.Env{status: 404, body: ""}}
1118 def get("https://info.pleroma.site/activity2.json", _, _, [
1119 {"accept", "application/activity+json"}
1124 body: File.read!("test/fixtures/tesla_mock/https__info.pleroma.site_activity2.json"),
1125 headers: activitypub_object_headers()
1129 def get("https://info.pleroma.site/activity2.json", _, _, _) do
1130 {:ok, %Tesla.Env{status: 404, body: ""}}
1133 def get("https://info.pleroma.site/activity3.json", _, _, [
1134 {"accept", "application/activity+json"}
1139 body: File.read!("test/fixtures/tesla_mock/https__info.pleroma.site_activity3.json"),
1140 headers: activitypub_object_headers()
1144 def get("https://info.pleroma.site/activity3.json", _, _, _) do
1145 {:ok, %Tesla.Env{status: 404, body: ""}}
1148 def get("https://mstdn.jp/.well-known/webfinger?resource=acct:kpherox@mstdn.jp", _, _, _) do
1152 body: File.read!("test/fixtures/tesla_mock/kpherox@mstdn.jp.xml"),
1153 headers: [{"content-type", "application/xrd+xml"}]
1157 def get("https://10.111.10.1/notice/9kCP7V", _, _, _) do
1158 {:ok, %Tesla.Env{status: 200, body: ""}}
1161 def get("https://172.16.32.40/notice/9kCP7V", _, _, _) do
1162 {:ok, %Tesla.Env{status: 200, body: ""}}
1165 def get("https://192.168.10.40/notice/9kCP7V", _, _, _) do
1166 {:ok, %Tesla.Env{status: 200, body: ""}}
1169 def get("https://www.patreon.com/posts/mastodon-2-9-and-28121681", _, _, _) do
1170 {:ok, %Tesla.Env{status: 200, body: ""}}
1173 def get("http://mastodon.example.org/@admin/99541947525187367", _, _, _) do
1177 body: File.read!("test/fixtures/mastodon-post-activity.json"),
1178 headers: activitypub_object_headers()
1182 def get("https://info.pleroma.site/activity4.json", _, _, _) do
1183 {:ok, %Tesla.Env{status: 500, body: "Error occurred"}}
1186 def get("http://example.com/rel_me/anchor", _, _, _) do
1187 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor.html")}}
1190 def get("http://example.com/rel_me/anchor_nofollow", _, _, _) do
1191 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor_nofollow.html")}}
1194 def get("http://example.com/rel_me/link", _, _, _) do
1195 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_link.html")}}
1198 def get("http://example.com/rel_me/null", _, _, _) do
1199 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_null.html")}}
1202 def get("https://skippers-bin.com/notes/7x9tmrp97i", _, _, _) do
1206 body: File.read!("test/fixtures/tesla_mock/misskey_poll_no_end_date.json"),
1207 headers: activitypub_object_headers()
1211 def get("https://example.org/emoji/firedfox.png", _, _, _) do
1212 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/image.jpg")}}
1215 def get("https://skippers-bin.com/users/7v1w1r8ce6", _, _, _) do
1219 body: File.read!("test/fixtures/tesla_mock/sjw.json"),
1220 headers: activitypub_object_headers()
1224 def get("https://patch.cx/users/rin", _, _, _) do
1228 body: File.read!("test/fixtures/tesla_mock/rin.json"),
1229 headers: activitypub_object_headers()
1234 "https://channels.tests.funkwhale.audio/federation/music/uploads/42342395-0208-4fee-a38d-259a6dae0871",
1242 body: File.read!("test/fixtures/tesla_mock/funkwhale_audio.json"),
1243 headers: activitypub_object_headers()
1247 def get("https://channels.tests.funkwhale.audio/federation/actors/compositions", _, _, _) do
1251 body: File.read!("test/fixtures/tesla_mock/funkwhale_channel.json"),
1252 headers: activitypub_object_headers()
1256 def get("http://example.com/rel_me/error", _, _, _) do
1257 {:ok, %Tesla.Env{status: 404, body: ""}}
1260 def get("https://relay.mastodon.host/actor", _, _, _) do
1264 body: File.read!("test/fixtures/relay/relay.json"),
1265 headers: activitypub_object_headers()
1269 def get("http://localhost:4001/", _, "", [{"accept", "text/html"}]) do
1270 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/7369654.html")}}
1273 def get("https://osada.macgirvin.com/", _, "", [{"accept", "text/html"}]) do
1277 body: File.read!("test/fixtures/tesla_mock/https___osada.macgirvin.com.html")
1281 def get("https://patch.cx/objects/a399c28e-c821-4820-bc3e-4afeb044c16f", _, _, _) do
1285 body: File.read!("test/fixtures/tesla_mock/emoji-in-summary.json"),
1286 headers: activitypub_object_headers()
1290 def get(url, query, body, headers) do
1292 "Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{
1300 def post(url, query \\ [], body \\ [], headers \\ [])
1302 def post("https://relay.mastodon.host/inbox", _, _, _) do
1303 {:ok, %Tesla.Env{status: 200, body: ""}}
1306 def post("http://example.org/needs_refresh", _, _, _) do
1314 def post("http://mastodon.example.org/inbox", _, _, _) do
1322 def post("https://hubzilla.example.org/inbox", _, _, _) do
1330 def post("http://gs.example.org/index.php/main/salmon/user/1", _, _, _) do
1338 def post("http://200.site" <> _, _, _, _) do
1346 def post("http://connrefused.site" <> _, _, _, _) do
1347 {:error, :connrefused}
1350 def post("http://404.site" <> _, _, _, _) do
1358 def post(url, query, body, headers) do
1360 "Mock response not implemented for POST #{inspect(url)}, #{query}, #{inspect(body)}, #{
1365 # Most of the rich media mocks are missing HEAD requests, so we just return 404.
1367 "https://example.com/ogp",
1368 "https://example.com/ogp-missing-data",
1369 "https://example.com/twitter-card"
1371 def head(url, _query, _body, _headers) when url in @rich_media_mocks do
1372 {:ok, %Tesla.Env{status: 404, body: ""}}
1375 def head(url, query, body, headers) do
1377 "Mock response not implemented for HEAD #{inspect(url)}, #{query}, #{inspect(body)}, #{