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://mastodon.sdf.org/users/rinpatch/collections/featured", _, _, _) do
97 File.read!("test/fixtures/users_mock/masto_featured.json")
98 |> String.replace("{{domain}}", "mastodon.sdf.org")
99 |> String.replace("{{nickname}}", "rinpatch"),
100 headers: [{"content-type", "application/activity+json"}]
104 def get("https://patch.cx/objects/tesla_mock/poll_attachment", _, _, _) do
108 body: File.read!("test/fixtures/tesla_mock/poll_attachment.json"),
109 headers: activitypub_object_headers()
114 "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/emelie",
122 body: File.read!("test/fixtures/tesla_mock/webfinger_emelie.json"),
123 headers: activitypub_object_headers()
128 "https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com",
131 [{"accept", "application/xrd+xml,application/jrd+json"}]
136 body: File.read!("test/fixtures/tesla_mock/mike@osada.macgirvin.com.json"),
137 headers: [{"content-type", "application/jrd+json"}]
142 "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/29191",
145 [{"accept", "application/xrd+xml,application/jrd+json"}]
150 body: File.read!("test/fixtures/tesla_mock/https___social.heldscal.la_user_29191.xml")
155 "https://pawoo.net/.well-known/webfinger?resource=acct:https://pawoo.net/users/pekorino",
158 [{"accept", "application/xrd+xml,application/jrd+json"}]
163 body: File.read!("test/fixtures/tesla_mock/https___pawoo.net_users_pekorino.xml")
168 "https://social.stopwatchingus-heidelberg.de/.well-known/webfinger?resource=acct:https://social.stopwatchingus-heidelberg.de/user/18330",
171 [{"accept", "application/xrd+xml,application/jrd+json"}]
176 body: File.read!("test/fixtures/tesla_mock/atarifrosch_webfinger.xml")
181 "https://social.heldscal.la/.well-known/webfinger?resource=nonexistant@social.heldscal.la",
184 [{"accept", "application/xrd+xml,application/jrd+json"}]
189 body: File.read!("test/fixtures/tesla_mock/nonexistant@social.heldscal.la.xml")
194 "https://squeet.me/xrd/?uri=acct:lain@squeet.me",
197 [{"accept", "application/xrd+xml,application/jrd+json"}]
202 body: File.read!("test/fixtures/tesla_mock/lain_squeet.me_webfinger.xml"),
203 headers: [{"content-type", "application/xrd+xml"}]
208 "https://mst3k.interlinked.me/users/luciferMysticus",
211 [{"accept", "application/activity+json"}]
216 body: File.read!("test/fixtures/tesla_mock/lucifermysticus.json"),
217 headers: activitypub_object_headers()
221 def get("https://prismo.news/@mxb", _, _, _) do
225 body: File.read!("test/fixtures/tesla_mock/https___prismo.news__mxb.json"),
226 headers: activitypub_object_headers()
231 "https://hubzilla.example.org/channel/kaniini",
234 [{"accept", "application/activity+json"}]
239 body: File.read!("test/fixtures/tesla_mock/kaniini@hubzilla.example.org.json"),
240 headers: activitypub_object_headers()
244 def get("https://niu.moe/users/rye", _, _, [{"accept", "application/activity+json"}]) do
248 body: File.read!("test/fixtures/tesla_mock/rye.json"),
249 headers: activitypub_object_headers()
253 def get("https://n1u.moe/users/rye", _, _, [{"accept", "application/activity+json"}]) do
257 body: File.read!("test/fixtures/tesla_mock/rye.json"),
258 headers: activitypub_object_headers()
262 def get("http://mastodon.example.org/users/admin/statuses/100787282858396771", _, _, _) do
268 "test/fixtures/tesla_mock/http___mastodon.example.org_users_admin_status_1234.json"
273 def get("https://puckipedia.com/", _, _, [{"accept", "application/activity+json"}]) do
277 body: File.read!("test/fixtures/tesla_mock/puckipedia.com.json"),
278 headers: activitypub_object_headers()
282 def get("https://peertube.moe/accounts/7even", _, _, _) do
286 body: File.read!("test/fixtures/tesla_mock/7even.json"),
287 headers: activitypub_object_headers()
291 def get("https://peertube.stream/accounts/createurs", _, _, _) do
295 body: File.read!("test/fixtures/peertube/actor-person.json"),
296 headers: activitypub_object_headers()
300 def get("https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3", _, _, _) do
304 body: File.read!("test/fixtures/tesla_mock/peertube.moe-vid.json"),
305 headers: activitypub_object_headers()
309 def get("https://framatube.org/accounts/framasoft", _, _, _) do
313 body: File.read!("test/fixtures/tesla_mock/https___framatube.org_accounts_framasoft.json"),
314 headers: activitypub_object_headers()
318 def get("https://framatube.org/videos/watch/6050732a-8a7a-43d4-a6cd-809525a1d206", _, _, _) do
322 body: File.read!("test/fixtures/tesla_mock/framatube.org-video.json"),
323 headers: activitypub_object_headers()
327 def get("https://peertube.social/accounts/craigmaloney", _, _, _) do
331 body: File.read!("test/fixtures/tesla_mock/craigmaloney.json"),
332 headers: activitypub_object_headers()
336 def get("https://peertube.social/videos/watch/278d2b7c-0f38-4aaa-afe6-9ecc0c4a34fe", _, _, _) do
340 body: File.read!("test/fixtures/tesla_mock/peertube-social.json"),
341 headers: activitypub_object_headers()
345 def get("https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39", _, _, [
346 {"accept", "application/activity+json"}
351 body: File.read!("test/fixtures/tesla_mock/mobilizon.org-event.json"),
352 headers: activitypub_object_headers()
356 def get("https://mobilizon.org/@tcit", _, _, [{"accept", "application/activity+json"}]) do
360 body: File.read!("test/fixtures/tesla_mock/mobilizon.org-user.json"),
361 headers: activitypub_object_headers()
365 def get("https://baptiste.gelez.xyz/@/BaptisteGelez", _, _, _) do
369 body: File.read!("test/fixtures/tesla_mock/baptiste.gelex.xyz-user.json"),
370 headers: activitypub_object_headers()
374 def get("https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/", _, _, _) do
378 body: File.read!("test/fixtures/tesla_mock/baptiste.gelex.xyz-article.json"),
379 headers: activitypub_object_headers()
383 def get("https://wedistribute.org/wp-json/pterotype/v1/object/85810", _, _, _) do
387 body: File.read!("test/fixtures/tesla_mock/wedistribute-article.json"),
388 headers: activitypub_object_headers()
392 def get("https://wedistribute.org/wp-json/pterotype/v1/actor/-blog", _, _, _) do
396 body: File.read!("test/fixtures/tesla_mock/wedistribute-user.json"),
397 headers: activitypub_object_headers()
401 def get("http://mastodon.example.org/users/admin", _, _, _) do
405 body: File.read!("test/fixtures/tesla_mock/admin@mastdon.example.org.json"),
406 headers: activitypub_object_headers()
411 "http://mastodon.example.org/users/admin/statuses/99512778738411822/replies?min_id=99512778738411824&page=true",
416 {:ok, %Tesla.Env{status: 404, body: ""}}
419 def get("http://mastodon.example.org/users/relay", _, _, [
420 {"accept", "application/activity+json"}
425 body: File.read!("test/fixtures/tesla_mock/relay@mastdon.example.org.json"),
426 headers: activitypub_object_headers()
430 def get("http://mastodon.example.org/users/gargron", _, _, [
431 {"accept", "application/activity+json"}
436 def get("https://osada.macgirvin.com/.well-known/host-meta", _, _, _) do
444 def get("http://mastodon.sdf.org/.well-known/host-meta", _, _, _) do
448 body: File.read!("test/fixtures/tesla_mock/sdf.org_host_meta")
452 def get("https://mastodon.sdf.org/.well-known/host-meta", _, _, _) do
456 body: File.read!("test/fixtures/tesla_mock/sdf.org_host_meta")
461 "https://mastodon.sdf.org/.well-known/webfinger?resource=https://mastodon.sdf.org/users/snowdusk",
469 body: File.read!("test/fixtures/tesla_mock/snowdusk@sdf.org_host_meta.json")
473 def get("http://mstdn.jp/.well-known/host-meta", _, _, _) do
477 body: File.read!("test/fixtures/tesla_mock/mstdn.jp_host_meta")
481 def get("https://mstdn.jp/.well-known/host-meta", _, _, _) do
485 body: File.read!("test/fixtures/tesla_mock/mstdn.jp_host_meta")
489 def get("https://mstdn.jp/.well-known/webfinger?resource=kpherox@mstdn.jp", _, _, _) do
493 body: File.read!("test/fixtures/tesla_mock/kpherox@mstdn.jp.xml")
497 def get("http://mamot.fr/.well-known/host-meta", _, _, _) do
501 body: File.read!("test/fixtures/tesla_mock/mamot.fr_host_meta")
505 def get("https://mamot.fr/.well-known/host-meta", _, _, _) do
509 body: File.read!("test/fixtures/tesla_mock/mamot.fr_host_meta")
513 def get("http://pawoo.net/.well-known/host-meta", _, _, _) do
517 body: File.read!("test/fixtures/tesla_mock/pawoo.net_host_meta")
521 def get("https://pawoo.net/.well-known/host-meta", _, _, _) do
525 body: File.read!("test/fixtures/tesla_mock/pawoo.net_host_meta")
530 "https://pawoo.net/.well-known/webfinger?resource=https://pawoo.net/users/pekorino",
538 body: File.read!("test/fixtures/tesla_mock/pekorino@pawoo.net_host_meta.json"),
539 headers: activitypub_object_headers()
543 def get("http://pleroma.soykaf.com/.well-known/host-meta", _, _, _) do
547 body: File.read!("test/fixtures/tesla_mock/soykaf.com_host_meta")
551 def get("https://pleroma.soykaf.com/.well-known/host-meta", _, _, _) do
555 body: File.read!("test/fixtures/tesla_mock/soykaf.com_host_meta")
559 def get("http://social.stopwatchingus-heidelberg.de/.well-known/host-meta", _, _, _) do
563 body: File.read!("test/fixtures/tesla_mock/stopwatchingus-heidelberg.de_host_meta")
567 def get("https://social.stopwatchingus-heidelberg.de/.well-known/host-meta", _, _, _) do
571 body: File.read!("test/fixtures/tesla_mock/stopwatchingus-heidelberg.de_host_meta")
576 "http://mastodon.example.org/@admin/99541947525187367",
584 body: File.read!("test/fixtures/mastodon-note-object.json"),
585 headers: activitypub_object_headers()
589 def get("http://mastodon.example.org/@admin/99541947525187368", _, _, _) do
597 def get("https://shitposter.club/notice/7369654", _, _, _) do
601 body: File.read!("test/fixtures/tesla_mock/7369654.html")
605 def get("https://mstdn.io/users/mayuutann", _, _, [{"accept", "application/activity+json"}]) do
609 body: File.read!("test/fixtures/tesla_mock/mayumayu.json"),
610 headers: activitypub_object_headers()
615 "https://mstdn.io/users/mayuutann/statuses/99568293732299394",
618 [{"accept", "application/activity+json"}]
623 body: File.read!("test/fixtures/tesla_mock/mayumayupost.json"),
624 headers: activitypub_object_headers()
628 def get(url, _, _, [{"accept", "application/xrd+xml,application/jrd+json"}])
630 "https://pleroma.soykaf.com/.well-known/webfinger?resource=acct:https://pleroma.soykaf.com/users/lain",
631 "https://pleroma.soykaf.com/.well-known/webfinger?resource=https://pleroma.soykaf.com/users/lain"
636 body: File.read!("test/fixtures/tesla_mock/https___pleroma.soykaf.com_users_lain.xml")
641 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/1",
644 [{"accept", "application/xrd+xml,application/jrd+json"}]
649 body: File.read!("test/fixtures/tesla_mock/https___shitposter.club_user_1.xml")
653 def get("https://testing.pleroma.lol/objects/b319022a-4946-44c5-9de9-34801f95507b", _, _, _) do
654 {:ok, %Tesla.Env{status: 200}}
658 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/5381",
661 [{"accept", "application/xrd+xml,application/jrd+json"}]
666 body: File.read!("test/fixtures/tesla_mock/spc_5381_xrd.xml")
670 def get("http://shitposter.club/.well-known/host-meta", _, _, _) do
674 body: File.read!("test/fixtures/tesla_mock/shitposter.club_host_meta")
678 def get("https://shitposter.club/notice/4027863", _, _, _) do
682 body: File.read!("test/fixtures/tesla_mock/7369654.html")
686 def get("http://social.sakamoto.gq/.well-known/host-meta", _, _, _) do
690 body: File.read!("test/fixtures/tesla_mock/social.sakamoto.gq_host_meta")
695 "https://social.sakamoto.gq/.well-known/webfinger?resource=https://social.sakamoto.gq/users/eal",
698 [{"accept", "application/xrd+xml,application/jrd+json"}]
703 body: File.read!("test/fixtures/tesla_mock/eal_sakamoto.xml")
707 def get("http://mastodon.social/.well-known/host-meta", _, _, _) do
711 body: File.read!("test/fixtures/tesla_mock/mastodon.social_host_meta")
716 "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/lambadalambda",
719 [{"accept", "application/xrd+xml,application/jrd+json"}]
725 File.read!("test/fixtures/tesla_mock/https___mastodon.social_users_lambadalambda.xml")
730 "https://mastodon.social/.well-known/webfinger?resource=acct:not_found@mastodon.social",
733 [{"accept", "application/xrd+xml,application/jrd+json"}]
735 {:ok, %Tesla.Env{status: 404}}
738 def get("http://gs.example.org/.well-known/host-meta", _, _, _) do
742 body: File.read!("test/fixtures/tesla_mock/gs.example.org_host_meta")
747 "http://gs.example.org/.well-known/webfinger?resource=http://gs.example.org:4040/index.php/user/1",
750 [{"accept", "application/xrd+xml,application/jrd+json"}]
756 File.read!("test/fixtures/tesla_mock/http___gs.example.org_4040_index.php_user_1.xml")
761 "http://gs.example.org:4040/index.php/user/1",
764 [{"accept", "application/activity+json"}]
766 {:ok, %Tesla.Env{status: 406, body: ""}}
769 def get("https://squeet.me/.well-known/host-meta", _, _, _) do
771 %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/squeet.me_host_meta")}}
775 "https://squeet.me/xrd?uri=lain@squeet.me",
778 [{"accept", "application/xrd+xml,application/jrd+json"}]
783 body: File.read!("test/fixtures/tesla_mock/lain_squeet.me_webfinger.xml")
788 "https://social.heldscal.la/.well-known/webfinger?resource=acct:shp@social.heldscal.la",
791 [{"accept", "application/xrd+xml,application/jrd+json"}]
796 body: File.read!("test/fixtures/tesla_mock/shp@social.heldscal.la.xml"),
797 headers: [{"content-type", "application/xrd+xml"}]
802 "https://social.heldscal.la/.well-known/webfinger?resource=acct:invalid_content@social.heldscal.la",
805 [{"accept", "application/xrd+xml,application/jrd+json"}]
807 {:ok, %Tesla.Env{status: 200, body: "", headers: [{"content-type", "application/jrd+json"}]}}
810 def get("https://framatube.org/.well-known/host-meta", _, _, _) do
814 body: File.read!("test/fixtures/tesla_mock/framatube.org_host_meta")
819 "https://framatube.org/main/xrd?uri=acct:framasoft@framatube.org",
822 [{"accept", "application/xrd+xml,application/jrd+json"}]
827 headers: [{"content-type", "application/jrd+json"}],
828 body: File.read!("test/fixtures/tesla_mock/framasoft@framatube.org.json")
832 def get("http://gnusocial.de/.well-known/host-meta", _, _, _) do
836 body: File.read!("test/fixtures/tesla_mock/gnusocial.de_host_meta")
841 "http://gnusocial.de/main/xrd?uri=winterdienst@gnusocial.de",
844 [{"accept", "application/xrd+xml,application/jrd+json"}]
849 body: File.read!("test/fixtures/tesla_mock/winterdienst_webfinger.json"),
850 headers: activitypub_object_headers()
854 def get("https://status.alpicola.com/.well-known/host-meta", _, _, _) do
858 body: File.read!("test/fixtures/tesla_mock/status.alpicola.com_host_meta")
862 def get("https://macgirvin.com/.well-known/host-meta", _, _, _) do
866 body: File.read!("test/fixtures/tesla_mock/macgirvin.com_host_meta")
870 def get("https://gerzilla.de/.well-known/host-meta", _, _, _) do
874 body: File.read!("test/fixtures/tesla_mock/gerzilla.de_host_meta")
879 "https://gerzilla.de/xrd/?uri=acct:kaniini@gerzilla.de",
882 [{"accept", "application/xrd+xml,application/jrd+json"}]
887 headers: [{"content-type", "application/jrd+json"}],
888 body: File.read!("test/fixtures/tesla_mock/kaniini@gerzilla.de.json")
893 "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/23211",
901 body: File.read!("test/fixtures/tesla_mock/https___social.heldscal.la_user_23211.xml")
905 def get("http://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://social.heldscal.la/.well-known/host-meta", _, _, _) do
917 body: File.read!("test/fixtures/tesla_mock/social.heldscal.la_host_meta")
921 def get("https://mastodon.social/users/lambadalambda", _, _, _) do
925 body: File.read!("test/fixtures/lambadalambda.json"),
926 headers: activitypub_object_headers()
930 def get("https://mastodon.social/users/lambadalambda/collections/featured", _, _, _) do
935 File.read!("test/fixtures/users_mock/masto_featured.json")
936 |> String.replace("{{domain}}", "mastodon.social")
937 |> String.replace("{{nickname}}", "lambadalambda"),
938 headers: activitypub_object_headers()
942 def get("https://apfed.club/channel/indio", _, _, _) do
946 body: File.read!("test/fixtures/tesla_mock/osada-user-indio.json"),
947 headers: activitypub_object_headers()
951 def get("https://social.heldscal.la/user/23211", _, _, [{"accept", "application/activity+json"}]) do
952 {:ok, Tesla.Mock.json(%{"id" => "https://social.heldscal.la/user/23211"}, status: 200)}
955 def get("http://example.com/ogp", _, _, _) do
956 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
959 def get("https://example.com/ogp", _, _, _) do
960 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
963 def get("https://pleroma.local/notice/9kCP7V", _, _, _) do
964 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
967 def get("http://localhost:4001/users/masto_closed/followers", _, _, _) do
971 body: File.read!("test/fixtures/users_mock/masto_closed_followers.json"),
972 headers: activitypub_object_headers()
976 def get("http://localhost:4001/users/masto_closed/followers?page=1", _, _, _) do
980 body: File.read!("test/fixtures/users_mock/masto_closed_followers_page.json"),
981 headers: activitypub_object_headers()
985 def get("http://localhost:4001/users/masto_closed/following", _, _, _) do
989 body: File.read!("test/fixtures/users_mock/masto_closed_following.json"),
990 headers: activitypub_object_headers()
994 def get("http://localhost:4001/users/masto_closed/following?page=1", _, _, _) do
998 body: File.read!("test/fixtures/users_mock/masto_closed_following_page.json"),
999 headers: activitypub_object_headers()
1003 def get("http://localhost:8080/followers/fuser3", _, _, _) do
1007 body: File.read!("test/fixtures/users_mock/friendica_followers.json"),
1008 headers: activitypub_object_headers()
1012 def get("http://localhost:8080/following/fuser3", _, _, _) do
1016 body: File.read!("test/fixtures/users_mock/friendica_following.json"),
1017 headers: activitypub_object_headers()
1021 def get("http://localhost:4001/users/fuser2/followers", _, _, _) do
1025 body: File.read!("test/fixtures/users_mock/pleroma_followers.json"),
1026 headers: activitypub_object_headers()
1030 def get("http://localhost:4001/users/fuser2/following", _, _, _) do
1034 body: File.read!("test/fixtures/users_mock/pleroma_following.json"),
1035 headers: activitypub_object_headers()
1039 def get("http://domain-with-errors:4001/users/fuser1/followers", _, _, _) do
1047 def get("http://domain-with-errors:4001/users/fuser1/following", _, _, _) do
1055 def get("http://example.com/ogp-missing-data", _, _, _) do
1059 body: File.read!("test/fixtures/rich_media/ogp-missing-data.html")
1063 def get("https://example.com/ogp-missing-data", _, _, _) do
1067 body: File.read!("test/fixtures/rich_media/ogp-missing-data.html")
1071 def get("http://example.com/malformed", _, _, _) do
1073 %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/malformed-data.html")}}
1076 def get("http://example.com/empty", _, _, _) do
1077 {:ok, %Tesla.Env{status: 200, body: "hello"}}
1080 def get("http://404.site" <> _, _, _, _) do
1089 "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=acct:lain@zetsubou.xn--q9jyb4c",
1092 [{"accept", "application/xrd+xml,application/jrd+json"}]
1097 body: File.read!("test/fixtures/lain.xml"),
1098 headers: [{"content-type", "application/xrd+xml"}]
1103 "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=acct:https://zetsubou.xn--q9jyb4c/users/lain",
1106 [{"accept", "application/xrd+xml,application/jrd+json"}]
1111 body: File.read!("test/fixtures/lain.xml"),
1112 headers: [{"content-type", "application/xrd+xml"}]
1116 def get("http://zetsubou.xn--q9jyb4c/.well-known/host-meta", _, _, _) do
1120 body: File.read!("test/fixtures/host-meta-zetsubou.xn--q9jyb4c.xml")
1125 "https://zetsubou.xn--q9jyb4c/.well-known/host-meta",
1133 body: File.read!("test/fixtures/host-meta-zetsubou.xn--q9jyb4c.xml")
1137 def get("http://lm.kazv.moe/.well-known/host-meta", _, _, _) do
1141 body: File.read!("test/fixtures/tesla_mock/lm.kazv.moe_host_meta")
1145 def get("https://lm.kazv.moe/.well-known/host-meta", _, _, _) do
1149 body: File.read!("test/fixtures/tesla_mock/lm.kazv.moe_host_meta")
1154 "https://lm.kazv.moe/.well-known/webfinger?resource=acct:mewmew@lm.kazv.moe",
1157 [{"accept", "application/xrd+xml,application/jrd+json"}]
1162 body: File.read!("test/fixtures/tesla_mock/https___lm.kazv.moe_users_mewmew.xml"),
1163 headers: [{"content-type", "application/xrd+xml"}]
1167 def get("https://lm.kazv.moe/users/mewmew", _, _, _) do
1171 body: File.read!("test/fixtures/tesla_mock/mewmew@lm.kazv.moe.json"),
1172 headers: activitypub_object_headers()
1176 def get("https://lm.kazv.moe/users/mewmew/collections/featured", _, _, _) do
1181 File.read!("test/fixtures/users_mock/masto_featured.json")
1182 |> String.replace("{{domain}}", "lm.kazv.moe")
1183 |> String.replace("{{nickname}}", "mewmew"),
1184 headers: [{"content-type", "application/activity+json"}]
1188 def get("https://info.pleroma.site/activity.json", _, _, [
1189 {"accept", "application/activity+json"}
1194 body: File.read!("test/fixtures/tesla_mock/https__info.pleroma.site_activity.json"),
1195 headers: activitypub_object_headers()
1199 def get("https://info.pleroma.site/activity.json", _, _, _) do
1200 {:ok, %Tesla.Env{status: 404, body: ""}}
1203 def get("https://info.pleroma.site/activity2.json", _, _, [
1204 {"accept", "application/activity+json"}
1209 body: File.read!("test/fixtures/tesla_mock/https__info.pleroma.site_activity2.json"),
1210 headers: activitypub_object_headers()
1214 def get("https://info.pleroma.site/activity2.json", _, _, _) do
1215 {:ok, %Tesla.Env{status: 404, body: ""}}
1218 def get("https://info.pleroma.site/activity3.json", _, _, [
1219 {"accept", "application/activity+json"}
1224 body: File.read!("test/fixtures/tesla_mock/https__info.pleroma.site_activity3.json"),
1225 headers: activitypub_object_headers()
1229 def get("https://info.pleroma.site/activity3.json", _, _, _) do
1230 {:ok, %Tesla.Env{status: 404, body: ""}}
1233 def get("https://mstdn.jp/.well-known/webfinger?resource=acct:kpherox@mstdn.jp", _, _, _) do
1237 body: File.read!("test/fixtures/tesla_mock/kpherox@mstdn.jp.xml"),
1238 headers: [{"content-type", "application/xrd+xml"}]
1242 def get("https://10.111.10.1/notice/9kCP7V", _, _, _) do
1243 {:ok, %Tesla.Env{status: 200, body: ""}}
1246 def get("https://172.16.32.40/notice/9kCP7V", _, _, _) do
1247 {:ok, %Tesla.Env{status: 200, body: ""}}
1250 def get("https://192.168.10.40/notice/9kCP7V", _, _, _) do
1251 {:ok, %Tesla.Env{status: 200, body: ""}}
1254 def get("https://www.patreon.com/posts/mastodon-2-9-and-28121681", _, _, _) do
1255 {:ok, %Tesla.Env{status: 200, body: ""}}
1258 def get("http://mastodon.example.org/@admin/99541947525187367", _, _, _) do
1262 body: File.read!("test/fixtures/mastodon-post-activity.json"),
1263 headers: activitypub_object_headers()
1267 def get("https://info.pleroma.site/activity4.json", _, _, _) do
1268 {:ok, %Tesla.Env{status: 500, body: "Error occurred"}}
1271 def get("http://example.com/rel_me/anchor", _, _, _) do
1272 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor.html")}}
1275 def get("http://example.com/rel_me/anchor_nofollow", _, _, _) do
1276 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor_nofollow.html")}}
1279 def get("http://example.com/rel_me/link", _, _, _) do
1280 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_link.html")}}
1283 def get("http://example.com/rel_me/null", _, _, _) do
1284 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_null.html")}}
1287 def get("https://skippers-bin.com/notes/7x9tmrp97i", _, _, _) do
1291 body: File.read!("test/fixtures/tesla_mock/misskey_poll_no_end_date.json"),
1292 headers: activitypub_object_headers()
1296 def get("https://example.org/emoji/firedfox.png", _, _, _) do
1297 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/image.jpg")}}
1300 def get("https://skippers-bin.com/users/7v1w1r8ce6", _, _, _) do
1304 body: File.read!("test/fixtures/tesla_mock/sjw.json"),
1305 headers: activitypub_object_headers()
1309 def get("https://patch.cx/users/rin", _, _, _) do
1313 body: File.read!("test/fixtures/tesla_mock/rin.json"),
1314 headers: activitypub_object_headers()
1319 "https://channels.tests.funkwhale.audio/federation/music/uploads/42342395-0208-4fee-a38d-259a6dae0871",
1327 body: File.read!("test/fixtures/tesla_mock/funkwhale_audio.json"),
1328 headers: activitypub_object_headers()
1332 def get("https://channels.tests.funkwhale.audio/federation/actors/compositions", _, _, _) do
1336 body: File.read!("test/fixtures/tesla_mock/funkwhale_channel.json"),
1337 headers: activitypub_object_headers()
1341 def get("http://example.com/rel_me/error", _, _, _) do
1342 {:ok, %Tesla.Env{status: 404, body: ""}}
1345 def get("https://relay.mastodon.host/actor", _, _, _) do
1349 body: File.read!("test/fixtures/relay/relay.json"),
1350 headers: activitypub_object_headers()
1354 def get("http://localhost:4001/", _, "", [{"accept", "text/html"}]) do
1355 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/7369654.html")}}
1358 def get("https://osada.macgirvin.com/", _, "", [{"accept", "text/html"}]) do
1362 body: File.read!("test/fixtures/tesla_mock/https___osada.macgirvin.com.html")
1366 def get("https://patch.cx/objects/a399c28e-c821-4820-bc3e-4afeb044c16f", _, _, _) do
1370 body: File.read!("test/fixtures/tesla_mock/emoji-in-summary.json"),
1371 headers: activitypub_object_headers()
1375 def get("https://mk.absturztau.be/users/8ozbzjs3o8", _, _, _) do
1379 body: File.read!("test/fixtures/tesla_mock/mametsuko@mk.absturztau.be.json"),
1380 headers: activitypub_object_headers()
1384 def get("https://p.helene.moe/users/helene", _, _, _) do
1388 body: File.read!("test/fixtures/tesla_mock/helene@p.helene.moe.json"),
1389 headers: activitypub_object_headers()
1393 def get("https://mk.absturztau.be/notes/93e7nm8wqg", _, _, _) do
1397 body: File.read!("test/fixtures/tesla_mock/mk.absturztau.be-93e7nm8wqg.json"),
1398 headers: activitypub_object_headers()
1402 def get("https://p.helene.moe/objects/fd5910ac-d9dc-412e-8d1d-914b203296c4", _, _, _) do
1406 body: File.read!("test/fixtures/tesla_mock/p.helene.moe-AM7S6vZQmL6pI9TgPY.json"),
1407 headers: activitypub_object_headers()
1411 def get(url, query, body, headers) do
1413 "Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{inspect(headers)}"}
1419 def post(url, query \\ [], body \\ [], headers \\ [])
1421 def post("https://relay.mastodon.host/inbox", _, _, _) do
1422 {:ok, %Tesla.Env{status: 200, body: ""}}
1425 def post("http://example.org/needs_refresh", _, _, _) do
1433 def post("http://mastodon.example.org/inbox", _, _, _) do
1441 def post("https://hubzilla.example.org/inbox", _, _, _) do
1449 def post("http://gs.example.org/index.php/main/salmon/user/1", _, _, _) do
1457 def post("http://200.site" <> _, _, _, _) do
1465 def post("http://connrefused.site" <> _, _, _, _) do
1466 {:error, :connrefused}
1469 def post("http://404.site" <> _, _, _, _) do
1477 def post(url, query, body, headers) do
1479 "Mock response not implemented for POST #{inspect(url)}, #{query}, #{inspect(body)}, #{inspect(headers)}"}
1482 # Most of the rich media mocks are missing HEAD requests, so we just return 404.
1484 "https://example.com/ogp",
1485 "https://example.com/ogp-missing-data",
1486 "https://example.com/twitter-card"
1488 def head(url, _query, _body, _headers) when url in @rich_media_mocks do
1489 {:ok, %Tesla.Env{status: 404, body: ""}}
1492 def head(url, query, body, headers) do
1494 "Mock response not implemented for HEAD #{inspect(url)}, #{query}, #{inspect(body)}, #{inspect(headers)}"}