tests: add a test to verify the general fake direction protection works in all cases
[akkoma] / test / support / httpoison_mock.ex
index 4a5a9ea856a44041813c56f7f347a50fc182e891..0be09b6ce56b9ad403d2e56a7642a1312995c038 100644 (file)
@@ -3,8 +3,97 @@ defmodule HTTPoisonMock do
 
   def get(url, body \\ [], headers \\ [])
 
+  def get("https://prismo.news/@mxb", _, _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/https___prismo.news__mxb.json")
+     }}
+  end
+
+  def get("https://osada.macgirvin.com/channel/mike", _, _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body:
+         File.read!("test/fixtures/httpoison_mock/https___osada.macgirvin.com_channel_mike.json")
+     }}
+  end
+
+  def get(
+        "https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com",
+        _,
+        _
+      ) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/mike@osada.macgirvin.com.json")
+     }}
+  end
+
+  def get("https://info.pleroma.site/activity.json", _, _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/https__info.pleroma.site_activity.json")
+     }}
+  end
+
+  def get("https://info.pleroma.site/activity2.json", _, _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/https__info.pleroma.site_activity2.json")
+     }}
+  end
+
+  def get("https://info.pleroma.site/activity3.json", _, _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/https__info.pleroma.site_activity3.json")
+     }}
+  end
+
+  def get("https://info.pleroma.site/activity4.json", _, _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/https__info.pleroma.site_activity4.json")
+     }}
+  end
+
+  def get("https://info.pleroma.site/actor.json", _, _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/https___info.pleroma.site_actor.json")
+     }}
+  end
+
+  def get("https://puckipedia.com/", [Accept: "application/activity+json"], _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/puckipedia.com.json")
+     }}
+  end
+
+  def get(
+        "https://gerzilla.de/.well-known/webfinger?resource=acct:kaniini@gerzilla.de",
+        [Accept: "application/xrd+xml,application/jrd+json"],
+        follow_redirect: true
+      ) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/kaniini@gerzilla.de.json")
+     }}
+  end
+
   def get(
-        "http://framatube.org/.well-known/webfinger?resource=acct:framasoft@framatube.org",
+        "https://framatube.org/.well-known/webfinger?resource=acct:framasoft@framatube.org",
         [Accept: "application/xrd+xml,application/jrd+json"],
         follow_redirect: true
       ) do
@@ -16,7 +105,7 @@ defmodule HTTPoisonMock do
   end
 
   def get(
-        "http://gnusocial.de/.well-known/webfinger?resource=acct:winterdienst@gnusocial.de",
+        "https://gnusocial.de/.well-known/webfinger?resource=acct:winterdienst@gnusocial.de",
         [Accept: "application/xrd+xml,application/jrd+json"],
         follow_redirect: true
       ) do
@@ -376,6 +465,17 @@ defmodule HTTPoisonMock do
      }}
   end
 
+  def get("http://mastodon.example.org/users/admin/statuses/100787282858396771", _, _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body:
+         File.read!(
+           "test/fixtures/httpoison_mock/http___mastodon.example.org_users_admin_status_1234.json"
+         )
+     }}
+  end
+
   def get(
         "https://pawoo.net/.well-known/webfinger",
         [Accept: "application/xrd+xml,application/jrd+json"],
@@ -519,6 +619,14 @@ defmodule HTTPoisonMock do
      }}
   end
 
+  def get("http://status.alpicola.com/.well-known/host-meta", [], follow_redirect: true) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/status.alpicola.com_host_meta")
+     }}
+  end
+
   def get("http://macgirvin.com/.well-known/host-meta", [], follow_redirect: true) do
     {:ok,
      %Response{
@@ -628,6 +736,18 @@ defmodule HTTPoisonMock do
      }}
   end
 
+  def get(
+        "https://hubzilla.example.org/channel/kaniini",
+        [Accept: "application/activity+json"],
+        _
+      ) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/kaniini@hubzilla.example.org.json")
+     }}
+  end
+
   def get("https://masto.quad.moe/users/_HellPie", [Accept: "application/activity+json"], _) do
     {:ok,
      %Response{
@@ -644,6 +764,14 @@ defmodule HTTPoisonMock do
      }}
   end
 
+  def get("https://n1u.moe/users/rye", [Accept: "application/activity+json"], _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/rye.json")
+     }}
+  end
+
   def get(
         "https://mst3k.interlinked.me/users/luciferMysticus",
         [Accept: "application/activity+json"],
@@ -704,6 +832,38 @@ defmodule HTTPoisonMock do
      }}
   end
 
+  def get("https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/", _, _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/baptiste.gelex.xyz-article.json")
+     }}
+  end
+
+  def get("https://baptiste.gelez.xyz/@/BaptisteGelez", _, _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/baptiste.gelex.xyz-user.json")
+     }}
+  end
+
+  def get("https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3", _, _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/peertube.moe-vid.json")
+     }}
+  end
+
+  def get("https://peertube.moe/accounts/7even", _, _) do
+    {:ok,
+     %Response{
+       status_code: 200,
+       body: File.read!("test/fixtures/httpoison_mock/7even.json")
+     }}
+  end
+
   def get(url, body, headers) do
     {:error,
      "Not implemented the mock response for get #{inspect(url)}, #{inspect(body)}, #{