Mock HTTPoison in testing.
This commit is contained in:
parent
7269c51f3a
commit
d982f04a65
19 changed files with 2527 additions and 9 deletions
|
|
@ -45,10 +45,10 @@ defmodule Pleroma.Web.OStatus do
|
|||
{:ok, activities}
|
||||
end
|
||||
|
||||
def make_share(entry, doc, retweeted_activity) do
|
||||
def make_share(_entry, doc, retweeted_activity) do
|
||||
with {:ok, actor} <- find_make_or_update_user(doc),
|
||||
%Object{} = object <- Object.get_cached_by_ap_id(retweeted_activity.data["object"]["id"]),
|
||||
{:ok, activity, object} = ActivityPub.announce(actor, object, false) do
|
||||
{:ok, activity, _object} = ActivityPub.announce(actor, object, false) do
|
||||
{:ok, activity}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
defmodule Pleroma.Web.Salmon do
|
||||
@httpoison Application.get_env(:pleroma, :httpoison)
|
||||
|
||||
use Bitwise
|
||||
alias Pleroma.Web.XML
|
||||
alias Pleroma.Web.OStatus.ActivityRepresenter
|
||||
|
|
@ -135,7 +137,7 @@ defmodule Pleroma.Web.Salmon do
|
|||
|
||||
defp send_to_user(_,_,_), do: nil
|
||||
|
||||
def publish(user, activity, poster \\ &HTTPoison.post/3)
|
||||
def publish(user, activity, poster \\ &@httpoison.post/3)
|
||||
def publish(%{info: %{"keys" => keys}} = user, activity, poster) do
|
||||
feed = ActivityRepresenter.to_simple_form(activity, user, true)
|
||||
|> ActivityRepresenter.wrap_with_entry
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
defmodule Pleroma.Web.WebFinger do
|
||||
@httpoison Application.get_env(:pleroma, :httpoison)
|
||||
|
||||
alias Pleroma.{Repo, User, XmlBuilder}
|
||||
alias Pleroma.Web
|
||||
|
|
@ -81,7 +82,7 @@ defmodule Pleroma.Web.WebFinger do
|
|||
{:ok, data}
|
||||
end
|
||||
|
||||
def finger(account, getter \\ &HTTPoison.get/3) do
|
||||
def finger(account, getter \\ &@httpoison.get/3) do
|
||||
domain = with [_name, domain] <- String.split(account, "@") do
|
||||
domain
|
||||
else _e ->
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ defmodule Pleroma.Web.Websub do
|
|||
|
||||
import Ecto.Query
|
||||
|
||||
@websub_verifier Application.get_env(:pleroma, :websub_verifier)
|
||||
@httpoison Application.get_env(:pleroma, :httpoison)
|
||||
|
||||
def verify(subscription, getter \\ &HTTPoison.get/3) do
|
||||
def verify(subscription, getter \\ &@httpoison.get/3) do
|
||||
challenge = Base.encode16(:crypto.strong_rand_bytes(8))
|
||||
lease_seconds = NaiveDateTime.diff(subscription.valid_until, subscription.updated_at)
|
||||
lease_seconds = lease_seconds |> to_string
|
||||
|
|
@ -51,7 +51,7 @@ defmodule Pleroma.Web.Websub do
|
|||
signature = sign(sub.secret || "", response)
|
||||
Logger.debug(fn -> "Pushing to #{sub.callback}" end)
|
||||
|
||||
HTTPoison.post(sub.callback, response, [
|
||||
@httpoison.post(sub.callback, response, [
|
||||
{"Content-Type", "application/atom+xml"},
|
||||
{"X-Hub-Signature", "sha1=#{signature}"}
|
||||
])
|
||||
|
|
@ -141,7 +141,7 @@ defmodule Pleroma.Web.Websub do
|
|||
requester.(subscription)
|
||||
end
|
||||
|
||||
def gather_feed_data(topic, getter \\ &HTTPoison.get/1) do
|
||||
def gather_feed_data(topic, getter \\ &@httpoison.get/1) do
|
||||
with {:ok, response} <- getter.(topic),
|
||||
status_code when status_code in 200..299 <- response.status_code,
|
||||
body <- response.body,
|
||||
|
|
@ -167,7 +167,7 @@ defmodule Pleroma.Web.Websub do
|
|||
end
|
||||
end
|
||||
|
||||
def request_subscription(websub, poster \\ &HTTPoison.post/3, timeout \\ 10_000) do
|
||||
def request_subscription(websub, poster \\ &@httpoison.post/3, timeout \\ 10_000) do
|
||||
data = [
|
||||
"hub.mode": "subscribe",
|
||||
"hub.topic": websub.topic,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue