Merge branch 'develop' into feature/1893-remote-emoji-packs-pagination
This commit is contained in:
commit
346cc3ac24
54 changed files with 908 additions and 187 deletions
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Pleroma.Config.DeprecationWarningsTest do
|
||||
use ExUnit.Case, async: true
|
||||
use ExUnit.Case
|
||||
use Pleroma.Tests.Helpers
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
|
|
@ -66,6 +66,30 @@ defmodule Pleroma.Config.DeprecationWarningsTest do
|
|||
end) =~ "Your config is using old format (only domain) for MediaProxy whitelist option"
|
||||
end
|
||||
|
||||
test "check_welcome_message_config/0" do
|
||||
clear_config([:instance, :welcome_user_nickname], "LainChan")
|
||||
|
||||
assert capture_log(fn ->
|
||||
DeprecationWarnings.check_welcome_message_config()
|
||||
end) =~ "Your config is using the old namespace for Welcome messages configuration."
|
||||
end
|
||||
|
||||
test "check_hellthread_threshold/0" do
|
||||
clear_config([:mrf_hellthread, :threshold], 16)
|
||||
|
||||
assert capture_log(fn ->
|
||||
DeprecationWarnings.check_hellthread_threshold()
|
||||
end) =~ "You are using the old configuration mechanism for the hellthread filter."
|
||||
end
|
||||
|
||||
test "check_activity_expiration_config/0" do
|
||||
clear_config([Pleroma.ActivityExpiration, :enabled], true)
|
||||
|
||||
assert capture_log(fn ->
|
||||
DeprecationWarnings.check_activity_expiration_config()
|
||||
end) =~ "Your config is using old namespace for activity expiration configuration."
|
||||
end
|
||||
|
||||
describe "check_gun_pool_options/0" do
|
||||
test "await_up_timeout" do
|
||||
config = Config.get(:connections_pool)
|
||||
|
|
@ -74,7 +98,7 @@ defmodule Pleroma.Config.DeprecationWarningsTest do
|
|||
assert capture_log(fn ->
|
||||
DeprecationWarnings.check_gun_pool_options()
|
||||
end) =~
|
||||
"Your config is using old setting name `await_up_timeout` instead of `connect_timeout`"
|
||||
"Your config is using old setting `config :pleroma, :connections_pool, await_up_timeout`."
|
||||
end
|
||||
|
||||
test "pool timeout" do
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.WebPushHttpClientMock do
|
||||
def get(url, headers \\ [], options \\ []) do
|
||||
{
|
||||
res,
|
||||
%Tesla.Env{status: status}
|
||||
} = Pleroma.HTTP.request(:get, url, "", headers, options)
|
||||
|
||||
{res, %{status_code: status}}
|
||||
end
|
||||
|
||||
def post(url, body, headers \\ [], options \\ []) do
|
||||
{
|
||||
res,
|
||||
%Tesla.Env{status: status}
|
||||
} = Pleroma.HTTP.request(:post, url, body, headers, options)
|
||||
|
||||
{res, %{status_code: status}}
|
||||
end
|
||||
end
|
||||
|
|
@ -6,6 +6,8 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
|
|||
alias Pleroma.Config
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
setup_all do
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
|
|
@ -17,6 +19,7 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
|
|||
end
|
||||
|
||||
setup do: clear_config([Pleroma.Emails.Mailer, :enabled], true)
|
||||
setup do: clear_config([:instance, :account_activation_required], true)
|
||||
|
||||
describe "pleroma.email test" do
|
||||
test "Sends test email with no given address" do
|
||||
|
|
@ -50,5 +53,71 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
|
|||
html_body: ~r/a test email was requested./i
|
||||
)
|
||||
end
|
||||
|
||||
test "Sends confirmation emails" do
|
||||
local_user1 =
|
||||
insert(:user, %{
|
||||
confirmation_pending: true,
|
||||
confirmation_token: "mytoken",
|
||||
deactivated: false,
|
||||
email: "local1@pleroma.com",
|
||||
local: true
|
||||
})
|
||||
|
||||
local_user2 =
|
||||
insert(:user, %{
|
||||
confirmation_pending: true,
|
||||
confirmation_token: "mytoken",
|
||||
deactivated: false,
|
||||
email: "local2@pleroma.com",
|
||||
local: true
|
||||
})
|
||||
|
||||
:ok = Mix.Tasks.Pleroma.Email.run(["resend_confirmation_emails"])
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert_email_sent(to: {local_user1.name, local_user1.email})
|
||||
assert_email_sent(to: {local_user2.name, local_user2.email})
|
||||
end
|
||||
|
||||
test "Does not send confirmation email to inappropriate users" do
|
||||
# confirmed user
|
||||
insert(:user, %{
|
||||
confirmation_pending: false,
|
||||
confirmation_token: "mytoken",
|
||||
deactivated: false,
|
||||
email: "confirmed@pleroma.com",
|
||||
local: true
|
||||
})
|
||||
|
||||
# remote user
|
||||
insert(:user, %{
|
||||
deactivated: false,
|
||||
email: "remote@not-pleroma.com",
|
||||
local: false
|
||||
})
|
||||
|
||||
# deactivated user =
|
||||
insert(:user, %{
|
||||
deactivated: true,
|
||||
email: "deactivated@pleroma.com",
|
||||
local: false
|
||||
})
|
||||
|
||||
# invisible user
|
||||
insert(:user, %{
|
||||
deactivated: false,
|
||||
email: "invisible@pleroma.com",
|
||||
local: true,
|
||||
invisible: true
|
||||
})
|
||||
|
||||
:ok = Mix.Tasks.Pleroma.Email.run(["resend_confirmation_emails"])
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
refute_email_sent()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -81,6 +81,80 @@ defmodule Mix.Tasks.Pleroma.RelayTest do
|
|||
assert undo_activity.data["object"]["id"] == cancelled_activity.data["id"]
|
||||
refute "#{target_instance}/followers" in User.following(local_user)
|
||||
end
|
||||
|
||||
test "unfollow when relay is dead" do
|
||||
user = insert(:user)
|
||||
target_instance = user.ap_id
|
||||
|
||||
Mix.Tasks.Pleroma.Relay.run(["follow", target_instance])
|
||||
|
||||
%User{ap_id: follower_id} = local_user = Relay.get_actor()
|
||||
target_user = User.get_cached_by_ap_id(target_instance)
|
||||
follow_activity = Utils.fetch_latest_follow(local_user, target_user)
|
||||
User.follow(local_user, target_user)
|
||||
|
||||
assert "#{target_instance}/followers" in User.following(local_user)
|
||||
|
||||
Tesla.Mock.mock(fn %{method: :get, url: ^target_instance} ->
|
||||
%Tesla.Env{status: 404}
|
||||
end)
|
||||
|
||||
Pleroma.Repo.delete(user)
|
||||
Cachex.clear(:user_cache)
|
||||
|
||||
Mix.Tasks.Pleroma.Relay.run(["unfollow", target_instance])
|
||||
|
||||
cancelled_activity = Activity.get_by_ap_id(follow_activity.data["id"])
|
||||
assert cancelled_activity.data["state"] == "accept"
|
||||
|
||||
assert [] ==
|
||||
ActivityPub.fetch_activities(
|
||||
[],
|
||||
%{
|
||||
type: "Undo",
|
||||
actor_id: follower_id,
|
||||
skip_preload: true,
|
||||
invisible_actors: true
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
test "force unfollow when relay is dead" do
|
||||
user = insert(:user)
|
||||
target_instance = user.ap_id
|
||||
|
||||
Mix.Tasks.Pleroma.Relay.run(["follow", target_instance])
|
||||
|
||||
%User{ap_id: follower_id} = local_user = Relay.get_actor()
|
||||
target_user = User.get_cached_by_ap_id(target_instance)
|
||||
follow_activity = Utils.fetch_latest_follow(local_user, target_user)
|
||||
User.follow(local_user, target_user)
|
||||
|
||||
assert "#{target_instance}/followers" in User.following(local_user)
|
||||
|
||||
Tesla.Mock.mock(fn %{method: :get, url: ^target_instance} ->
|
||||
%Tesla.Env{status: 404}
|
||||
end)
|
||||
|
||||
Pleroma.Repo.delete(user)
|
||||
Cachex.clear(:user_cache)
|
||||
|
||||
Mix.Tasks.Pleroma.Relay.run(["unfollow", target_instance, "--force"])
|
||||
|
||||
cancelled_activity = Activity.get_by_ap_id(follow_activity.data["id"])
|
||||
assert cancelled_activity.data["state"] == "cancelled"
|
||||
|
||||
[undo_activity] =
|
||||
ActivityPub.fetch_activities(
|
||||
[],
|
||||
%{type: "Undo", actor_id: follower_id, skip_preload: true, invisible_actors: true}
|
||||
)
|
||||
|
||||
assert undo_activity.data["type"] == "Undo"
|
||||
assert undo_activity.data["actor"] == local_user.ap_id
|
||||
assert undo_activity.data["object"]["id"] == cancelled_activity.data["id"]
|
||||
refute "#{target_instance}/followers" in User.following(local_user)
|
||||
end
|
||||
end
|
||||
|
||||
describe "mix pleroma.relay list" do
|
||||
|
|
|
|||
|
|
@ -225,47 +225,64 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
test "All statuses set" do
|
||||
user = insert(:user)
|
||||
|
||||
Mix.Tasks.Pleroma.User.run(["set", user.nickname, "--moderator", "--admin", "--locked"])
|
||||
Mix.Tasks.Pleroma.User.run([
|
||||
"set",
|
||||
user.nickname,
|
||||
"--admin",
|
||||
"--confirmed",
|
||||
"--locked",
|
||||
"--moderator"
|
||||
])
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Moderator status .* true/
|
||||
assert message =~ ~r/Admin status .* true/
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Confirmation pending .* false/
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Locked status .* true/
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Admin status .* true/
|
||||
assert message =~ ~r/Moderator status .* true/
|
||||
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
assert user.is_moderator
|
||||
assert user.locked
|
||||
assert user.is_admin
|
||||
refute user.confirmation_pending
|
||||
end
|
||||
|
||||
test "All statuses unset" do
|
||||
user = insert(:user, locked: true, is_moderator: true, is_admin: true)
|
||||
user =
|
||||
insert(:user, locked: true, is_moderator: true, is_admin: true, confirmation_pending: true)
|
||||
|
||||
Mix.Tasks.Pleroma.User.run([
|
||||
"set",
|
||||
user.nickname,
|
||||
"--no-moderator",
|
||||
"--no-admin",
|
||||
"--no-locked"
|
||||
"--no-confirmed",
|
||||
"--no-locked",
|
||||
"--no-moderator"
|
||||
])
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Moderator status .* false/
|
||||
assert message =~ ~r/Admin status .* false/
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Confirmation pending .* true/
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Locked status .* false/
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Admin status .* false/
|
||||
assert message =~ ~r/Moderator status .* false/
|
||||
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
refute user.is_moderator
|
||||
refute user.locked
|
||||
refute user.is_admin
|
||||
assert user.confirmation_pending
|
||||
end
|
||||
|
||||
test "no user to set status" do
|
||||
|
|
@ -554,4 +571,44 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
assert message =~ "Could not change user tags"
|
||||
end
|
||||
end
|
||||
|
||||
describe "bulk confirm and unconfirm" do
|
||||
test "confirm all" do
|
||||
user1 = insert(:user, confirmation_pending: true)
|
||||
user2 = insert(:user, confirmation_pending: true)
|
||||
|
||||
assert user1.confirmation_pending
|
||||
assert user2.confirmation_pending
|
||||
|
||||
Mix.Tasks.Pleroma.User.run(["confirm_all"])
|
||||
|
||||
user1 = User.get_cached_by_nickname(user1.nickname)
|
||||
user2 = User.get_cached_by_nickname(user2.nickname)
|
||||
|
||||
refute user1.confirmation_pending
|
||||
refute user2.confirmation_pending
|
||||
end
|
||||
|
||||
test "unconfirm all" do
|
||||
user1 = insert(:user, confirmation_pending: false)
|
||||
user2 = insert(:user, confirmation_pending: false)
|
||||
admin = insert(:user, is_admin: true, confirmation_pending: false)
|
||||
mod = insert(:user, is_moderator: true, confirmation_pending: false)
|
||||
|
||||
refute user1.confirmation_pending
|
||||
refute user2.confirmation_pending
|
||||
|
||||
Mix.Tasks.Pleroma.User.run(["unconfirm_all"])
|
||||
|
||||
user1 = User.get_cached_by_nickname(user1.nickname)
|
||||
user2 = User.get_cached_by_nickname(user2.nickname)
|
||||
admin = User.get_cached_by_nickname(admin.nickname)
|
||||
mod = User.get_cached_by_nickname(mod.nickname)
|
||||
|
||||
assert user1.confirmation_pending
|
||||
assert user2.confirmation_pending
|
||||
refute admin.confirmation_pending
|
||||
refute mod.confirmation_pending
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,6 +17,46 @@ defmodule Pleroma.UserSearchTest do
|
|||
describe "User.search" do
|
||||
setup do: clear_config([:instance, :limit_to_local_content])
|
||||
|
||||
test "returns a resolved user as the first result" do
|
||||
Pleroma.Config.put([:instance, :limit_to_local_content], false)
|
||||
user = insert(:user, %{nickname: "no_relation", ap_id: "https://lain.com/users/lain"})
|
||||
_user = insert(:user, %{nickname: "com_user"})
|
||||
|
||||
[first_user, _second_user] = User.search("https://lain.com/users/lain", resolve: true)
|
||||
|
||||
assert first_user.id == user.id
|
||||
end
|
||||
|
||||
test "returns a user with matching ap_id as the first result" do
|
||||
user = insert(:user, %{nickname: "no_relation", ap_id: "https://lain.com/users/lain"})
|
||||
_user = insert(:user, %{nickname: "com_user"})
|
||||
|
||||
[first_user, _second_user] = User.search("https://lain.com/users/lain")
|
||||
|
||||
assert first_user.id == user.id
|
||||
end
|
||||
|
||||
test "doesn't die if two users have the same uri" do
|
||||
insert(:user, %{uri: "https://gensokyo.2hu/@raymoo"})
|
||||
insert(:user, %{uri: "https://gensokyo.2hu/@raymoo"})
|
||||
assert [_first_user, _second_user] = User.search("https://gensokyo.2hu/@raymoo")
|
||||
end
|
||||
|
||||
test "returns a user with matching uri as the first result" do
|
||||
user =
|
||||
insert(:user, %{
|
||||
nickname: "no_relation",
|
||||
ap_id: "https://lain.com/users/lain",
|
||||
uri: "https://lain.com/@lain"
|
||||
})
|
||||
|
||||
_user = insert(:user, %{nickname: "com_user"})
|
||||
|
||||
[first_user, _second_user] = User.search("https://lain.com/@lain")
|
||||
|
||||
assert first_user.id == user.id
|
||||
end
|
||||
|
||||
test "excludes invisible users from results" do
|
||||
user = insert(:user, %{nickname: "john t1000"})
|
||||
insert(:user, %{invisible: true, nickname: "john t800"})
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ defmodule Pleroma.Web.ActivityPub.MRFTest do
|
|||
|
||||
describe "describe/0" do
|
||||
test "it works as expected with noop policy" do
|
||||
clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.NoOpPolicy])
|
||||
|
||||
expected = %{
|
||||
mrf_policies: ["NoOpPolicy"],
|
||||
exclusions: false
|
||||
|
|
|
|||
|
|
@ -63,6 +63,46 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do
|
|||
assert activity.data["to"] == [user.ap_id]
|
||||
refute "#{user.ap_id}/followers" in User.following(service_actor)
|
||||
end
|
||||
|
||||
test "force unfollow when target service is dead" do
|
||||
user = insert(:user)
|
||||
user_ap_id = user.ap_id
|
||||
user_id = user.id
|
||||
|
||||
Tesla.Mock.mock(fn %{method: :get, url: ^user_ap_id} ->
|
||||
%Tesla.Env{status: 404}
|
||||
end)
|
||||
|
||||
service_actor = Relay.get_actor()
|
||||
CommonAPI.follow(service_actor, user)
|
||||
assert "#{user.ap_id}/followers" in User.following(service_actor)
|
||||
|
||||
assert Pleroma.Repo.get_by(
|
||||
Pleroma.FollowingRelationship,
|
||||
follower_id: service_actor.id,
|
||||
following_id: user_id
|
||||
)
|
||||
|
||||
Pleroma.Repo.delete(user)
|
||||
Cachex.clear(:user_cache)
|
||||
|
||||
assert {:ok, %Activity{} = activity} = Relay.unfollow(user_ap_id, %{force: true})
|
||||
|
||||
assert refresh_record(service_actor).following_count == 0
|
||||
|
||||
refute Pleroma.Repo.get_by(
|
||||
Pleroma.FollowingRelationship,
|
||||
follower_id: service_actor.id,
|
||||
following_id: user_id
|
||||
)
|
||||
|
||||
assert activity.actor == "#{Pleroma.Web.Endpoint.url()}/relay"
|
||||
assert user.ap_id in activity.recipients
|
||||
assert activity.data["type"] == "Undo"
|
||||
assert activity.data["actor"] == service_actor.ap_id
|
||||
assert activity.data["to"] == [user_ap_id]
|
||||
refute "#{user.ap_id}/followers" in User.following(service_actor)
|
||||
end
|
||||
end
|
||||
|
||||
describe "publish/1" do
|
||||
|
|
|
|||
|
|
@ -157,12 +157,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
|
|||
}
|
||||
end
|
||||
|
||||
test "returns an error if received a second time" do
|
||||
test "returns same activity if received a second time" do
|
||||
data = File.read!("test/fixtures/mastodon-question-activity.json") |> Poison.decode!()
|
||||
|
||||
assert {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
assert {:error, {:validate_object, {:error, _}}} = Transmogrifier.handle_incoming(data)
|
||||
assert {:ok, ^activity} = Transmogrifier.handle_incoming(data)
|
||||
end
|
||||
|
||||
test "accepts a Question with no content" do
|
||||
|
|
|
|||
|
|
@ -29,6 +29,23 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
setup do: clear_config([:instance, :limit])
|
||||
setup do: clear_config([:instance, :max_pinned_statuses])
|
||||
|
||||
describe "posting polls" do
|
||||
test "it posts a poll" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
status: "who is the best",
|
||||
poll: %{expires_in: 600, options: ["reimu", "marisa"]}
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
||||
assert object.data["type"] == "Question"
|
||||
assert object.data["oneOf"] |> length() == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "blocking" do
|
||||
setup do
|
||||
blocker = insert(:user)
|
||||
|
|
|
|||
|
|
@ -81,6 +81,15 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyControllerTest do
|
|||
end
|
||||
|
||||
describe "Media Preview Proxy" do
|
||||
def assert_dependencies_installed do
|
||||
missing_dependencies = Pleroma.Helpers.MediaHelper.missing_dependencies()
|
||||
|
||||
assert missing_dependencies == [],
|
||||
"Error: missing dependencies (please refer to `docs/installation`): #{
|
||||
inspect(missing_dependencies)
|
||||
}"
|
||||
end
|
||||
|
||||
setup do
|
||||
clear_config([:media_proxy, :enabled], true)
|
||||
clear_config([:media_preview_proxy, :enabled], true)
|
||||
|
|
@ -184,6 +193,8 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyControllerTest do
|
|||
url: url,
|
||||
media_proxy_url: media_proxy_url
|
||||
} do
|
||||
assert_dependencies_installed()
|
||||
|
||||
# Setting a high :min_content_length to ensure this scenario is not affected by its logic
|
||||
clear_config([:media_preview_proxy, :min_content_length], 1_000_000_000)
|
||||
|
||||
|
|
@ -270,6 +281,8 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyControllerTest do
|
|||
url: url,
|
||||
media_proxy_url: media_proxy_url
|
||||
} do
|
||||
assert_dependencies_installed()
|
||||
|
||||
Tesla.Mock.mock(fn
|
||||
%{method: "head", url: ^media_proxy_url} ->
|
||||
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/png"}]}
|
||||
|
|
@ -290,6 +303,8 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyControllerTest do
|
|||
url: url,
|
||||
media_proxy_url: media_proxy_url
|
||||
} do
|
||||
assert_dependencies_installed()
|
||||
|
||||
Tesla.Mock.mock(fn
|
||||
%{method: "head", url: ^media_proxy_url} ->
|
||||
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/jpeg"}]}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
defmodule Pleroma.Web.Push.ImplTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
alias Pleroma.Notification
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.User
|
||||
|
|
@ -12,10 +14,6 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.Push.Impl
|
||||
alias Pleroma.Web.Push.Subscription
|
||||
alias Pleroma.Web.WebPushHttpClientMock
|
||||
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
|
||||
setup do
|
||||
Tesla.Mock.mock(fn
|
||||
|
|
@ -80,22 +78,6 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
assert Impl.push_message(@message, @sub, @api_key, %Subscription{}) == :ok
|
||||
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
|
||||
test "fail message sending" do
|
||||
assert Impl.push_message(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue