forked from AkkomaGang/akkoma
Testing: Don't federate in testing.
This commit is contained in:
parent
3589b30ddc
commit
abe2e8881f
9 changed files with 70 additions and 10 deletions
|
@ -28,7 +28,8 @@
|
||||||
config :pleroma, :instance,
|
config :pleroma, :instance,
|
||||||
email: "admin@example.com",
|
email: "admin@example.com",
|
||||||
notify_email: "noreply@example.com",
|
notify_email: "noreply@example.com",
|
||||||
skip_thread_containment: false
|
skip_thread_containment: false,
|
||||||
|
federating: false
|
||||||
|
|
||||||
# Configure your database
|
# Configure your database
|
||||||
config :pleroma, Pleroma.Repo,
|
config :pleroma, Pleroma.Repo,
|
||||||
|
|
|
@ -170,14 +170,17 @@ def create_context(context) do
|
||||||
Enqueues an activity for federation if it's local
|
Enqueues an activity for federation if it's local
|
||||||
"""
|
"""
|
||||||
def maybe_federate(%Activity{local: true} = activity) do
|
def maybe_federate(%Activity{local: true} = activity) do
|
||||||
priority =
|
if Pleroma.Config.get!([:instance, :federating]) do
|
||||||
case activity.data["type"] do
|
priority =
|
||||||
"Delete" -> 10
|
case activity.data["type"] do
|
||||||
"Create" -> 1
|
"Delete" -> 10
|
||||||
_ -> 5
|
"Create" -> 1
|
||||||
end
|
_ -> 5
|
||||||
|
end
|
||||||
|
|
||||||
|
Pleroma.Web.Federator.publish(activity, priority)
|
||||||
|
end
|
||||||
|
|
||||||
Pleroma.Web.Federator.publish(activity, priority)
|
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,16 @@ defmodule Pleroma.ConversationTest do
|
||||||
|
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
|
setup_all do
|
||||||
|
config_path = [:instance, :federating]
|
||||||
|
initial_setting = Pleroma.Config.get(config_path)
|
||||||
|
|
||||||
|
Pleroma.Config.put(config_path, true)
|
||||||
|
on_exit(fn -> Pleroma.Config.put(config_path, initial_setting) end)
|
||||||
|
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
|
||||||
test "it goes through old direct conversations" do
|
test "it goes through old direct conversations" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
|
|
|
@ -15,6 +15,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
||||||
|
|
||||||
setup_all do
|
setup_all do
|
||||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
|
|
||||||
|
config_path = [:instance, :federating]
|
||||||
|
initial_setting = Pleroma.Config.get(config_path)
|
||||||
|
|
||||||
|
Pleroma.Config.put(config_path, true)
|
||||||
|
on_exit(fn -> Pleroma.Config.put(config_path, initial_setting) end)
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,13 @@ defmodule Pleroma.Web.FederatorTest do
|
||||||
|
|
||||||
setup_all do
|
setup_all do
|
||||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
|
|
||||||
|
config_path = [:instance, :federating]
|
||||||
|
initial_setting = Pleroma.Config.get(config_path)
|
||||||
|
|
||||||
|
Pleroma.Config.put(config_path, true)
|
||||||
|
on_exit(fn -> Pleroma.Config.put(config_path, initial_setting) end)
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,13 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
||||||
|
|
||||||
setup_all do
|
setup_all do
|
||||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
|
|
||||||
|
config_path = [:instance, :federating]
|
||||||
|
initial_setting = Pleroma.Config.get(config_path)
|
||||||
|
|
||||||
|
Pleroma.Config.put(config_path, true)
|
||||||
|
on_exit(fn -> Pleroma.Config.put(config_path, initial_setting) end)
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,15 @@
|
||||||
defmodule Pleroma.Web.FederatingPlugTest do
|
defmodule Pleroma.Web.FederatingPlugTest do
|
||||||
use Pleroma.Web.ConnCase
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
|
setup_all do
|
||||||
|
config_path = [:instance, :federating]
|
||||||
|
initial_setting = Pleroma.Config.get(config_path)
|
||||||
|
|
||||||
|
on_exit(fn -> Pleroma.Config.put(config_path, initial_setting) end)
|
||||||
|
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
|
||||||
test "returns and halt the conn when federating is disabled" do
|
test "returns and halt the conn when federating is disabled" do
|
||||||
Pleroma.Config.put([:instance, :federating], false)
|
Pleroma.Config.put([:instance, :federating], false)
|
||||||
|
|
||||||
|
@ -14,11 +23,11 @@ test "returns and halt the conn when federating is disabled" do
|
||||||
|
|
||||||
assert conn.status == 404
|
assert conn.status == 404
|
||||||
assert conn.halted
|
assert conn.halted
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :federating], true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "does nothing when federating is enabled" do
|
test "does nothing when federating is enabled" do
|
||||||
|
Pleroma.Config.put([:instance, :federating], true)
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
build_conn()
|
build_conn()
|
||||||
|> Pleroma.Web.FederatingPlug.call(%{})
|
|> Pleroma.Web.FederatingPlug.call(%{})
|
||||||
|
|
|
@ -10,6 +10,12 @@ defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
|
|
||||||
|
config_path = [:instance, :federating]
|
||||||
|
initial_setting = Pleroma.Config.get(config_path)
|
||||||
|
|
||||||
|
Pleroma.Config.put(config_path, true)
|
||||||
|
on_exit(fn -> Pleroma.Config.put(config_path, initial_setting) end)
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,16 @@ defmodule Pleroma.Web.Websub.WebsubControllerTest do
|
||||||
alias Pleroma.Web.Websub
|
alias Pleroma.Web.Websub
|
||||||
alias Pleroma.Web.Websub.WebsubClientSubscription
|
alias Pleroma.Web.Websub.WebsubClientSubscription
|
||||||
|
|
||||||
|
setup_all do
|
||||||
|
config_path = [:instance, :federating]
|
||||||
|
initial_setting = Pleroma.Config.get(config_path)
|
||||||
|
|
||||||
|
Pleroma.Config.put(config_path, true)
|
||||||
|
on_exit(fn -> Pleroma.Config.put(config_path, initial_setting) end)
|
||||||
|
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
|
||||||
test "websub subscription request", %{conn: conn} do
|
test "websub subscription request", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue