1 defmodule HttpRequestMock do
13 with {:ok, res} <- apply(__MODULE__, method, [url, query, body, headers]) do
24 def get(url, query \\ [], body \\ [], headers \\ [])
26 def get("http://gs.example.org:4040/index.php/user/1", _, _, Accept: "application/activity+json") do
34 def get("https://squeet.me/xrd/?uri=lain@squeet.me", _, _,
35 Accept: "application/xrd+xml,application/jrd+json"
40 body: File.read!("test/fixtures/httpoison_mock/lain_squeet.me_webfinger.xml")
44 def get("https://mst3k.interlinked.me/users/luciferMysticus", _, _,
45 Accept: "application/activity+json"
50 body: File.read!("test/fixtures/httpoison_mock/lucifermysticus.json")
54 def get("https://prismo.news/@mxb", _, _, _) do
58 body: File.read!("test/fixtures/httpoison_mock/https___prismo.news__mxb.json")
62 def get("https://hubzilla.example.org/channel/kaniini", _, _,
63 Accept: "application/activity+json"
68 body: File.read!("test/fixtures/httpoison_mock/kaniini@hubzilla.example.org.json")
72 def get("https://niu.moe/users/rye", _, _, Accept: "application/activity+json") do
76 body: File.read!("test/fixtures/httpoison_mock/rye.json")
80 def get("http://mastodon.example.org/users/admin/statuses/100787282858396771", _, _, _) do
86 "test/fixtures/httpoison_mock/http___mastodon.example.org_users_admin_status_1234.json"
91 def get("https://puckipedia.com/", _, _, Accept: "application/activity+json") do
95 body: File.read!("test/fixtures/httpoison_mock/puckipedia.com.json")
99 def get("https://peertube.moe/accounts/7even", _, _, _) do
103 body: File.read!("test/fixtures/httpoison_mock/7even.json")
107 def get("https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3", _, _, _) do
111 body: File.read!("test/fixtures/httpoison_mock/peertube.moe-vid.json")
115 def get("https://baptiste.gelez.xyz/@/BaptisteGelez", _, _, _) do
119 body: File.read!("test/fixtures/httpoison_mock/baptiste.gelex.xyz-user.json")
123 def get("https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/", _, _, _) do
127 body: File.read!("test/fixtures/httpoison_mock/baptiste.gelex.xyz-article.json")
131 def get("http://mastodon.example.org/users/admin", _, _, Accept: "application/activity+json") do
135 body: File.read!("test/fixtures/httpoison_mock/admin@mastdon.example.org.json")
139 def get("http://mastodon.example.org/@admin/99541947525187367", _, _,
140 Accept: "application/activity+json"
145 body: File.read!("test/fixtures/mastodon-note-object.json")
149 def get("https://shitposter.club/notice/7369654", _, _, _) do
153 body: File.read!("test/fixtures/httpoison_mock/7369654.html")
157 def get("https://mstdn.io/users/mayuutann", _, _, Accept: "application/activity+json") do
161 body: File.read!("test/fixtures/httpoison_mock/mayumayu.json")
165 def get("https://mstdn.io/users/mayuutann/statuses/99568293732299394", _, _,
166 Accept: "application/activity+json"
171 body: File.read!("test/fixtures/httpoison_mock/mayumayupost.json")
175 def get("https://pleroma.soykaf.com/users/lain/feed.atom", _, _, _) do
181 "test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain_feed.atom.xml"
186 def get(url, _, _, Accept: "application/xrd+xml,application/jrd+json")
188 "https://pleroma.soykaf.com/.well-known/webfinger?resource=acct:https://pleroma.soykaf.com/users/lain",
189 "https://pleroma.soykaf.com/.well-known/webfinger?resource=https://pleroma.soykaf.com/users/lain"
194 body: File.read!("test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain.xml")
198 def get("https://shitposter.club/api/statuses/user_timeline/1.atom", _, _, _) do
204 "test/fixtures/httpoison_mock/https___shitposter.club_api_statuses_user_timeline_1.atom.xml"
210 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/1",
213 Accept: "application/xrd+xml,application/jrd+json"
218 body: File.read!("test/fixtures/httpoison_mock/https___shitposter.club_user_1.xml")
222 def get("https://shitposter.club/notice/2827873", _, _, _) do
227 File.read!("test/fixtures/httpoison_mock/https___shitposter.club_notice_2827873.html")
231 def get("https://shitposter.club/api/statuses/show/2827873.atom", _, _, _) do
237 "test/fixtures/httpoison_mock/https___shitposter.club_api_statuses_show_2827873.atom.xml"
242 def get("https://testing.pleroma.lol/objects/b319022a-4946-44c5-9de9-34801f95507b", _, _, _) do
243 {:ok, %Tesla.Env{status: 200}}
246 def get("https://shitposter.club/api/statuses/user_timeline/5381.atom", _, _, _) do
250 body: File.read!("test/fixtures/httpoison_mock/spc_5381.atom")
255 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/5381",
258 Accept: "application/xrd+xml,application/jrd+json"
263 body: File.read!("test/fixtures/httpoison_mock/spc_5381_xrd.xml")
267 def get("http://shitposter.club/.well-known/host-meta", _, _, _) do
271 body: File.read!("test/fixtures/httpoison_mock/shitposter.club_host_meta")
275 def get("https://shitposter.club/api/statuses/show/7369654.atom", _, _, _) do
279 body: File.read!("test/fixtures/httpoison_mock/7369654.atom")
283 def get("https://shitposter.club/notice/4027863", _, _, _) do
287 body: File.read!("test/fixtures/httpoison_mock/7369654.html")
291 def get("https://social.sakamoto.gq/users/eal/feed.atom", _, _, _) do
295 body: File.read!("test/fixtures/httpoison_mock/sakamoto_eal_feed.atom")
299 def get("http://social.sakamoto.gq/.well-known/host-meta", _, _, _) do
303 body: File.read!("test/fixtures/httpoison_mock/social.sakamoto.gq_host_meta")
308 "https://social.sakamoto.gq/.well-known/webfinger?resource=https://social.sakamoto.gq/users/eal",
311 Accept: "application/xrd+xml,application/jrd+json"
316 body: File.read!("test/fixtures/httpoison_mock/eal_sakamoto.xml")
320 def get("https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056", _, _,
321 Accept: "application/atom+xml"
323 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/httpoison_mock/sakamoto.atom")}}
326 def get("http://mastodon.social/.well-known/host-meta", _, _, _) do
330 body: File.read!("test/fixtures/httpoison_mock/mastodon.social_host_meta")
335 "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/lambadalambda",
338 Accept: "application/xrd+xml,application/jrd+json"
345 "test/fixtures/httpoison_mock/https___mastodon.social_users_lambadalambda.xml"
350 def get("http://gs.example.org/.well-known/host-meta", _, _, _) do
354 body: File.read!("test/fixtures/httpoison_mock/gs.example.org_host_meta")
359 "http://gs.example.org/.well-known/webfinger?resource=http://gs.example.org:4040/index.php/user/1",
362 Accept: "application/xrd+xml,application/jrd+json"
369 "test/fixtures/httpoison_mock/http___gs.example.org_4040_index.php_user_1.xml"
374 def get("http://gs.example.org/index.php/api/statuses/user_timeline/1.atom", _, _, _) do
380 "test/fixtures/httpoison_mock/http__gs.example.org_index.php_api_statuses_user_timeline_1.atom.xml"
385 def get("https://social.heldscal.la/api/statuses/user_timeline/29191.atom", _, _, _) do
391 "test/fixtures/httpoison_mock/https___social.heldscal.la_api_statuses_user_timeline_29191.atom.xml"
396 def get("http://squeet.me/.well-known/host-meta", _, _, _) do
398 %Tesla.Env{status: 200, body: File.read!("test/fixtures/httpoison_mock/squeet.me_host_meta")}}
401 def get("https://squeet.me/xrd?uri=lain@squeet.me", _, _,
402 Accept: "application/xrd+xml,application/jrd+json"
407 body: File.read!("test/fixtures/httpoison_mock/lain_squeet.me_webfinger.xml")
412 "https://social.heldscal.la/.well-known/webfinger?resource=shp@social.heldscal.la",
415 Accept: "application/xrd+xml,application/jrd+json"
420 body: File.read!("test/fixtures/httpoison_mock/shp@social.heldscal.la.xml")
424 def get("http://framatube.org/.well-known/host-meta", _, _, _) do
428 body: File.read!("test/fixtures/httpoison_mock/framatube.org_host_meta")
432 def get("http://framatube.org/main/xrd?uri=framasoft@framatube.org", _, _,
433 Accept: "application/xrd+xml,application/jrd+json"
438 headers: [{"content-type", "application/json"}],
439 body: File.read!("test/fixtures/httpoison_mock/framasoft@framatube.org.json")
443 def get("http://gnusocial.de/.well-known/host-meta", _, _, _) do
447 body: File.read!("test/fixtures/httpoison_mock/gnusocial.de_host_meta")
451 def get("http://gnusocial.de/main/xrd?uri=winterdienst@gnusocial.de", _, _,
452 Accept: "application/xrd+xml,application/jrd+json"
457 body: File.read!("test/fixtures/httpoison_mock/winterdienst_webfinger.json")
461 def get("http://status.alpicola.com/.well-known/host-meta", _, _, _) do
465 body: File.read!("test/fixtures/httpoison_mock/status.alpicola.com_host_meta")
469 def get("http://macgirvin.com/.well-known/host-meta", _, _, _) do
473 body: File.read!("test/fixtures/httpoison_mock/macgirvin.com_host_meta")
477 def get("http://gerzilla.de/.well-known/host-meta", _, _, _) do
481 body: File.read!("test/fixtures/httpoison_mock/gerzilla.de_host_meta")
485 def get("https://gerzilla.de/xrd/?uri=kaniini@gerzilla.de", _, _,
486 Accept: "application/xrd+xml,application/jrd+json"
491 headers: [{"content-type", "application/json"}],
492 body: File.read!("test/fixtures/httpoison_mock/kaniini@gerzilla.de.json")
496 def get("https://social.heldscal.la/api/statuses/user_timeline/23211.atom", _, _, _) do
502 "test/fixtures/httpoison_mock/https___social.heldscal.la_api_statuses_user_timeline_23211.atom.xml"
508 "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/23211",
516 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_user_23211.xml")
520 def get("http://social.heldscal.la/.well-known/host-meta", _, _, _) do
524 body: File.read!("test/fixtures/httpoison_mock/social.heldscal.la_host_meta")
528 def get("https://social.heldscal.la/.well-known/host-meta", _, _, _) do
532 body: File.read!("test/fixtures/httpoison_mock/social.heldscal.la_host_meta")
536 def get("https://mastodon.social/users/lambadalambda.atom", _, _, _) do
537 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/lambadalambda.atom")}}
540 def get("https://social.heldscal.la/user/23211", _, _, Accept: "application/activity+json") do
541 {:ok, Tesla.Mock.json(%{"id" => "https://social.heldscal.la/user/23211"}, status: 200)}
544 def get(url, query, body, headers) do
546 "Not implemented the mock response for get #{inspect(url)}, #{query}, #{inspect(body)}, #{
554 def post(url, query \\ [], body \\ [], headers \\ [])
556 def post("http://example.org/needs_refresh", _, _, _) do
564 def post(url, _query, _body, _headers) do
565 {:error, "Not implemented the mock response for post #{inspect(url)}"}