Fix a bunch of unused variable warnings
[akkoma] / test / support / httpoison_mock.ex
1 defmodule HTTPoisonMock do
2 alias HTTPoison.Response
3
4 def get(url, body \\ [], headers \\ [])
5
6 def get(
7 "http://framatube.org/.well-known/webfinger?resource=acct:framasoft@framatube.org",
8 [Accept: "application/xrd+xml,application/jrd+json"],
9 follow_redirect: true
10 ) do
11 {:ok,
12 %Response{
13 status_code: 200,
14 body: File.read!("test/fixtures/httpoison_mock/framasoft@framatube.org.json")
15 }}
16 end
17
18 def get(
19 "http://gnusocial.de/.well-known/webfinger?resource=acct:winterdienst@gnusocial.de",
20 [Accept: "application/xrd+xml,application/jrd+json"],
21 follow_redirect: true
22 ) do
23 {:ok,
24 %Response{
25 status_code: 200,
26 body: File.read!("test/fixtures/httpoison_mock/winterdienst_webfinger.json")
27 }}
28 end
29
30 def get(
31 "https://social.heldscal.la/.well-known/webfinger",
32 [Accept: "application/xrd+xml,application/jrd+json"],
33 params: [resource: "nonexistant@social.heldscal.la"],
34 follow_redirect: true
35 ) do
36 {:ok,
37 %Response{
38 status_code: 500,
39 body: File.read!("test/fixtures/httpoison_mock/nonexistant@social.heldscal.la.xml")
40 }}
41 end
42
43 def get(
44 "https://social.heldscal.la/.well-known/webfinger?resource=shp@social.heldscal.la",
45 [Accept: "application/xrd+xml,application/jrd+json"],
46 follow_redirect: true
47 ) do
48 {:ok,
49 %Response{
50 status_code: 200,
51 body: File.read!("test/fixtures/httpoison_mock/shp@social.heldscal.la.xml")
52 }}
53 end
54
55 def get(
56 "https://social.heldscal.la/.well-known/webfinger",
57 [Accept: "application/xrd+xml,application/jrd+json"],
58 params: [resource: "shp@social.heldscal.la"],
59 follow_redirect: true
60 ) do
61 {:ok,
62 %Response{
63 status_code: 200,
64 body: File.read!("test/fixtures/httpoison_mock/shp@social.heldscal.la.xml")
65 }}
66 end
67
68 def get(
69 "https://social.heldscal.la/.well-known/webfinger",
70 [Accept: "application/xrd+xml,application/jrd+json"],
71 params: [resource: "https://social.heldscal.la/user/23211"],
72 follow_redirect: true
73 ) do
74 {:ok,
75 %Response{
76 status_code: 200,
77 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_user_23211.xml")
78 }}
79 end
80
81 def get(
82 "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/23211",
83 [Accept: "application/xrd+xml,application/jrd+json"],
84 follow_redirect: true
85 ) do
86 {:ok,
87 %Response{
88 status_code: 200,
89 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_user_23211.xml")
90 }}
91 end
92
93 def get(
94 "https://social.heldscal.la/.well-known/webfinger",
95 [Accept: "application/xrd+xml,application/jrd+json"],
96 params: [resource: "https://social.heldscal.la/user/29191"],
97 follow_redirect: true
98 ) do
99 {:ok,
100 %Response{
101 status_code: 200,
102 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_user_29191.xml")
103 }}
104 end
105
106 def get(
107 "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/29191",
108 [Accept: "application/xrd+xml,application/jrd+json"],
109 follow_redirect: true
110 ) do
111 {:ok,
112 %Response{
113 status_code: 200,
114 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_user_29191.xml")
115 }}
116 end
117
118 def get(
119 "https://mastodon.social/.well-known/webfinger",
120 [Accept: "application/xrd+xml,application/jrd+json"],
121 params: [resource: "https://mastodon.social/users/lambadalambda"],
122 follow_redirect: true
123 ) do
124 {:ok,
125 %Response{
126 status_code: 200,
127 body:
128 File.read!(
129 "test/fixtures/httpoison_mock/https___mastodon.social_users_lambadalambda.xml"
130 )
131 }}
132 end
133
134 def get(
135 "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/lambadalambda",
136 [Accept: "application/xrd+xml,application/jrd+json"],
137 follow_redirect: true
138 ) do
139 {:ok,
140 %Response{
141 status_code: 200,
142 body:
143 File.read!(
144 "test/fixtures/httpoison_mock/https___mastodon.social_users_lambadalambda.xml"
145 )
146 }}
147 end
148
149 def get(
150 "https://shitposter.club/.well-known/webfinger",
151 [Accept: "application/xrd+xml,application/jrd+json"],
152 params: [resource: "https://shitposter.club/user/1"],
153 follow_redirect: true
154 ) do
155 {:ok,
156 %Response{
157 status_code: 200,
158 body: File.read!("test/fixtures/httpoison_mock/https___shitposter.club_user_1.xml")
159 }}
160 end
161
162 def get(
163 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/1",
164 [Accept: "application/xrd+xml,application/jrd+json"],
165 follow_redirect: true
166 ) do
167 {:ok,
168 %Response{
169 status_code: 200,
170 body: File.read!("test/fixtures/httpoison_mock/https___shitposter.club_user_1.xml")
171 }}
172 end
173
174 def get(
175 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/5381",
176 [Accept: "application/xrd+xml,application/jrd+json"],
177 follow_redirect: true
178 ) do
179 {:ok,
180 %Response{
181 status_code: 200,
182 body: File.read!("test/fixtures/httpoison_mock/spc_5381_xrd.xml")
183 }}
184 end
185
186 def get(
187 "http://gs.example.org/.well-known/webfinger",
188 [Accept: "application/xrd+xml,application/jrd+json"],
189 params: [resource: "http://gs.example.org:4040/index.php/user/1"],
190 follow_redirect: true
191 ) do
192 {:ok,
193 %Response{
194 status_code: 200,
195 body:
196 File.read!(
197 "test/fixtures/httpoison_mock/http___gs.example.org_4040_index.php_user_1.xml"
198 )
199 }}
200 end
201
202 def get(
203 "http://gs.example.org/.well-known/webfinger?resource=http://gs.example.org:4040/index.php/user/1",
204 [Accept: "application/xrd+xml,application/jrd+json"],
205 follow_redirect: true
206 ) do
207 {:ok,
208 %Response{
209 status_code: 200,
210 body:
211 File.read!(
212 "test/fixtures/httpoison_mock/http___gs.example.org_4040_index.php_user_1.xml"
213 )
214 }}
215 end
216
217 def get(
218 "https://social.stopwatchingus-heidelberg.de/.well-known/webfinger?resource=https://social.stopwatchingus-heidelberg.de/user/18330",
219 [Accept: "application/xrd+xml,application/jrd+json"],
220 follow_redirect: true
221 ) do
222 {:ok,
223 %Response{
224 status_code: 200,
225 body: File.read!("test/fixtures/httpoison_mock/atarifrosch_webfinger.xml")
226 }}
227 end
228
229 def get(
230 "https://pleroma.soykaf.com/.well-known/webfinger",
231 [Accept: "application/xrd+xml,application/jrd+json"],
232 params: [resource: "https://pleroma.soykaf.com/users/lain"],
233 follow_redirect: true
234 ) do
235 {:ok,
236 %Response{
237 status_code: 200,
238 body: File.read!("test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain.xml")
239 }}
240 end
241
242 def get(
243 "https://pleroma.soykaf.com/.well-known/webfinger?resource=https://pleroma.soykaf.com/users/lain",
244 [Accept: "application/xrd+xml,application/jrd+json"],
245 follow_redirect: true
246 ) do
247 {:ok,
248 %Response{
249 status_code: 200,
250 body: File.read!("test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain.xml")
251 }}
252 end
253
254 def get("https://social.heldscal.la/api/statuses/user_timeline/29191.atom", _body, _headers) do
255 {:ok,
256 %Response{
257 status_code: 200,
258 body:
259 File.read!(
260 "test/fixtures/httpoison_mock/https___social.heldscal.la_api_statuses_user_timeline_29191.atom.xml"
261 )
262 }}
263 end
264
265 def get("https://shitposter.club/api/statuses/user_timeline/5381.atom", _body, _headers) do
266 {:ok,
267 %Response{
268 status_code: 200,
269 body: File.read!("test/fixtures/httpoison_mock/spc_5381.atom")
270 }}
271 end
272
273 def get("https://social.heldscal.la/api/statuses/user_timeline/23211.atom", _body, _headers) do
274 {:ok,
275 %Response{
276 status_code: 200,
277 body:
278 File.read!(
279 "test/fixtures/httpoison_mock/https___social.heldscal.la_api_statuses_user_timeline_23211.atom.xml"
280 )
281 }}
282 end
283
284 def get("https://mastodon.social/users/lambadalambda.atom", _body, _headers) do
285 {:ok,
286 %Response{
287 status_code: 200,
288 body:
289 File.read!(
290 "test/fixtures/httpoison_mock/https___mastodon.social_users_lambadalambda.atom"
291 )
292 }}
293 end
294
295 def get(
296 "https://social.stopwatchingus-heidelberg.de/api/statuses/user_timeline/18330.atom",
297 _body,
298 _headers
299 ) do
300 {:ok,
301 %Response{
302 status_code: 200,
303 body: File.read!("test/fixtures/httpoison_mock/atarifrosch_feed.xml")
304 }}
305 end
306
307 def get("https://pleroma.soykaf.com/users/lain/feed.atom", _body, _headers) do
308 {:ok,
309 %Response{
310 status_code: 200,
311 body:
312 File.read!(
313 "test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain_feed.atom.xml"
314 )
315 }}
316 end
317
318 def get("https://social.sakamoto.gq/users/eal/feed.atom", _body, _headers) do
319 {:ok,
320 %Response{
321 status_code: 200,
322 body: File.read!("test/fixtures/httpoison_mock/sakamoto_eal_feed.atom")
323 }}
324 end
325
326 def get("http://gs.example.org/index.php/api/statuses/user_timeline/1.atom", _body, _headers) do
327 {:ok,
328 %Response{
329 status_code: 200,
330 body:
331 File.read!(
332 "test/fixtures/httpoison_mock/http__gs.example.org_index.php_api_statuses_user_timeline_1.atom.xml"
333 )
334 }}
335 end
336
337 def get("https://shitposter.club/notice/2827873", _body, _headers) do
338 {:ok,
339 %Response{
340 status_code: 200,
341 body:
342 File.read!("test/fixtures/httpoison_mock/https___shitposter.club_notice_2827873.html")
343 }}
344 end
345
346 def get("https://shitposter.club/api/statuses/show/2827873.atom", _body, _headers) do
347 {:ok,
348 %Response{
349 status_code: 200,
350 body:
351 File.read!(
352 "test/fixtures/httpoison_mock/https___shitposter.club_api_statuses_show_2827873.atom.xml"
353 )
354 }}
355 end
356
357 def get("https://shitposter.club/api/statuses/user_timeline/1.atom", _body, _headers) do
358 {:ok,
359 %Response{
360 status_code: 200,
361 body:
362 File.read!(
363 "test/fixtures/httpoison_mock/https___shitposter.club_api_statuses_user_timeline_1.atom.xml"
364 )
365 }}
366 end
367
368 def post(
369 "https://social.heldscal.la/main/push/hub",
370 {:form, _data},
371 "Content-type": "application/x-www-form-urlencoded"
372 ) do
373 {:ok,
374 %Response{
375 status_code: 202
376 }}
377 end
378
379 def get(
380 "https://pawoo.net/.well-known/webfinger",
381 [Accept: "application/xrd+xml,application/jrd+json"],
382 params: [resource: "https://pawoo.net/users/pekorino"],
383 follow_redirect: true
384 ) do
385 {:ok,
386 %Response{
387 status_code: 200,
388 body: File.read!("test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.xml")
389 }}
390 end
391
392 def get(
393 "https://pawoo.net/.well-known/webfinger?resource=https://pawoo.net/users/pekorino",
394 [Accept: "application/xrd+xml,application/jrd+json"],
395 follow_redirect: true
396 ) do
397 {:ok,
398 %Response{
399 status_code: 200,
400 body: File.read!("test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.xml")
401 }}
402 end
403
404 def get("https://pawoo.net/users/pekorino.atom", _, _) do
405 {:ok,
406 %Response{
407 status_code: 200,
408 body: File.read!("test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.atom")
409 }}
410 end
411
412 def get(
413 "https://mamot.fr/.well-known/webfinger",
414 [Accept: "application/xrd+xml,application/jrd+json"],
415 params: [resource: "https://mamot.fr/users/Skruyb"],
416 follow_redirect: true
417 ) do
418 {:ok,
419 %Response{
420 status_code: 200,
421 body: File.read!("test/fixtures/httpoison_mock/skruyb@mamot.fr.atom")
422 }}
423 end
424
425 def get(
426 "https://mamot.fr/.well-known/webfinger?resource=https://mamot.fr/users/Skruyb",
427 [Accept: "application/xrd+xml,application/jrd+json"],
428 follow_redirect: true
429 ) do
430 {:ok,
431 %Response{
432 status_code: 200,
433 body: File.read!("test/fixtures/httpoison_mock/skruyb@mamot.fr.atom")
434 }}
435 end
436
437 def get(
438 "https://social.sakamoto.gq/.well-known/webfinger",
439 [Accept: "application/xrd+xml,application/jrd+json"],
440 params: [resource: "https://social.sakamoto.gq/users/eal"],
441 follow_redirect: true
442 ) do
443 {:ok,
444 %Response{
445 status_code: 200,
446 body: File.read!("test/fixtures/httpoison_mock/eal_sakamoto.xml")
447 }}
448 end
449
450 def get(
451 "https://social.sakamoto.gq/.well-known/webfinger?resource=https://social.sakamoto.gq/users/eal",
452 [Accept: "application/xrd+xml,application/jrd+json"],
453 follow_redirect: true
454 ) do
455 {:ok,
456 %Response{
457 status_code: 200,
458 body: File.read!("test/fixtures/httpoison_mock/eal_sakamoto.xml")
459 }}
460 end
461
462 def get(
463 "https://pleroma.soykaf.com/.well-known/webfinger?resource=https://pleroma.soykaf.com/users/shp",
464 [Accept: "application/xrd+xml,application/jrd+json"],
465 follow_redirect: true
466 ) do
467 {:ok,
468 %Response{
469 status_code: 200,
470 body: File.read!("test/fixtures/httpoison_mock/shp@pleroma.soykaf.com.webfigner")
471 }}
472 end
473
474 def get(
475 "https://squeet.me/xrd/?uri=lain@squeet.me",
476 [Accept: "application/xrd+xml,application/jrd+json"],
477 follow_redirect: true
478 ) do
479 {:ok,
480 %Response{
481 status_code: 200,
482 body: File.read!("test/fixtures/httpoison_mock/lain_squeet.me_webfinger.xml")
483 }}
484 end
485
486 def get("https://mamot.fr/users/Skruyb.atom", _, _) do
487 {:ok,
488 %Response{
489 status_code: 200,
490 body: File.read!("test/fixtures/httpoison_mock/https___mamot.fr_users_Skruyb.atom")
491 }}
492 end
493
494 def get(
495 "https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056",
496 [Accept: "application/atom+xml"],
497 _
498 ) do
499 {:ok,
500 %Response{
501 status_code: 200,
502 body: File.read!("test/fixtures/httpoison_mock/sakamoto.atom")
503 }}
504 end
505
506 def get("https://pleroma.soykaf.com/users/shp/feed.atom", _, _) do
507 {:ok,
508 %Response{
509 status_code: 200,
510 body: File.read!("test/fixtures/httpoison_mock/shp@pleroma.soykaf.com.feed")
511 }}
512 end
513
514 def get("http://social.heldscal.la/.well-known/host-meta", [], follow_redirect: true) do
515 {:ok,
516 %Response{
517 status_code: 200,
518 body: File.read!("test/fixtures/httpoison_mock/social.heldscal.la_host_meta")
519 }}
520 end
521
522 def get("http://macgirvin.com/.well-known/host-meta", [], follow_redirect: true) do
523 {:ok,
524 %Response{
525 status_code: 200,
526 body: File.read!("test/fixtures/httpoison_mock/macgirvin.com_host_meta")
527 }}
528 end
529
530 def get("http://mastodon.social/.well-known/host-meta", [], follow_redirect: true) do
531 {:ok,
532 %Response{
533 status_code: 200,
534 body: File.read!("test/fixtures/httpoison_mock/mastodon.social_host_meta")
535 }}
536 end
537
538 def get("http://shitposter.club/.well-known/host-meta", [], follow_redirect: true) do
539 {:ok,
540 %Response{
541 status_code: 200,
542 body: File.read!("test/fixtures/httpoison_mock/shitposter.club_host_meta")
543 }}
544 end
545
546 def get("http://pleroma.soykaf.com/.well-known/host-meta", [], follow_redirect: true) do
547 {:ok,
548 %Response{
549 status_code: 200,
550 body: File.read!("test/fixtures/httpoison_mock/pleroma.soykaf.com_host_meta")
551 }}
552 end
553
554 def get("http://social.sakamoto.gq/.well-known/host-meta", [], follow_redirect: true) do
555 {:ok,
556 %Response{
557 status_code: 200,
558 body: File.read!("test/fixtures/httpoison_mock/social.sakamoto.gq_host_meta")
559 }}
560 end
561
562 def get("http://gs.example.org/.well-known/host-meta", [], follow_redirect: true) do
563 {:ok,
564 %Response{
565 status_code: 200,
566 body: File.read!("test/fixtures/httpoison_mock/gs.example.org_host_meta")
567 }}
568 end
569
570 def get("http://pawoo.net/.well-known/host-meta", [], follow_redirect: true) do
571 {:ok,
572 %Response{
573 status_code: 200,
574 body: File.read!("test/fixtures/httpoison_mock/pawoo.net_host_meta")
575 }}
576 end
577
578 def get("http://mamot.fr/.well-known/host-meta", [], follow_redirect: true) do
579 {:ok,
580 %Response{
581 status_code: 200,
582 body: File.read!("test/fixtures/httpoison_mock/mamot.fr_host_meta")
583 }}
584 end
585
586 def get("http://mastodon.xyz/.well-known/host-meta", [], follow_redirect: true) do
587 {:ok,
588 %Response{
589 status_code: 200,
590 body: File.read!("test/fixtures/httpoison_mock/mastodon.xyz_host_meta")
591 }}
592 end
593
594 def get("http://social.wxcafe.net/.well-known/host-meta", [], follow_redirect: true) do
595 {:ok,
596 %Response{
597 status_code: 200,
598 body: File.read!("test/fixtures/httpoison_mock/social.wxcafe.net_host_meta")
599 }}
600 end
601
602 def get("http://squeet.me/.well-known/host-meta", [], follow_redirect: true) do
603 {:ok,
604 %Response{
605 status_code: 200,
606 body: File.read!("test/fixtures/httpoison_mock/squeet.me_host_meta")
607 }}
608 end
609
610 def get(
611 "http://social.stopwatchingus-heidelberg.de/.well-known/host-meta",
612 [],
613 follow_redirect: true
614 ) do
615 {:ok,
616 %Response{
617 status_code: 200,
618 body:
619 File.read!("test/fixtures/httpoison_mock/social.stopwatchingus-heidelberg.de_host_meta")
620 }}
621 end
622
623 def get("http://mastodon.example.org/users/admin", [Accept: "application/activity+json"], _) do
624 {:ok,
625 %Response{
626 status_code: 200,
627 body: File.read!("test/fixtures/httpoison_mock/admin@mastdon.example.org.json")
628 }}
629 end
630
631 def get("https://masto.quad.moe/users/_HellPie", [Accept: "application/activity+json"], _) do
632 {:ok,
633 %Response{
634 status_code: 200,
635 body: File.read!("test/fixtures/httpoison_mock/hellpie.json")
636 }}
637 end
638
639 def get("https://niu.moe/users/rye", [Accept: "application/activity+json"], _) do
640 {:ok,
641 %Response{
642 status_code: 200,
643 body: File.read!("test/fixtures/httpoison_mock/rye.json")
644 }}
645 end
646
647 def get(
648 "https://mst3k.interlinked.me/users/luciferMysticus",
649 [Accept: "application/activity+json"],
650 _
651 ) do
652 {:ok,
653 %Response{
654 status_code: 200,
655 body: File.read!("test/fixtures/httpoison_mock/lucifermysticus.json")
656 }}
657 end
658
659 def get("https://mstdn.io/users/mayuutann", [Accept: "application/activity+json"], _) do
660 {:ok,
661 %Response{
662 status_code: 200,
663 body: File.read!("test/fixtures/httpoison_mock/mayumayu.json")
664 }}
665 end
666
667 def get(
668 "http://mastodon.example.org/@admin/99541947525187367",
669 [Accept: "application/activity+json"],
670 _
671 ) do
672 {:ok,
673 %Response{
674 status_code: 200,
675 body: File.read!("test/fixtures/mastodon-note-object.json")
676 }}
677 end
678
679 def get(
680 "https://mstdn.io/users/mayuutann/statuses/99568293732299394",
681 [Accept: "application/activity+json"],
682 _
683 ) do
684 {:ok,
685 %Response{
686 status_code: 200,
687 body: File.read!("test/fixtures/httpoison_mock/mayumayupost.json")
688 }}
689 end
690
691 def get("https://shitposter.club/notice/7369654", _, _) do
692 {:ok,
693 %Response{
694 status_code: 200,
695 body: File.read!("test/fixtures/httpoison_mock/7369654.html")
696 }}
697 end
698
699 def get("https://shitposter.club/api/statuses/show/7369654.atom", _body, _headers) do
700 {:ok,
701 %Response{
702 status_code: 200,
703 body: File.read!("test/fixtures/httpoison_mock/7369654.atom")
704 }}
705 end
706
707 def get(url, body, headers) do
708 {:error,
709 "Not implemented the mock response for get #{inspect(url)}, #{inspect(body)}, #{
710 inspect(headers)
711 }"}
712 end
713
714 def post(url, _body, _headers) do
715 {:error, "Not implemented the mock response for post #{inspect(url)}"}
716 end
717
718 def post(url, _body, _headers, _options) do
719 {:error, "Not implemented the mock response for post #{inspect(url)}"}
720 end
721 end