Merge branch 'activitypub-likes' into 'develop'
[akkoma] / test / support / http_request_mock.ex
index f44e9a1c686dc8ba352d8e653a17df1adc0fb486..e4279e14d5377477dd4e6357aab4097fcc003b74 100644 (file)
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
 defmodule HttpRequestMock do
   require Logger
 
@@ -13,8 +17,8 @@ defmodule HttpRequestMock do
     with {:ok, res} <- apply(__MODULE__, method, [url, query, body, headers]) do
       res
     else
-      {_, r} = error ->
-        Logger.warn(r)
+      {_, _r} = error ->
+        Logger.warn(r)
         error
     end
   end
@@ -23,11 +27,119 @@ defmodule HttpRequestMock do
   #
   def get(url, query \\ [], body \\ [], headers \\ [])
 
-  def get("http://gs.example.org:4040/index.php/user/1", _, _, Accept: "application/activity+json") do
+  def get("https://osada.macgirvin.com/channel/mike", _, _, _) do
+    {:ok,
+     %Tesla.Env{
+       status: 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",
+        _,
+        _,
+        Accept: "application/xrd+xml,application/jrd+json"
+      ) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/httpoison_mock/mike@osada.macgirvin.com.json")
+     }}
+  end
+
+  def get(
+        "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/29191",
+        _,
+        _,
+        Accept: "application/xrd+xml,application/jrd+json"
+      ) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_user_29191.xml")
+     }}
+  end
+
+  def get("https://pawoo.net/users/pekorino.atom", _, _, _) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.atom")
+     }}
+  end
+
+  def get(
+        "https://pawoo.net/.well-known/webfinger?resource=acct:https://pawoo.net/users/pekorino",
+        _,
+        _,
+        Accept: "application/xrd+xml,application/jrd+json"
+      ) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.xml")
+     }}
+  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/httpoison_mock/atarifrosch_feed.xml")
+     }}
+  end
+
+  def get(
+        "https://social.stopwatchingus-heidelberg.de/.well-known/webfinger?resource=acct:https://social.stopwatchingus-heidelberg.de/user/18330",
+        _,
+        _,
+        Accept: "application/xrd+xml,application/jrd+json"
+      ) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/httpoison_mock/atarifrosch_webfinger.xml")
+     }}
+  end
+
+  def get("https://mamot.fr/users/Skruyb.atom", _, _, _) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/httpoison_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/httpoison_mock/skruyb@mamot.fr.atom")
+     }}
+  end
+
+  def get(
+        "https://social.heldscal.la/.well-known/webfinger?resource=nonexistant@social.heldscal.la",
+        _,
+        _,
+        Accept: "application/xrd+xml,application/jrd+json"
+      ) do
     {:ok,
      %Tesla.Env{
        status: 200,
-       body: "{\"id\": 1}"
+       body: File.read!("test/fixtures/httpoison_mock/nonexistant@social.heldscal.la.xml")
      }}
   end