Merge develop
[akkoma] / test / support / http_request_mock.ex
index 9624cb0f76148fd86256becc0c6376d8aa4ef4df..344e27f137506a8fb65f43789b5df98a65c243ca 100644 (file)
@@ -82,6 +82,14 @@ defmodule HttpRequestMock do
      }}
   end
 
+  def get("https://patch.cx/objects/tesla_mock/poll_attachment", _, _, _) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/tesla_mock/poll_attachment.json")
+     }}
+  end
+
   def get(
         "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/emelie",
         _,
@@ -95,14 +103,6 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://mastodon.social/users/emelie.atom", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body: File.read!("test/fixtures/tesla_mock/emelie.atom")
-     }}
-  end
-
   def get(
         "https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com",
         _,
@@ -129,14 +129,6 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://pawoo.net/users/pekorino.atom", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body: File.read!("test/fixtures/tesla_mock/https___pawoo.net_users_pekorino.atom")
-     }}
-  end
-
   def get(
         "https://pawoo.net/.well-known/webfinger?resource=acct:https://pawoo.net/users/pekorino",
         _,
@@ -150,19 +142,6 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get(
-        "https://social.stopwatchingus-heidelberg.de/api/statuses/user_timeline/18330.atom",
-        _,
-        _,
-        _
-      ) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body: File.read!("test/fixtures/tesla_mock/atarifrosch_feed.xml")
-     }}
-  end
-
   def get(
         "https://social.stopwatchingus-heidelberg.de/.well-known/webfinger?resource=acct:https://social.stopwatchingus-heidelberg.de/user/18330",
         _,
@@ -176,27 +155,6 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://mamot.fr/users/Skruyb.atom", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body: File.read!("test/fixtures/tesla_mock/https___mamot.fr_users_Skruyb.atom")
-     }}
-  end
-
-  def get(
-        "https://mamot.fr/.well-known/webfinger?resource=acct:https://mamot.fr/users/Skruyb",
-        _,
-        _,
-        [{"accept", "application/xrd+xml,application/jrd+json"}]
-      ) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body: File.read!("test/fixtures/tesla_mock/skruyb@mamot.fr.atom")
-     }}
-  end
-
   def get(
         "https://social.heldscal.la/.well-known/webfinger?resource=nonexistant@social.heldscal.la",
         _,
@@ -211,7 +169,7 @@ defmodule HttpRequestMock do
   end
 
   def get(
-        "https://squeet.me/xrd/?uri=lain@squeet.me",
+        "https://squeet.me/xrd/?uri=acct:lain@squeet.me",
         _,
         _,
         [{"accept", "application/xrd+xml,application/jrd+json"}]
@@ -308,6 +266,22 @@ defmodule HttpRequestMock do
      }}
   end
 
+  def get("https://framatube.org/accounts/framasoft", _, _, _) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/tesla_mock/https___framatube.org_accounts_framasoft.json")
+     }}
+  end
+
+  def get("https://framatube.org/videos/watch/6050732a-8a7a-43d4-a6cd-809525a1d206", _, _, _) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/tesla_mock/framatube.org-video.json")
+     }}
+  end
+
   def get("https://peertube.social/accounts/craigmaloney", _, _, _) do
     {:ok,
      %Tesla.Env{
@@ -483,19 +457,6 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get(
-        "https://mamot.fr/.well-known/webfinger?resource=https://mamot.fr/users/Skruyb",
-        _,
-        _,
-        _
-      ) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body: File.read!("test/fixtures/tesla_mock/skruyb@mamot.fr.atom")
-     }}
-  end
-
   def get("http://pawoo.net/.well-known/host-meta", _, _, _) do
     {:ok,
      %Tesla.Env{
@@ -623,17 +584,6 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://pleroma.soykaf.com/users/lain/feed.atom", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body:
-         File.read!(
-           "test/fixtures/tesla_mock/https___pleroma.soykaf.com_users_lain_feed.atom.xml"
-         )
-     }}
-  end
-
   def get(url, _, _, [{"accept", "application/xrd+xml,application/jrd+json"}])
       when url in [
              "https://pleroma.soykaf.com/.well-known/webfinger?resource=acct:https://pleroma.soykaf.com/users/lain",
@@ -646,17 +596,6 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://shitposter.club/api/statuses/user_timeline/1.atom", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body:
-         File.read!(
-           "test/fixtures/tesla_mock/https___shitposter.club_api_statuses_user_timeline_1.atom.xml"
-         )
-     }}
-  end
-
   def get(
         "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/1",
         _,
@@ -670,37 +609,10 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://shitposter.club/notice/2827873", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body: File.read!("test/fixtures/tesla_mock/https___shitposter.club_notice_2827873.json")
-     }}
-  end
-
-  def get("https://shitposter.club/api/statuses/show/2827873.atom", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body:
-         File.read!(
-           "test/fixtures/tesla_mock/https___shitposter.club_api_statuses_show_2827873.atom.xml"
-         )
-     }}
-  end
-
   def get("https://testing.pleroma.lol/objects/b319022a-4946-44c5-9de9-34801f95507b", _, _, _) do
     {:ok, %Tesla.Env{status: 200}}
   end
 
-  def get("https://shitposter.club/api/statuses/user_timeline/5381.atom", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body: File.read!("test/fixtures/tesla_mock/spc_5381.atom")
-     }}
-  end
-
   def get(
         "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/5381",
         _,
@@ -722,14 +634,6 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://shitposter.club/api/statuses/show/7369654.atom", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body: File.read!("test/fixtures/tesla_mock/7369654.atom")
-     }}
-  end
-
   def get("https://shitposter.club/notice/4027863", _, _, _) do
     {:ok,
      %Tesla.Env{
@@ -738,14 +642,6 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://social.sakamoto.gq/users/eal/feed.atom", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body: File.read!("test/fixtures/tesla_mock/sakamoto_eal_feed.atom")
-     }}
-  end
-
   def get("http://social.sakamoto.gq/.well-known/host-meta", _, _, _) do
     {:ok,
      %Tesla.Env{
@@ -767,15 +663,6 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get(
-        "https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056",
-        _,
-        _,
-        [{"accept", "application/atom+xml"}]
-      ) do
-    {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/sakamoto.atom")}}
-  end
-
   def get("http://mastodon.social/.well-known/host-meta", _, _, _) do
     {:ok,
      %Tesla.Env{
@@ -829,28 +716,6 @@ defmodule HttpRequestMock do
     {:ok, %Tesla.Env{status: 406, body: ""}}
   end
 
-  def get("http://gs.example.org/index.php/api/statuses/user_timeline/1.atom", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body:
-         File.read!(
-           "test/fixtures/tesla_mock/http__gs.example.org_index.php_api_statuses_user_timeline_1.atom.xml"
-         )
-     }}
-  end
-
-  def get("https://social.heldscal.la/api/statuses/user_timeline/29191.atom", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body:
-         File.read!(
-           "test/fixtures/tesla_mock/https___social.heldscal.la_api_statuses_user_timeline_29191.atom.xml"
-         )
-     }}
-  end
-
   def get("http://squeet.me/.well-known/host-meta", _, _, _) do
     {:ok,
      %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/squeet.me_host_meta")}}
@@ -870,7 +735,7 @@ defmodule HttpRequestMock do
   end
 
   def get(
-        "https://social.heldscal.la/.well-known/webfinger?resource=shp@social.heldscal.la",
+        "https://social.heldscal.la/.well-known/webfinger?resource=acct:shp@social.heldscal.la",
         _,
         _,
         [{"accept", "application/xrd+xml,application/jrd+json"}]
@@ -883,7 +748,7 @@ defmodule HttpRequestMock do
   end
 
   def get(
-        "https://social.heldscal.la/.well-known/webfinger?resource=invalid_content@social.heldscal.la",
+        "https://social.heldscal.la/.well-known/webfinger?resource=acct:invalid_content@social.heldscal.la",
         _,
         _,
         [{"accept", "application/xrd+xml,application/jrd+json"}]
@@ -900,7 +765,7 @@ defmodule HttpRequestMock do
   end
 
   def get(
-        "http://framatube.org/main/xrd?uri=framasoft@framatube.org",
+        "http://framatube.org/main/xrd?uri=acct:framasoft@framatube.org",
         _,
         _,
         [{"accept", "application/xrd+xml,application/jrd+json"}]
@@ -959,7 +824,7 @@ defmodule HttpRequestMock do
   end
 
   def get(
-        "https://gerzilla.de/xrd/?uri=kaniini@gerzilla.de",
+        "https://gerzilla.de/xrd/?uri=acct:kaniini@gerzilla.de",
         _,
         _,
         [{"accept", "application/xrd+xml,application/jrd+json"}]
@@ -972,17 +837,6 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://social.heldscal.la/api/statuses/user_timeline/23211.atom", _, _, _) do
-    {:ok,
-     %Tesla.Env{
-       status: 200,
-       body:
-         File.read!(
-           "test/fixtures/tesla_mock/https___social.heldscal.la_api_statuses_user_timeline_23211.atom.xml"
-         )
-     }}
-  end
-
   def get(
         "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/23211",
         _,
@@ -1012,10 +866,6 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://mastodon.social/users/lambadalambda.atom", _, _, _) do
-    {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/lambadalambda.atom")}}
-  end
-
   def get("https://mastodon.social/users/lambadalambda", _, _, _) do
     {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/lambadalambda.json")}}
   end
@@ -1155,7 +1005,7 @@ defmodule HttpRequestMock do
   end
 
   def get(
-        "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=lain@zetsubou.xn--q9jyb4c",
+        "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=acct:lain@zetsubou.xn--q9jyb4c",
         _,
         _,
         [{"accept", "application/xrd+xml,application/jrd+json"}]
@@ -1168,7 +1018,7 @@ defmodule HttpRequestMock do
   end
 
   def get(
-        "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=https://zetsubou.xn--q9jyb4c/users/lain",
+        "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=acct:https://zetsubou.xn--q9jyb4c/users/lain",
         _,
         _,
         [{"accept", "application/xrd+xml,application/jrd+json"}]
@@ -1291,6 +1141,10 @@ defmodule HttpRequestMock do
      }}
   end
 
+  def get("https://example.org/emoji/firedfox.png", _, _, _) do
+    {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/image.jpg")}}
+  end
+
   def get("https://skippers-bin.com/users/7v1w1r8ce6", _, _, _) do
     {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/sjw.json")}}
   end
@@ -1322,6 +1176,18 @@ defmodule HttpRequestMock do
     {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/relay/relay.json")}}
   end
 
+  def get("http://localhost:4001/", _, "", [{"accept", "text/html"}]) do
+    {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/7369654.html")}}
+  end
+
+  def get("https://osada.macgirvin.com/", _, "", [{"accept", "text/html"}]) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/tesla_mock/https___osada.macgirvin.com.html")
+     }}
+  end
+
   def get(url, query, body, headers) do
     {:error,
      "Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{