Make WebPushEncryption use Pleroma.HTTP as an HTTP adapter
This commit is contained in:
parent
49584a9928
commit
226fa3e486
@ -787,6 +787,8 @@
|
|||||||
|
|
||||||
config :ex_aws, http_client: Pleroma.HTTP.ExAws
|
config :ex_aws, http_client: Pleroma.HTTP.ExAws
|
||||||
|
|
||||||
|
config :web_push_encryption, http_client: Pleroma.HTTP
|
||||||
|
|
||||||
config :pleroma, :instances_favicons, enabled: false
|
config :pleroma, :instances_favicons, enabled: false
|
||||||
|
|
||||||
config :floki, :html_parser, Floki.HTMLParser.FastHtml
|
config :floki, :html_parser, Floki.HTMLParser.FastHtml
|
||||||
|
@ -12,7 +12,9 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||||||
alias Pleroma.Web.CommonAPI
|
alias Pleroma.Web.CommonAPI
|
||||||
alias Pleroma.Web.Push.Impl
|
alias Pleroma.Web.Push.Impl
|
||||||
alias Pleroma.Web.Push.Subscription
|
alias Pleroma.Web.Push.Subscription
|
||||||
|
alias Pleroma.Web.WebPushHttpClientMock
|
||||||
|
|
||||||
|
import Mock
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
@ -78,6 +80,22 @@ test "successful message sending" do
|
|||||||
assert Impl.push_message(@message, @sub, @api_key, %Subscription{}) == :ok
|
assert Impl.push_message(@message, @sub, @api_key, %Subscription{}) == :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test_with_mock "uses WebPushHttpClientMock as an HTTP client", WebPushHttpClientMock,
|
||||||
|
post: fn _, _, _ -> {:ok, %{status_code: 200}} end do
|
||||||
|
Impl.push_message(@message, @sub, @api_key, %Subscription{})
|
||||||
|
assert_called(WebPushHttpClientMock.post("https://example.com/example/1234", :_, :_))
|
||||||
|
end
|
||||||
|
|
||||||
|
test_with_mock "uses Pleroma.HTTP as an HTTP client", Pleroma.HTTP,
|
||||||
|
post: fn _, _, _ -> {:ok, %{status_code: 200}} end do
|
||||||
|
client = Application.get_env(:web_push_encryption, :http_client)
|
||||||
|
on_exit(fn -> Application.put_env(:web_push_encryption, :http_client, client) end)
|
||||||
|
Application.put_env(:web_push_encryption, :http_client, Pleroma.HTTP)
|
||||||
|
|
||||||
|
Impl.push_message(@message, @sub, @api_key, %Subscription{})
|
||||||
|
assert_called(Pleroma.HTTP.post("https://example.com/example/1234", :_, :_))
|
||||||
|
end
|
||||||
|
|
||||||
@tag capture_log: true
|
@tag capture_log: true
|
||||||
test "fail message sending" do
|
test "fail message sending" do
|
||||||
assert Impl.push_message(
|
assert Impl.push_message(
|
||||||
|
Loading…
Reference in New Issue
Block a user