aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-05-05 14:16:54 +0200
committerRoger Braun <roger@rogerbraun.net>2017-05-05 14:16:54 +0200
commitd982f04a652ee95110ebd7d6dfc1ebdaa3c15d6f (patch)
tree201b126e7e33bdab789e3f8d758becc63f2b01db /lib
parent7269c51f3a4409110bc61faada08e35ce1b4d030 (diff)
downloadpleroma-d982f04a652ee95110ebd7d6dfc1ebdaa3c15d6f.tar.gz
Mock HTTPoison in testing.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/ostatus/ostatus.ex4
-rw-r--r--lib/pleroma/web/salmon/salmon.ex4
-rw-r--r--lib/pleroma/web/web_finger/web_finger.ex3
-rw-r--r--lib/pleroma/web/websub/websub.ex10
4 files changed, 12 insertions, 9 deletions
diff --git a/lib/pleroma/web/ostatus/ostatus.ex b/lib/pleroma/web/ostatus/ostatus.ex
index 57fa3bcd5..3bed5a5d9 100644
--- a/lib/pleroma/web/ostatus/ostatus.ex
+++ b/lib/pleroma/web/ostatus/ostatus.ex
@@ -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
diff --git a/lib/pleroma/web/salmon/salmon.ex b/lib/pleroma/web/salmon/salmon.ex
index 3a8c30778..b95ad48ad 100644
--- a/lib/pleroma/web/salmon/salmon.ex
+++ b/lib/pleroma/web/salmon/salmon.ex
@@ -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
diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex
index 2da111035..e8b738c96 100644
--- a/lib/pleroma/web/web_finger/web_finger.ex
+++ b/lib/pleroma/web/web_finger/web_finger.ex
@@ -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 ->
diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex
index 848aac615..7bdb778ad 100644
--- a/lib/pleroma/web/websub/websub.ex
+++ b/lib/pleroma/web/websub/websub.ex
@@ -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,