Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1440 lines
37KB

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule HttpRequestMock do
  5. require Logger
  6. def request(
  7. %Tesla.Env{
  8. url: url,
  9. method: method,
  10. headers: headers,
  11. query: query,
  12. body: body
  13. } = _env
  14. ) do
  15. with {:ok, res} <- apply(__MODULE__, method, [url, query, body, headers]) do
  16. res
  17. else
  18. error ->
  19. with {:error, message} <- error do
  20. Logger.warn(to_string(message))
  21. end
  22. {_, _r} = error
  23. end
  24. end
  25. # GET Requests
  26. #
  27. def get(url, query \\ [], body \\ [], headers \\ [])
  28. def get("https://osada.macgirvin.com/channel/mike", _, _, _) do
  29. {:ok,
  30. %Tesla.Env{
  31. status: 200,
  32. body: File.read!("test/fixtures/tesla_mock/https___osada.macgirvin.com_channel_mike.json")
  33. }}
  34. end
  35. def get("https://shitposter.club/users/moonman", _, _, _) do
  36. {:ok,
  37. %Tesla.Env{
  38. status: 200,
  39. body: File.read!("test/fixtures/tesla_mock/moonman@shitposter.club.json")
  40. }}
  41. end
  42. def get("https://mastodon.social/users/emelie/statuses/101849165031453009", _, _, _) do
  43. {:ok,
  44. %Tesla.Env{
  45. status: 200,
  46. body: File.read!("test/fixtures/tesla_mock/status.emelie.json")
  47. }}
  48. end
  49. def get("https://mastodon.social/users/emelie/statuses/101849165031453404", _, _, _) do
  50. {:ok,
  51. %Tesla.Env{
  52. status: 404,
  53. body: ""
  54. }}
  55. end
  56. def get("https://mastodon.social/users/emelie", _, _, _) do
  57. {:ok,
  58. %Tesla.Env{
  59. status: 200,
  60. body: File.read!("test/fixtures/tesla_mock/emelie.json")
  61. }}
  62. end
  63. def get("https://mastodon.social/users/not_found", _, _, _) do
  64. {:ok, %Tesla.Env{status: 404}}
  65. end
  66. def get("https://mastodon.sdf.org/users/rinpatch", _, _, _) do
  67. {:ok,
  68. %Tesla.Env{
  69. status: 200,
  70. body: File.read!("test/fixtures/tesla_mock/rinpatch.json")
  71. }}
  72. end
  73. def get("https://patch.cx/objects/tesla_mock/poll_attachment", _, _, _) do
  74. {:ok,
  75. %Tesla.Env{
  76. status: 200,
  77. body: File.read!("test/fixtures/tesla_mock/poll_attachment.json")
  78. }}
  79. end
  80. def get(
  81. "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/emelie",
  82. _,
  83. _,
  84. _
  85. ) do
  86. {:ok,
  87. %Tesla.Env{
  88. status: 200,
  89. body: File.read!("test/fixtures/tesla_mock/webfinger_emelie.json")
  90. }}
  91. end
  92. def get("https://mastodon.social/users/emelie.atom", _, _, _) do
  93. {:ok,
  94. %Tesla.Env{
  95. status: 200,
  96. body: File.read!("test/fixtures/tesla_mock/emelie.atom")
  97. }}
  98. end
  99. def get(
  100. "https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com",
  101. _,
  102. _,
  103. [{"accept", "application/xrd+xml,application/jrd+json"}]
  104. ) do
  105. {:ok,
  106. %Tesla.Env{
  107. status: 200,
  108. body: File.read!("test/fixtures/tesla_mock/mike@osada.macgirvin.com.json")
  109. }}
  110. end
  111. def get(
  112. "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/29191",
  113. _,
  114. _,
  115. [{"accept", "application/xrd+xml,application/jrd+json"}]
  116. ) do
  117. {:ok,
  118. %Tesla.Env{
  119. status: 200,
  120. body: File.read!("test/fixtures/tesla_mock/https___social.heldscal.la_user_29191.xml")
  121. }}
  122. end
  123. def get("https://pawoo.net/users/pekorino.atom", _, _, _) do
  124. {:ok,
  125. %Tesla.Env{
  126. status: 200,
  127. body: File.read!("test/fixtures/tesla_mock/https___pawoo.net_users_pekorino.atom")
  128. }}
  129. end
  130. def get(
  131. "https://pawoo.net/.well-known/webfinger?resource=acct:https://pawoo.net/users/pekorino",
  132. _,
  133. _,
  134. [{"accept", "application/xrd+xml,application/jrd+json"}]
  135. ) do
  136. {:ok,
  137. %Tesla.Env{
  138. status: 200,
  139. body: File.read!("test/fixtures/tesla_mock/https___pawoo.net_users_pekorino.xml")
  140. }}
  141. end
  142. def get(
  143. "https://social.stopwatchingus-heidelberg.de/api/statuses/user_timeline/18330.atom",
  144. _,
  145. _,
  146. _
  147. ) do
  148. {:ok,
  149. %Tesla.Env{
  150. status: 200,
  151. body: File.read!("test/fixtures/tesla_mock/atarifrosch_feed.xml")
  152. }}
  153. end
  154. def get(
  155. "https://social.stopwatchingus-heidelberg.de/.well-known/webfinger?resource=acct:https://social.stopwatchingus-heidelberg.de/user/18330",
  156. _,
  157. _,
  158. [{"accept", "application/xrd+xml,application/jrd+json"}]
  159. ) do
  160. {:ok,
  161. %Tesla.Env{
  162. status: 200,
  163. body: File.read!("test/fixtures/tesla_mock/atarifrosch_webfinger.xml")
  164. }}
  165. end
  166. def get("https://mamot.fr/users/Skruyb.atom", _, _, _) do
  167. {:ok,
  168. %Tesla.Env{
  169. status: 200,
  170. body: File.read!("test/fixtures/tesla_mock/https___mamot.fr_users_Skruyb.atom")
  171. }}
  172. end
  173. def get(
  174. "https://mamot.fr/.well-known/webfinger?resource=acct:https://mamot.fr/users/Skruyb",
  175. _,
  176. _,
  177. [{"accept", "application/xrd+xml,application/jrd+json"}]
  178. ) do
  179. {:ok,
  180. %Tesla.Env{
  181. status: 200,
  182. body: File.read!("test/fixtures/tesla_mock/skruyb@mamot.fr.atom")
  183. }}
  184. end
  185. def get(
  186. "https://social.heldscal.la/.well-known/webfinger?resource=nonexistant@social.heldscal.la",
  187. _,
  188. _,
  189. [{"accept", "application/xrd+xml,application/jrd+json"}]
  190. ) do
  191. {:ok,
  192. %Tesla.Env{
  193. status: 200,
  194. body: File.read!("test/fixtures/tesla_mock/nonexistant@social.heldscal.la.xml")
  195. }}
  196. end
  197. def get(
  198. "https://squeet.me/xrd/?uri=acct:lain@squeet.me",
  199. _,
  200. _,
  201. [{"accept", "application/xrd+xml,application/jrd+json"}]
  202. ) do
  203. {:ok,
  204. %Tesla.Env{
  205. status: 200,
  206. body: File.read!("test/fixtures/tesla_mock/lain_squeet.me_webfinger.xml")
  207. }}
  208. end
  209. def get(
  210. "https://mst3k.interlinked.me/users/luciferMysticus",
  211. _,
  212. _,
  213. [{"accept", "application/activity+json"}]
  214. ) do
  215. {:ok,
  216. %Tesla.Env{
  217. status: 200,
  218. body: File.read!("test/fixtures/tesla_mock/lucifermysticus.json")
  219. }}
  220. end
  221. def get("https://prismo.news/@mxb", _, _, _) do
  222. {:ok,
  223. %Tesla.Env{
  224. status: 200,
  225. body: File.read!("test/fixtures/tesla_mock/https___prismo.news__mxb.json")
  226. }}
  227. end
  228. def get(
  229. "https://hubzilla.example.org/channel/kaniini",
  230. _,
  231. _,
  232. [{"accept", "application/activity+json"}]
  233. ) do
  234. {:ok,
  235. %Tesla.Env{
  236. status: 200,
  237. body: File.read!("test/fixtures/tesla_mock/kaniini@hubzilla.example.org.json")
  238. }}
  239. end
  240. def get("https://niu.moe/users/rye", _, _, [{"accept", "application/activity+json"}]) do
  241. {:ok,
  242. %Tesla.Env{
  243. status: 200,
  244. body: File.read!("test/fixtures/tesla_mock/rye.json")
  245. }}
  246. end
  247. def get("https://n1u.moe/users/rye", _, _, [{"accept", "application/activity+json"}]) do
  248. {:ok,
  249. %Tesla.Env{
  250. status: 200,
  251. body: File.read!("test/fixtures/tesla_mock/rye.json")
  252. }}
  253. end
  254. def get("http://mastodon.example.org/users/admin/statuses/100787282858396771", _, _, _) do
  255. {:ok,
  256. %Tesla.Env{
  257. status: 200,
  258. body:
  259. File.read!(
  260. "test/fixtures/tesla_mock/http___mastodon.example.org_users_admin_status_1234.json"
  261. )
  262. }}
  263. end
  264. def get("https://puckipedia.com/", _, _, [{"accept", "application/activity+json"}]) do
  265. {:ok,
  266. %Tesla.Env{
  267. status: 200,
  268. body: File.read!("test/fixtures/tesla_mock/puckipedia.com.json")
  269. }}
  270. end
  271. def get("https://peertube.moe/accounts/7even", _, _, _) do
  272. {:ok,
  273. %Tesla.Env{
  274. status: 200,
  275. body: File.read!("test/fixtures/tesla_mock/7even.json")
  276. }}
  277. end
  278. def get("https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3", _, _, _) do
  279. {:ok,
  280. %Tesla.Env{
  281. status: 200,
  282. body: File.read!("test/fixtures/tesla_mock/peertube.moe-vid.json")
  283. }}
  284. end
  285. def get("https://framatube.org/accounts/framasoft", _, _, _) do
  286. {:ok,
  287. %Tesla.Env{
  288. status: 200,
  289. body: File.read!("test/fixtures/tesla_mock/https___framatube.org_accounts_framasoft.json")
  290. }}
  291. end
  292. def get("https://framatube.org/videos/watch/6050732a-8a7a-43d4-a6cd-809525a1d206", _, _, _) do
  293. {:ok,
  294. %Tesla.Env{
  295. status: 200,
  296. body: File.read!("test/fixtures/tesla_mock/framatube.org-video.json")
  297. }}
  298. end
  299. def get("https://peertube.social/accounts/craigmaloney", _, _, _) do
  300. {:ok,
  301. %Tesla.Env{
  302. status: 200,
  303. body: File.read!("test/fixtures/tesla_mock/craigmaloney.json")
  304. }}
  305. end
  306. def get("https://peertube.social/videos/watch/278d2b7c-0f38-4aaa-afe6-9ecc0c4a34fe", _, _, _) do
  307. {:ok,
  308. %Tesla.Env{
  309. status: 200,
  310. body: File.read!("test/fixtures/tesla_mock/peertube-social.json")
  311. }}
  312. end
  313. def get("https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39", _, _, [
  314. {"accept", "application/activity+json"}
  315. ]) do
  316. {:ok,
  317. %Tesla.Env{
  318. status: 200,
  319. body: File.read!("test/fixtures/tesla_mock/mobilizon.org-event.json")
  320. }}
  321. end
  322. def get("https://mobilizon.org/@tcit", _, _, [{"accept", "application/activity+json"}]) do
  323. {:ok,
  324. %Tesla.Env{
  325. status: 200,
  326. body: File.read!("test/fixtures/tesla_mock/mobilizon.org-user.json")
  327. }}
  328. end
  329. def get("https://baptiste.gelez.xyz/@/BaptisteGelez", _, _, _) do
  330. {:ok,
  331. %Tesla.Env{
  332. status: 200,
  333. body: File.read!("test/fixtures/tesla_mock/baptiste.gelex.xyz-user.json")
  334. }}
  335. end
  336. def get("https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/", _, _, _) do
  337. {:ok,
  338. %Tesla.Env{
  339. status: 200,
  340. body: File.read!("test/fixtures/tesla_mock/baptiste.gelex.xyz-article.json")
  341. }}
  342. end
  343. def get("https://wedistribute.org/wp-json/pterotype/v1/object/85810", _, _, _) do
  344. {:ok,
  345. %Tesla.Env{
  346. status: 200,
  347. body: File.read!("test/fixtures/tesla_mock/wedistribute-article.json")
  348. }}
  349. end
  350. def get("https://wedistribute.org/wp-json/pterotype/v1/actor/-blog", _, _, _) do
  351. {:ok,
  352. %Tesla.Env{
  353. status: 200,
  354. body: File.read!("test/fixtures/tesla_mock/wedistribute-user.json")
  355. }}
  356. end
  357. def get("http://mastodon.example.org/users/admin", _, _, _) do
  358. {:ok,
  359. %Tesla.Env{
  360. status: 200,
  361. body: File.read!("test/fixtures/tesla_mock/admin@mastdon.example.org.json")
  362. }}
  363. end
  364. def get("http://mastodon.example.org/users/relay", _, _, [
  365. {"accept", "application/activity+json"}
  366. ]) do
  367. {:ok,
  368. %Tesla.Env{
  369. status: 200,
  370. body: File.read!("test/fixtures/tesla_mock/relay@mastdon.example.org.json")
  371. }}
  372. end
  373. def get("http://mastodon.example.org/users/gargron", _, _, [
  374. {"accept", "application/activity+json"}
  375. ]) do
  376. {:error, :nxdomain}
  377. end
  378. def get("http://osada.macgirvin.com/.well-known/host-meta", _, _, _) do
  379. {:ok,
  380. %Tesla.Env{
  381. status: 404,
  382. body: ""
  383. }}
  384. end
  385. def get("https://osada.macgirvin.com/.well-known/host-meta", _, _, _) do
  386. {:ok,
  387. %Tesla.Env{
  388. status: 404,
  389. body: ""
  390. }}
  391. end
  392. def get("http://mastodon.sdf.org/.well-known/host-meta", _, _, _) do
  393. {:ok,
  394. %Tesla.Env{
  395. status: 200,
  396. body: File.read!("test/fixtures/tesla_mock/sdf.org_host_meta")
  397. }}
  398. end
  399. def get("https://mastodon.sdf.org/.well-known/host-meta", _, _, _) do
  400. {:ok,
  401. %Tesla.Env{
  402. status: 200,
  403. body: File.read!("test/fixtures/tesla_mock/sdf.org_host_meta")
  404. }}
  405. end
  406. def get(
  407. "https://mastodon.sdf.org/.well-known/webfinger?resource=https://mastodon.sdf.org/users/snowdusk",
  408. _,
  409. _,
  410. _
  411. ) do
  412. {:ok,
  413. %Tesla.Env{
  414. status: 200,
  415. body: File.read!("test/fixtures/tesla_mock/snowdusk@sdf.org_host_meta.json")
  416. }}
  417. end
  418. def get("http://mstdn.jp/.well-known/host-meta", _, _, _) do
  419. {:ok,
  420. %Tesla.Env{
  421. status: 200,
  422. body: File.read!("test/fixtures/tesla_mock/mstdn.jp_host_meta")
  423. }}
  424. end
  425. def get("https://mstdn.jp/.well-known/host-meta", _, _, _) do
  426. {:ok,
  427. %Tesla.Env{
  428. status: 200,
  429. body: File.read!("test/fixtures/tesla_mock/mstdn.jp_host_meta")
  430. }}
  431. end
  432. def get("https://mstdn.jp/.well-known/webfinger?resource=kpherox@mstdn.jp", _, _, _) do
  433. {:ok,
  434. %Tesla.Env{
  435. status: 200,
  436. body: File.read!("test/fixtures/tesla_mock/kpherox@mstdn.jp.xml")
  437. }}
  438. end
  439. def get("http://mamot.fr/.well-known/host-meta", _, _, _) do
  440. {:ok,
  441. %Tesla.Env{
  442. status: 200,
  443. body: File.read!("test/fixtures/tesla_mock/mamot.fr_host_meta")
  444. }}
  445. end
  446. def get("https://mamot.fr/.well-known/host-meta", _, _, _) do
  447. {:ok,
  448. %Tesla.Env{
  449. status: 200,
  450. body: File.read!("test/fixtures/tesla_mock/mamot.fr_host_meta")
  451. }}
  452. end
  453. def get(
  454. "https://mamot.fr/.well-known/webfinger?resource=https://mamot.fr/users/Skruyb",
  455. _,
  456. _,
  457. _
  458. ) do
  459. {:ok,
  460. %Tesla.Env{
  461. status: 200,
  462. body: File.read!("test/fixtures/tesla_mock/skruyb@mamot.fr.atom")
  463. }}
  464. end
  465. def get("http://pawoo.net/.well-known/host-meta", _, _, _) do
  466. {:ok,
  467. %Tesla.Env{
  468. status: 200,
  469. body: File.read!("test/fixtures/tesla_mock/pawoo.net_host_meta")
  470. }}
  471. end
  472. def get("https://pawoo.net/.well-known/host-meta", _, _, _) do
  473. {:ok,
  474. %Tesla.Env{
  475. status: 200,
  476. body: File.read!("test/fixtures/tesla_mock/pawoo.net_host_meta")
  477. }}
  478. end
  479. def get(
  480. "https://pawoo.net/.well-known/webfinger?resource=https://pawoo.net/users/pekorino",
  481. _,
  482. _,
  483. _
  484. ) do
  485. {:ok,
  486. %Tesla.Env{
  487. status: 200,
  488. body: File.read!("test/fixtures/tesla_mock/pekorino@pawoo.net_host_meta.json")
  489. }}
  490. end
  491. def get("http://zetsubou.xn--q9jyb4c/.well-known/host-meta", _, _, _) do
  492. {:ok,
  493. %Tesla.Env{
  494. status: 200,
  495. body: File.read!("test/fixtures/tesla_mock/xn--q9jyb4c_host_meta")
  496. }}
  497. end
  498. def get("https://zetsubou.xn--q9jyb4c/.well-known/host-meta", _, _, _) do
  499. {:ok,
  500. %Tesla.Env{
  501. status: 200,
  502. body: File.read!("test/fixtures/tesla_mock/xn--q9jyb4c_host_meta")
  503. }}
  504. end
  505. def get("http://pleroma.soykaf.com/.well-known/host-meta", _, _, _) do
  506. {:ok,
  507. %Tesla.Env{
  508. status: 200,
  509. body: File.read!("test/fixtures/tesla_mock/soykaf.com_host_meta")
  510. }}
  511. end
  512. def get("https://pleroma.soykaf.com/.well-known/host-meta", _, _, _) do
  513. {:ok,
  514. %Tesla.Env{
  515. status: 200,
  516. body: File.read!("test/fixtures/tesla_mock/soykaf.com_host_meta")
  517. }}
  518. end
  519. def get("http://social.stopwatchingus-heidelberg.de/.well-known/host-meta", _, _, _) do
  520. {:ok,
  521. %Tesla.Env{
  522. status: 200,
  523. body: File.read!("test/fixtures/tesla_mock/stopwatchingus-heidelberg.de_host_meta")
  524. }}
  525. end
  526. def get("https://social.stopwatchingus-heidelberg.de/.well-known/host-meta", _, _, _) do
  527. {:ok,
  528. %Tesla.Env{
  529. status: 200,
  530. body: File.read!("test/fixtures/tesla_mock/stopwatchingus-heidelberg.de_host_meta")
  531. }}
  532. end
  533. def get(
  534. "http://mastodon.example.org/@admin/99541947525187367",
  535. _,
  536. _,
  537. _
  538. ) do
  539. {:ok,
  540. %Tesla.Env{
  541. status: 200,
  542. body: File.read!("test/fixtures/mastodon-note-object.json")
  543. }}
  544. end
  545. def get("http://mastodon.example.org/@admin/99541947525187368", _, _, _) do
  546. {:ok,
  547. %Tesla.Env{
  548. status: 404,
  549. body: ""
  550. }}
  551. end
  552. def get("https://shitposter.club/notice/7369654", _, _, _) do
  553. {:ok,
  554. %Tesla.Env{
  555. status: 200,
  556. body: File.read!("test/fixtures/tesla_mock/7369654.html")
  557. }}
  558. end
  559. def get("https://mstdn.io/users/mayuutann", _, _, [{"accept", "application/activity+json"}]) do
  560. {:ok,
  561. %Tesla.Env{
  562. status: 200,
  563. body: File.read!("test/fixtures/tesla_mock/mayumayu.json")
  564. }}
  565. end
  566. def get(
  567. "https://mstdn.io/users/mayuutann/statuses/99568293732299394",
  568. _,
  569. _,
  570. [{"accept", "application/activity+json"}]
  571. ) do
  572. {:ok,
  573. %Tesla.Env{
  574. status: 200,
  575. body: File.read!("test/fixtures/tesla_mock/mayumayupost.json")
  576. }}
  577. end
  578. def get("https://pleroma.soykaf.com/users/lain/feed.atom", _, _, _) do
  579. {:ok,
  580. %Tesla.Env{
  581. status: 200,
  582. body:
  583. File.read!(
  584. "test/fixtures/tesla_mock/https___pleroma.soykaf.com_users_lain_feed.atom.xml"
  585. )
  586. }}
  587. end
  588. def get(url, _, _, [{"accept", "application/xrd+xml,application/jrd+json"}])
  589. when url in [
  590. "https://pleroma.soykaf.com/.well-known/webfinger?resource=acct:https://pleroma.soykaf.com/users/lain",
  591. "https://pleroma.soykaf.com/.well-known/webfinger?resource=https://pleroma.soykaf.com/users/lain"
  592. ] do
  593. {:ok,
  594. %Tesla.Env{
  595. status: 200,
  596. body: File.read!("test/fixtures/tesla_mock/https___pleroma.soykaf.com_users_lain.xml")
  597. }}
  598. end
  599. def get("https://shitposter.club/api/statuses/user_timeline/1.atom", _, _, _) do
  600. {:ok,
  601. %Tesla.Env{
  602. status: 200,
  603. body:
  604. File.read!(
  605. "test/fixtures/tesla_mock/https___shitposter.club_api_statuses_user_timeline_1.atom.xml"
  606. )
  607. }}
  608. end
  609. def get(
  610. "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/1",
  611. _,
  612. _,
  613. [{"accept", "application/xrd+xml,application/jrd+json"}]
  614. ) do
  615. {:ok,
  616. %Tesla.Env{
  617. status: 200,
  618. body: File.read!("test/fixtures/tesla_mock/https___shitposter.club_user_1.xml")
  619. }}
  620. end
  621. def get("https://shitposter.club/notice/2827873", _, _, _) do
  622. {:ok,
  623. %Tesla.Env{
  624. status: 200,
  625. body: File.read!("test/fixtures/tesla_mock/https___shitposter.club_notice_2827873.json")
  626. }}
  627. end
  628. def get("https://shitposter.club/api/statuses/show/2827873.atom", _, _, _) do
  629. {:ok,
  630. %Tesla.Env{
  631. status: 200,
  632. body:
  633. File.read!(
  634. "test/fixtures/tesla_mock/https___shitposter.club_api_statuses_show_2827873.atom.xml"
  635. )
  636. }}
  637. end
  638. def get("https://testing.pleroma.lol/objects/b319022a-4946-44c5-9de9-34801f95507b", _, _, _) do
  639. {:ok, %Tesla.Env{status: 200}}
  640. end
  641. def get("https://shitposter.club/api/statuses/user_timeline/5381.atom", _, _, _) do
  642. {:ok,
  643. %Tesla.Env{
  644. status: 200,
  645. body: File.read!("test/fixtures/tesla_mock/spc_5381.atom")
  646. }}
  647. end
  648. def get(
  649. "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/5381",
  650. _,
  651. _,
  652. [{"accept", "application/xrd+xml,application/jrd+json"}]
  653. ) do
  654. {:ok,
  655. %Tesla.Env{
  656. status: 200,
  657. body: File.read!("test/fixtures/tesla_mock/spc_5381_xrd.xml")
  658. }}
  659. end
  660. def get("http://shitposter.club/.well-known/host-meta", _, _, _) do
  661. {:ok,
  662. %Tesla.Env{
  663. status: 200,
  664. body: File.read!("test/fixtures/tesla_mock/shitposter.club_host_meta")
  665. }}
  666. end
  667. def get("https://shitposter.club/api/statuses/show/7369654.atom", _, _, _) do
  668. {:ok,
  669. %Tesla.Env{
  670. status: 200,
  671. body: File.read!("test/fixtures/tesla_mock/7369654.atom")
  672. }}
  673. end
  674. def get("https://shitposter.club/notice/4027863", _, _, _) do
  675. {:ok,
  676. %Tesla.Env{
  677. status: 200,
  678. body: File.read!("test/fixtures/tesla_mock/7369654.html")
  679. }}
  680. end
  681. def get("https://social.sakamoto.gq/users/eal/feed.atom", _, _, _) do
  682. {:ok,
  683. %Tesla.Env{
  684. status: 200,
  685. body: File.read!("test/fixtures/tesla_mock/sakamoto_eal_feed.atom")
  686. }}
  687. end
  688. def get("http://social.sakamoto.gq/.well-known/host-meta", _, _, _) do
  689. {:ok,
  690. %Tesla.Env{
  691. status: 200,
  692. body: File.read!("test/fixtures/tesla_mock/social.sakamoto.gq_host_meta")
  693. }}
  694. end
  695. def get(
  696. "https://social.sakamoto.gq/.well-known/webfinger?resource=https://social.sakamoto.gq/users/eal",
  697. _,
  698. _,
  699. [{"accept", "application/xrd+xml,application/jrd+json"}]
  700. ) do
  701. {:ok,
  702. %Tesla.Env{
  703. status: 200,
  704. body: File.read!("test/fixtures/tesla_mock/eal_sakamoto.xml")
  705. }}
  706. end
  707. def get(
  708. "https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056",
  709. _,
  710. _,
  711. [{"accept", "application/atom+xml"}]
  712. ) do
  713. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/sakamoto.atom")}}
  714. end
  715. def get("http://mastodon.social/.well-known/host-meta", _, _, _) do
  716. {:ok,
  717. %Tesla.Env{
  718. status: 200,
  719. body: File.read!("test/fixtures/tesla_mock/mastodon.social_host_meta")
  720. }}
  721. end
  722. def get(
  723. "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/lambadalambda",
  724. _,
  725. _,
  726. [{"accept", "application/xrd+xml,application/jrd+json"}]
  727. ) do
  728. {:ok,
  729. %Tesla.Env{
  730. status: 200,
  731. body:
  732. File.read!("test/fixtures/tesla_mock/https___mastodon.social_users_lambadalambda.xml")
  733. }}
  734. end
  735. def get("http://gs.example.org/.well-known/host-meta", _, _, _) do
  736. {:ok,
  737. %Tesla.Env{
  738. status: 200,
  739. body: File.read!("test/fixtures/tesla_mock/gs.example.org_host_meta")
  740. }}
  741. end
  742. def get(
  743. "http://gs.example.org/.well-known/webfinger?resource=http://gs.example.org:4040/index.php/user/1",
  744. _,
  745. _,
  746. [{"accept", "application/xrd+xml,application/jrd+json"}]
  747. ) do
  748. {:ok,
  749. %Tesla.Env{
  750. status: 200,
  751. body:
  752. File.read!("test/fixtures/tesla_mock/http___gs.example.org_4040_index.php_user_1.xml")
  753. }}
  754. end
  755. def get(
  756. "http://gs.example.org:4040/index.php/user/1",
  757. _,
  758. _,
  759. [{"accept", "application/activity+json"}]
  760. ) do
  761. {:ok, %Tesla.Env{status: 406, body: ""}}
  762. end
  763. def get("http://gs.example.org/index.php/api/statuses/user_timeline/1.atom", _, _, _) do
  764. {:ok,
  765. %Tesla.Env{
  766. status: 200,
  767. body:
  768. File.read!(
  769. "test/fixtures/tesla_mock/http__gs.example.org_index.php_api_statuses_user_timeline_1.atom.xml"
  770. )
  771. }}
  772. end
  773. def get("https://social.heldscal.la/api/statuses/user_timeline/29191.atom", _, _, _) do
  774. {:ok,
  775. %Tesla.Env{
  776. status: 200,
  777. body:
  778. File.read!(
  779. "test/fixtures/tesla_mock/https___social.heldscal.la_api_statuses_user_timeline_29191.atom.xml"
  780. )
  781. }}
  782. end
  783. def get("http://squeet.me/.well-known/host-meta", _, _, _) do
  784. {:ok,
  785. %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/squeet.me_host_meta")}}
  786. end
  787. def get(
  788. "https://squeet.me/xrd?uri=lain@squeet.me",
  789. _,
  790. _,
  791. [{"accept", "application/xrd+xml,application/jrd+json"}]
  792. ) do
  793. {:ok,
  794. %Tesla.Env{
  795. status: 200,
  796. body: File.read!("test/fixtures/tesla_mock/lain_squeet.me_webfinger.xml")
  797. }}
  798. end
  799. def get(
  800. "https://social.heldscal.la/.well-known/webfinger?resource=acct:shp@social.heldscal.la",
  801. _,
  802. _,
  803. [{"accept", "application/xrd+xml,application/jrd+json"}]
  804. ) do
  805. {:ok,
  806. %Tesla.Env{
  807. status: 200,
  808. body: File.read!("test/fixtures/tesla_mock/shp@social.heldscal.la.xml")
  809. }}
  810. end
  811. def get(
  812. "https://social.heldscal.la/.well-known/webfinger?resource=acct:invalid_content@social.heldscal.la",
  813. _,
  814. _,
  815. [{"accept", "application/xrd+xml,application/jrd+json"}]
  816. ) do
  817. {:ok, %Tesla.Env{status: 200, body: ""}}
  818. end
  819. def get("http://framatube.org/.well-known/host-meta", _, _, _) do
  820. {:ok,
  821. %Tesla.Env{
  822. status: 200,
  823. body: File.read!("test/fixtures/tesla_mock/framatube.org_host_meta")
  824. }}
  825. end
  826. def get(
  827. "http://framatube.org/main/xrd?uri=acct:framasoft@framatube.org",
  828. _,
  829. _,
  830. [{"accept", "application/xrd+xml,application/jrd+json"}]
  831. ) do
  832. {:ok,
  833. %Tesla.Env{
  834. status: 200,
  835. headers: [{"content-type", "application/json"}],
  836. body: File.read!("test/fixtures/tesla_mock/framasoft@framatube.org.json")
  837. }}
  838. end
  839. def get("http://gnusocial.de/.well-known/host-meta", _, _, _) do
  840. {:ok,
  841. %Tesla.Env{
  842. status: 200,
  843. body: File.read!("test/fixtures/tesla_mock/gnusocial.de_host_meta")
  844. }}
  845. end
  846. def get(
  847. "http://gnusocial.de/main/xrd?uri=winterdienst@gnusocial.de",
  848. _,
  849. _,
  850. [{"accept", "application/xrd+xml,application/jrd+json"}]
  851. ) do
  852. {:ok,
  853. %Tesla.Env{
  854. status: 200,
  855. body: File.read!("test/fixtures/tesla_mock/winterdienst_webfinger.json")
  856. }}
  857. end
  858. def get("http://status.alpicola.com/.well-known/host-meta", _, _, _) do
  859. {:ok,
  860. %Tesla.Env{
  861. status: 200,
  862. body: File.read!("test/fixtures/tesla_mock/status.alpicola.com_host_meta")
  863. }}
  864. end
  865. def get("http://macgirvin.com/.well-known/host-meta", _, _, _) do
  866. {:ok,
  867. %Tesla.Env{
  868. status: 200,
  869. body: File.read!("test/fixtures/tesla_mock/macgirvin.com_host_meta")
  870. }}
  871. end
  872. def get("http://gerzilla.de/.well-known/host-meta", _, _, _) do
  873. {:ok,
  874. %Tesla.Env{
  875. status: 200,
  876. body: File.read!("test/fixtures/tesla_mock/gerzilla.de_host_meta")
  877. }}
  878. end
  879. def get(
  880. "https://gerzilla.de/xrd/?uri=acct:kaniini@gerzilla.de",
  881. _,
  882. _,
  883. [{"accept", "application/xrd+xml,application/jrd+json"}]
  884. ) do
  885. {:ok,
  886. %Tesla.Env{
  887. status: 200,
  888. headers: [{"content-type", "application/json"}],
  889. body: File.read!("test/fixtures/tesla_mock/kaniini@gerzilla.de.json")
  890. }}
  891. end
  892. def get("https://social.heldscal.la/api/statuses/user_timeline/23211.atom", _, _, _) do
  893. {:ok,
  894. %Tesla.Env{
  895. status: 200,
  896. body:
  897. File.read!(
  898. "test/fixtures/tesla_mock/https___social.heldscal.la_api_statuses_user_timeline_23211.atom.xml"
  899. )
  900. }}
  901. end
  902. def get(
  903. "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/23211",
  904. _,
  905. _,
  906. _
  907. ) do
  908. {:ok,
  909. %Tesla.Env{
  910. status: 200,
  911. body: File.read!("test/fixtures/tesla_mock/https___social.heldscal.la_user_23211.xml")
  912. }}
  913. end
  914. def get("http://social.heldscal.la/.well-known/host-meta", _, _, _) do
  915. {:ok,
  916. %Tesla.Env{
  917. status: 200,
  918. body: File.read!("test/fixtures/tesla_mock/social.heldscal.la_host_meta")
  919. }}
  920. end
  921. def get("https://social.heldscal.la/.well-known/host-meta", _, _, _) do
  922. {:ok,
  923. %Tesla.Env{
  924. status: 200,
  925. body: File.read!("test/fixtures/tesla_mock/social.heldscal.la_host_meta")
  926. }}
  927. end
  928. def get("https://mastodon.social/users/lambadalambda.atom", _, _, _) do
  929. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/lambadalambda.atom")}}
  930. end
  931. def get("https://mastodon.social/users/lambadalambda", _, _, _) do
  932. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/lambadalambda.json")}}
  933. end
  934. def get("https://apfed.club/channel/indio", _, _, _) do
  935. {:ok,
  936. %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/osada-user-indio.json")}}
  937. end
  938. def get("https://social.heldscal.la/user/23211", _, _, [{"accept", "application/activity+json"}]) do
  939. {:ok, Tesla.Mock.json(%{"id" => "https://social.heldscal.la/user/23211"}, status: 200)}
  940. end
  941. def get("http://example.com/ogp", _, _, _) do
  942. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
  943. end
  944. def get("https://example.com/ogp", _, _, _) do
  945. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
  946. end
  947. def get("https://pleroma.local/notice/9kCP7V", _, _, _) do
  948. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
  949. end
  950. def get("http://localhost:4001/users/masto_closed/followers", _, _, _) do
  951. {:ok,
  952. %Tesla.Env{
  953. status: 200,
  954. body: File.read!("test/fixtures/users_mock/masto_closed_followers.json")
  955. }}
  956. end
  957. def get("http://localhost:4001/users/masto_closed/followers?page=1", _, _, _) do
  958. {:ok,
  959. %Tesla.Env{
  960. status: 200,
  961. body: File.read!("test/fixtures/users_mock/masto_closed_followers_page.json")
  962. }}
  963. end
  964. def get("http://localhost:4001/users/masto_closed/following", _, _, _) do
  965. {:ok,
  966. %Tesla.Env{
  967. status: 200,
  968. body: File.read!("test/fixtures/users_mock/masto_closed_following.json")
  969. }}
  970. end
  971. def get("http://localhost:4001/users/masto_closed/following?page=1", _, _, _) do
  972. {:ok,
  973. %Tesla.Env{
  974. status: 200,
  975. body: File.read!("test/fixtures/users_mock/masto_closed_following_page.json")
  976. }}
  977. end
  978. def get("http://localhost:8080/followers/fuser3", _, _, _) do
  979. {:ok,
  980. %Tesla.Env{
  981. status: 200,
  982. body: File.read!("test/fixtures/users_mock/friendica_followers.json")
  983. }}
  984. end
  985. def get("http://localhost:8080/following/fuser3", _, _, _) do
  986. {:ok,
  987. %Tesla.Env{
  988. status: 200,
  989. body: File.read!("test/fixtures/users_mock/friendica_following.json")
  990. }}
  991. end
  992. def get("http://localhost:4001/users/fuser2/followers", _, _, _) do
  993. {:ok,
  994. %Tesla.Env{
  995. status: 200,
  996. body: File.read!("test/fixtures/users_mock/pleroma_followers.json")
  997. }}
  998. end
  999. def get("http://localhost:4001/users/fuser2/following", _, _, _) do
  1000. {:ok,
  1001. %Tesla.Env{
  1002. status: 200,
  1003. body: File.read!("test/fixtures/users_mock/pleroma_following.json")
  1004. }}
  1005. end
  1006. def get("http://domain-with-errors:4001/users/fuser1/followers", _, _, _) do
  1007. {:ok,
  1008. %Tesla.Env{
  1009. status: 504,
  1010. body: ""
  1011. }}
  1012. end
  1013. def get("http://domain-with-errors:4001/users/fuser1/following", _, _, _) do
  1014. {:ok,
  1015. %Tesla.Env{
  1016. status: 504,
  1017. body: ""
  1018. }}
  1019. end
  1020. def get("http://example.com/ogp-missing-data", _, _, _) do
  1021. {:ok,
  1022. %Tesla.Env{
  1023. status: 200,
  1024. body: File.read!("test/fixtures/rich_media/ogp-missing-data.html")
  1025. }}
  1026. end
  1027. def get("https://example.com/ogp-missing-data", _, _, _) do
  1028. {:ok,
  1029. %Tesla.Env{
  1030. status: 200,
  1031. body: File.read!("test/fixtures/rich_media/ogp-missing-data.html")
  1032. }}
  1033. end
  1034. def get("http://example.com/malformed", _, _, _) do
  1035. {:ok,
  1036. %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/malformed-data.html")}}
  1037. end
  1038. def get("http://example.com/empty", _, _, _) do
  1039. {:ok, %Tesla.Env{status: 200, body: "hello"}}
  1040. end
  1041. def get("http://404.site" <> _, _, _, _) do
  1042. {:ok,
  1043. %Tesla.Env{
  1044. status: 404,
  1045. body: ""
  1046. }}
  1047. end
  1048. def get(
  1049. "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=acct:lain@zetsubou.xn--q9jyb4c",
  1050. _,
  1051. _,
  1052. [{"accept", "application/xrd+xml,application/jrd+json"}]
  1053. ) do
  1054. {:ok,
  1055. %Tesla.Env{
  1056. status: 200,
  1057. body: File.read!("test/fixtures/lain.xml")
  1058. }}
  1059. end
  1060. def get(
  1061. "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=acct:https://zetsubou.xn--q9jyb4c/users/lain",
  1062. _,
  1063. _,
  1064. [{"accept", "application/xrd+xml,application/jrd+json"}]
  1065. ) do
  1066. {:ok,
  1067. %Tesla.Env{
  1068. status: 200,
  1069. body: File.read!("test/fixtures/lain.xml")
  1070. }}
  1071. end
  1072. def get(
  1073. "https://zetsubou.xn--q9jyb4c/.well-known/host-meta",
  1074. _,
  1075. _,
  1076. _
  1077. ) do
  1078. {:ok,
  1079. %Tesla.Env{
  1080. status: 200,
  1081. body: File.read!("test/fixtures/host-meta-zetsubou.xn--q9jyb4c.xml")
  1082. }}
  1083. end
  1084. def get("https://info.pleroma.site/activity.json", _, _, [
  1085. {"accept", "application/activity+json"}
  1086. ]) do
  1087. {:ok,
  1088. %Tesla.Env{
  1089. status: 200,
  1090. body: File.read!("test/fixtures/tesla_mock/https__info.pleroma.site_activity.json")
  1091. }}
  1092. end
  1093. def get("https://info.pleroma.site/activity.json", _, _, _) do
  1094. {:ok, %Tesla.Env{status: 404, body: ""}}
  1095. end
  1096. def get("https://info.pleroma.site/activity2.json", _, _, [
  1097. {"accept", "application/activity+json"}
  1098. ]) do
  1099. {:ok,
  1100. %Tesla.Env{
  1101. status: 200,
  1102. body: File.read!("test/fixtures/tesla_mock/https__info.pleroma.site_activity2.json")
  1103. }}
  1104. end
  1105. def get("https://info.pleroma.site/activity2.json", _, _, _) do
  1106. {:ok, %Tesla.Env{status: 404, body: ""}}
  1107. end
  1108. def get("https://info.pleroma.site/activity3.json", _, _, [
  1109. {"accept", "application/activity+json"}
  1110. ]) do
  1111. {:ok,
  1112. %Tesla.Env{
  1113. status: 200,
  1114. body: File.read!("test/fixtures/tesla_mock/https__info.pleroma.site_activity3.json")
  1115. }}
  1116. end
  1117. def get("https://info.pleroma.site/activity3.json", _, _, _) do
  1118. {:ok, %Tesla.Env{status: 404, body: ""}}
  1119. end
  1120. def get("https://mstdn.jp/.well-known/webfinger?resource=acct:kpherox@mstdn.jp", _, _, _) do
  1121. {:ok,
  1122. %Tesla.Env{
  1123. status: 200,
  1124. body: File.read!("test/fixtures/tesla_mock/kpherox@mstdn.jp.xml")
  1125. }}
  1126. end
  1127. def get("https://10.111.10.1/notice/9kCP7V", _, _, _) do
  1128. {:ok, %Tesla.Env{status: 200, body: ""}}
  1129. end
  1130. def get("https://172.16.32.40/notice/9kCP7V", _, _, _) do
  1131. {:ok, %Tesla.Env{status: 200, body: ""}}
  1132. end
  1133. def get("https://192.168.10.40/notice/9kCP7V", _, _, _) do
  1134. {:ok, %Tesla.Env{status: 200, body: ""}}
  1135. end
  1136. def get("https://www.patreon.com/posts/mastodon-2-9-and-28121681", _, _, _) do
  1137. {:ok, %Tesla.Env{status: 200, body: ""}}
  1138. end
  1139. def get("http://mastodon.example.org/@admin/99541947525187367", _, _, _) do
  1140. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/mastodon-post-activity.json")}}
  1141. end
  1142. def get("https://info.pleroma.site/activity4.json", _, _, _) do
  1143. {:ok, %Tesla.Env{status: 500, body: "Error occurred"}}
  1144. end
  1145. def get("http://example.com/rel_me/anchor", _, _, _) do
  1146. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor.html")}}
  1147. end
  1148. def get("http://example.com/rel_me/anchor_nofollow", _, _, _) do
  1149. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor_nofollow.html")}}
  1150. end
  1151. def get("http://example.com/rel_me/link", _, _, _) do
  1152. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_link.html")}}
  1153. end
  1154. def get("http://example.com/rel_me/null", _, _, _) do
  1155. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_null.html")}}
  1156. end
  1157. def get("https://skippers-bin.com/notes/7x9tmrp97i", _, _, _) do
  1158. {:ok,
  1159. %Tesla.Env{
  1160. status: 200,
  1161. body: File.read!("test/fixtures/tesla_mock/misskey_poll_no_end_date.json")
  1162. }}
  1163. end
  1164. def get("https://example.org/emoji/firedfox.png", _, _, _) do
  1165. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/image.jpg")}}
  1166. end
  1167. def get("https://skippers-bin.com/users/7v1w1r8ce6", _, _, _) do
  1168. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/sjw.json")}}
  1169. end
  1170. def get("https://patch.cx/users/rin", _, _, _) do
  1171. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/rin.json")}}
  1172. end
  1173. def get(
  1174. "https://channels.tests.funkwhale.audio/federation/music/uploads/42342395-0208-4fee-a38d-259a6dae0871",
  1175. _,
  1176. _,
  1177. _
  1178. ) do
  1179. {:ok,
  1180. %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/funkwhale_audio.json")}}
  1181. end
  1182. def get("https://channels.tests.funkwhale.audio/federation/actors/compositions", _, _, _) do
  1183. {:ok,
  1184. %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/funkwhale_channel.json")}}
  1185. end
  1186. def get("http://example.com/rel_me/error", _, _, _) do
  1187. {:ok, %Tesla.Env{status: 404, body: ""}}
  1188. end
  1189. def get("https://relay.mastodon.host/actor", _, _, _) do
  1190. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/relay/relay.json")}}
  1191. end
  1192. def get("http://localhost:4001/", _, "", Accept: "text/html") do
  1193. {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/7369654.html")}}
  1194. end
  1195. def get("https://osada.macgirvin.com/", _, "", Accept: "text/html") do
  1196. {:ok,
  1197. %Tesla.Env{
  1198. status: 200,
  1199. body: File.read!("test/fixtures/tesla_mock/https___osada.macgirvin.com.html")
  1200. }}
  1201. end
  1202. def get(url, query, body, headers) do
  1203. {:error,
  1204. "Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{
  1205. inspect(headers)
  1206. }"}
  1207. end
  1208. # POST Requests
  1209. #
  1210. def post(url, query \\ [], body \\ [], headers \\ [])
  1211. def post("https://relay.mastodon.host/inbox", _, _, _) do
  1212. {:ok, %Tesla.Env{status: 200, body: ""}}
  1213. end
  1214. def post("http://example.org/needs_refresh", _, _, _) do
  1215. {:ok,
  1216. %Tesla.Env{
  1217. status: 200,
  1218. body: ""
  1219. }}
  1220. end
  1221. def post("http://mastodon.example.org/inbox", _, _, _) do
  1222. {:ok,
  1223. %Tesla.Env{
  1224. status: 200,
  1225. body: ""
  1226. }}
  1227. end
  1228. def post("https://hubzilla.example.org/inbox", _, _, _) do
  1229. {:ok,
  1230. %Tesla.Env{
  1231. status: 200,
  1232. body: ""
  1233. }}
  1234. end
  1235. def post("http://gs.example.org/index.php/main/salmon/user/1", _, _, _) do
  1236. {:ok,
  1237. %Tesla.Env{
  1238. status: 200,
  1239. body: ""
  1240. }}
  1241. end
  1242. def post("http://200.site" <> _, _, _, _) do
  1243. {:ok,
  1244. %Tesla.Env{
  1245. status: 200,
  1246. body: ""
  1247. }}
  1248. end
  1249. def post("http://connrefused.site" <> _, _, _, _) do
  1250. {:error, :connrefused}
  1251. end
  1252. def post("http://404.site" <> _, _, _, _) do
  1253. {:ok,
  1254. %Tesla.Env{
  1255. status: 404,
  1256. body: ""
  1257. }}
  1258. end
  1259. def post(url, query, body, headers) do
  1260. {:error,
  1261. "Mock response not implemented for POST #{inspect(url)}, #{query}, #{inspect(body)}, #{
  1262. inspect(headers)
  1263. }"}
  1264. end
  1265. end