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("https://pleroma.soykaf.com/users/lain/feed.atom", _, _, _) do
32 "test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain_feed.atom.xml"
37 def get(url, _, _, Accept: "application/xrd+xml,application/jrd+json")
39 "https://pleroma.soykaf.com/.well-known/webfinger?resource=acct:https://pleroma.soykaf.com/users/lain",
40 "https://pleroma.soykaf.com/.well-known/webfinger?resource=https://pleroma.soykaf.com/users/lain"
45 body: File.read!("test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain.xml")
49 def get("https://shitposter.club/api/statuses/user_timeline/1.atom", _, _, _) do
55 "test/fixtures/httpoison_mock/https___shitposter.club_api_statuses_user_timeline_1.atom.xml"
61 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/1",
64 Accept: "application/xrd+xml,application/jrd+json"
69 body: File.read!("test/fixtures/httpoison_mock/https___shitposter.club_user_1.xml")
73 def get("https://shitposter.club/notice/2827873", _, _, _) do
78 File.read!("test/fixtures/httpoison_mock/https___shitposter.club_notice_2827873.html")
82 def get("https://shitposter.club/api/statuses/show/2827873.atom", _, _, _) do
88 "test/fixtures/httpoison_mock/https___shitposter.club_api_statuses_show_2827873.atom.xml"
93 def get("https://testing.pleroma.lol/objects/b319022a-4946-44c5-9de9-34801f95507b", _, _, _) do
94 {:ok, %Tesla.Env{status: 200}}
97 def get("https://shitposter.club/api/statuses/user_timeline/5381.atom", _, _, _) do
101 body: File.read!("test/fixtures/httpoison_mock/spc_5381.atom")
106 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/5381",
109 Accept: "application/xrd+xml,application/jrd+json"
114 body: File.read!("test/fixtures/httpoison_mock/spc_5381_xrd.xml")
118 def get("http://shitposter.club/.well-known/host-meta", _, _, _) do
122 body: File.read!("test/fixtures/httpoison_mock/shitposter.club_host_meta")
126 def get("https://shitposter.club/api/statuses/show/7369654.atom", _, _, _) do
130 body: File.read!("test/fixtures/httpoison_mock/7369654.atom")
134 def get("https://shitposter.club/notice/4027863", _, _, _) do
138 body: File.read!("test/fixtures/httpoison_mock/7369654.html")
142 def get("https://social.sakamoto.gq/users/eal/feed.atom", _, _, _) do
146 body: File.read!("test/fixtures/httpoison_mock/sakamoto_eal_feed.atom")
150 def get("http://social.sakamoto.gq/.well-known/host-meta", _, _, _) do
154 body: File.read!("test/fixtures/httpoison_mock/social.sakamoto.gq_host_meta")
159 "https://social.sakamoto.gq/.well-known/webfinger?resource=https://social.sakamoto.gq/users/eal",
162 Accept: "application/xrd+xml,application/jrd+json"
167 body: File.read!("test/fixtures/httpoison_mock/eal_sakamoto.xml")
171 def get("https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056", _, _,
172 Accept: "application/atom+xml"
174 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/httpoison_mock/sakamoto.atom")}}
177 def get("http://mastodon.social/.well-known/host-meta", _, _, _) do
181 body: File.read!("test/fixtures/httpoison_mock/mastodon.social_host_meta")
186 "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/lambadalambda",
189 Accept: "application/xrd+xml,application/jrd+json"
196 "test/fixtures/httpoison_mock/https___mastodon.social_users_lambadalambda.xml"
201 def get("http://gs.example.org/.well-known/host-meta", _, _, _) do
205 body: File.read!("test/fixtures/httpoison_mock/gs.example.org_host_meta")
210 "http://gs.example.org/.well-known/webfinger?resource=http://gs.example.org:4040/index.php/user/1",
213 Accept: "application/xrd+xml,application/jrd+json"
220 "test/fixtures/httpoison_mock/http___gs.example.org_4040_index.php_user_1.xml"
225 def get("http://gs.example.org/index.php/api/statuses/user_timeline/1.atom", _, _, _) do
231 "test/fixtures/httpoison_mock/http__gs.example.org_index.php_api_statuses_user_timeline_1.atom.xml"
236 def get("https://social.heldscal.la/api/statuses/user_timeline/29191.atom", _, _, _) do
242 "test/fixtures/httpoison_mock/https___social.heldscal.la_api_statuses_user_timeline_29191.atom.xml"
247 def get("http://squeet.me/.well-known/host-meta", _, _, _) do
249 %Tesla.Env{status: 200, body: File.read!("test/fixtures/httpoison_mock/squeet.me_host_meta")}}
252 def get("https://squeet.me/xrd?uri=lain@squeet.me", _, _,
253 Accept: "application/xrd+xml,application/jrd+json"
258 body: File.read!("test/fixtures/httpoison_mock/lain_squeet.me_webfinger.xml")
263 "https://social.heldscal.la/.well-known/webfinger?resource=shp@social.heldscal.la",
266 Accept: "application/xrd+xml,application/jrd+json"
271 body: File.read!("test/fixtures/httpoison_mock/shp@social.heldscal.la.xml")
275 def get("http://framatube.org/.well-known/host-meta", _, _, _) do
279 body: File.read!("test/fixtures/httpoison_mock/framatube.org_host_meta")
283 def get("http://framatube.org/main/xrd?uri=framasoft@framatube.org", _, _,
284 Accept: "application/xrd+xml,application/jrd+json"
289 headers: [{"content-type", "application/json"}],
290 body: File.read!("test/fixtures/httpoison_mock/framasoft@framatube.org.json")
294 def get("http://gnusocial.de/.well-known/host-meta", _, _, _) do
298 body: File.read!("test/fixtures/httpoison_mock/gnusocial.de_host_meta")
302 def get("http://gnusocial.de/main/xrd?uri=winterdienst@gnusocial.de", _, _,
303 Accept: "application/xrd+xml,application/jrd+json"
308 body: File.read!("test/fixtures/httpoison_mock/winterdienst_webfinger.json")
312 def get("http://status.alpicola.com/.well-known/host-meta", _, _, _) do
316 body: File.read!("test/fixtures/httpoison_mock/status.alpicola.com_host_meta")
320 def get("http://macgirvin.com/.well-known/host-meta", _, _, _) do
324 body: File.read!("test/fixtures/httpoison_mock/macgirvin.com_host_meta")
328 def get("http://gerzilla.de/.well-known/host-meta", _, _, _) do
332 body: File.read!("test/fixtures/httpoison_mock/gerzilla.de_host_meta")
336 def get("https://gerzilla.de/xrd/?uri=kaniini@gerzilla.de", _, _,
337 Accept: "application/xrd+xml,application/jrd+json"
342 headers: [{"content-type", "application/json"}],
343 body: File.read!("test/fixtures/httpoison_mock/kaniini@gerzilla.de.json")
347 def get("https://social.heldscal.la/api/statuses/user_timeline/23211.atom", _, _, _) do
353 "test/fixtures/httpoison_mock/https___social.heldscal.la_api_statuses_user_timeline_23211.atom.xml"
359 "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/23211",
367 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_user_23211.xml")
371 def get("http://social.heldscal.la/.well-known/host-meta", _, _, _) do
375 body: File.read!("test/fixtures/httpoison_mock/social.heldscal.la_host_meta")
379 def get("https://social.heldscal.la/.well-known/host-meta", _, _, _) do
383 body: File.read!("test/fixtures/httpoison_mock/social.heldscal.la_host_meta")
387 def get("https://mastodon.social/users/lambadalambda.atom", _, _, _) do
388 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/lambadalambda.atom")}}
391 def get("https://social.heldscal.la/user/23211", _, _, Accept: "application/activity+json") do
392 {:ok, Tesla.Mock.json(%{"id" => "https://social.heldscal.la/user/23211"}, status: 200)}
395 def get(url, query, body, headers) do
397 "Not implemented the mock response for get #{inspect(url)}, #{query}, #{inspect(body)}, #{
405 def post(url, query \\ [], body \\ [], headers \\ [])
407 def post("http://example.org/needs_refresh", _, _, _) do
415 def post(url, _query, _body, _headers) do
416 {:error, "Not implemented the mock response for post #{inspect(url)}"}