implement Move activities (#45)
[akkoma] / test / support / http_request_mock.ex
index 8807c2d14679551e778c3cfe2661cefb6a54aec4..dfac773dec024aba0aa105ad9a2ba428de1ca613 100644 (file)
@@ -725,6 +725,15 @@ defmodule HttpRequestMock do
      }}
   end
 
+  def get(
+        "https://mastodon.social/.well-known/webfinger?resource=acct:not_found@mastodon.social",
+        _,
+        _,
+        [{"accept", "application/xrd+xml,application/jrd+json"}]
+      ) do
+    {:ok, %Tesla.Env{status: 404}}
+  end
+
   def get("http://gs.example.org/.well-known/host-meta", _, _, _) do
     {:ok,
      %Tesla.Env{
@@ -1124,6 +1133,57 @@ defmodule HttpRequestMock do
      }}
   end
 
+  def get("http://lm.kazv.moe/.well-known/host-meta", _, _, _) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/tesla_mock/lm.kazv.moe_host_meta")
+     }}
+  end
+
+  def get("https://lm.kazv.moe/.well-known/host-meta", _, _, _) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/tesla_mock/lm.kazv.moe_host_meta")
+     }}
+  end
+
+  def get(
+        "https://lm.kazv.moe/.well-known/webfinger?resource=acct:mewmew@lm.kazv.moe",
+        _,
+        _,
+        [{"accept", "application/xrd+xml,application/jrd+json"}]
+      ) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/tesla_mock/https___lm.kazv.moe_users_mewmew.xml"),
+       headers: [{"content-type", "application/xrd+xml"}]
+     }}
+  end
+
+  def get("https://lm.kazv.moe/users/mewmew", _, _, _) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/tesla_mock/mewmew@lm.kazv.moe.json"),
+       headers: activitypub_object_headers()
+     }}
+  end
+
+  def get("https://lm.kazv.moe/users/mewmew/collections/featured", _, _, _) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body:
+         File.read!("test/fixtures/users_mock/masto_featured.json")
+         |> String.replace("{{domain}}", "lm.kazv.moe")
+         |> String.replace("{{nickname}}", "mewmew"),
+       headers: [{"content-type", "application/activity+json"}]
+     }}
+  end
+
   def get("https://info.pleroma.site/activity.json", _, _, [
         {"accept", "application/activity+json"}
       ]) do
@@ -1313,9 +1373,7 @@ defmodule HttpRequestMock do
 
   def get(url, query, body, headers) do
     {:error,
-     "Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{
-       inspect(headers)
-     }"}
+     "Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{inspect(headers)}"}
   end
 
   # POST Requests
@@ -1381,9 +1439,7 @@ defmodule HttpRequestMock do
 
   def post(url, query, body, headers) do
     {:error,
-     "Mock response not implemented for POST #{inspect(url)}, #{query}, #{inspect(body)}, #{
-       inspect(headers)
-     }"}
+     "Mock response not implemented for POST #{inspect(url)}, #{query}, #{inspect(body)}, #{inspect(headers)}"}
   end
 
   # Most of the rich media mocks are missing HEAD requests, so we just return 404.
@@ -1398,8 +1454,6 @@ defmodule HttpRequestMock do
 
   def head(url, query, body, headers) do
     {:error,
-     "Mock response not implemented for HEAD #{inspect(url)}, #{query}, #{inspect(body)}, #{
-       inspect(headers)
-     }"}
+     "Mock response not implemented for HEAD #{inspect(url)}, #{query}, #{inspect(body)}, #{inspect(headers)}"}
   end
 end