X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fsupport%2Fhttp_request_mock.ex;h=e4279e14d5377477dd4e6357aab4097fcc003b74;hb=ede3fd7459c437af19a736622e09d68d4b7acf61;hp=80b84d59137de7b369bc4176bb76aa0e98b989c1;hpb=a9e4a975866c33553c477667c431187590329447;p=akkoma diff --git a/test/support/http_request_mock.ex b/test/support/http_request_mock.ex index 80b84d591..e4279e14d 100644 --- a/test/support/http_request_mock.ex +++ b/test/support/http_request_mock.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# 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 @@ -22,8 +26,35 @@ defmodule HttpRequestMock do # GET Requests # def get(url, query \\ [], body \\ [], headers \\ []) - def get("https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/29191", - _, _, [Accept: "application/xrd+xml,application/jrd+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, @@ -39,8 +70,12 @@ defmodule HttpRequestMock do }} end - def get("https://pawoo.net/.well-known/webfinger?resource=acct:https://pawoo.net/users/pekorino", - _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do + 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, @@ -48,7 +83,12 @@ defmodule HttpRequestMock do }} end - def get("https://social.stopwatchingus-heidelberg.de/api/statuses/user_timeline/18330.atom", _, _, _) do + def get( + "https://social.stopwatchingus-heidelberg.de/api/statuses/user_timeline/18330.atom", + _, + _, + _ + ) do {:ok, %Tesla.Env{ status: 200, @@ -56,8 +96,12 @@ defmodule HttpRequestMock do }} 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 + 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, @@ -73,8 +117,12 @@ defmodule HttpRequestMock do }} end - def get("https://mamot.fr/.well-known/webfinger?resource=acct:https://mamot.fr/users/Skruyb", - _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do + 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, @@ -82,7 +130,12 @@ defmodule HttpRequestMock do }} end - def get("https://social.heldscal.la/.well-known/webfinger?resource=nonexistant@social.heldscal.la", _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do + 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, @@ -90,14 +143,6 @@ defmodule HttpRequestMock do }} end - def get("http://gs.example.org:4040/index.php/user/1", _, _, Accept: "application/activity+json") do - {:ok, - %Tesla.Env{ - status: 200, - body: "{\"id\": 1}" - }} - end - def get("https://squeet.me/xrd/?uri=lain@squeet.me", _, _, Accept: "application/xrd+xml,application/jrd+json" ) do