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