projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tests for Uploader with webhook
[akkoma]
/
test
/
web
/
federator_test.exs
diff --git
a/test/web/federator_test.exs
b/test/web/federator_test.exs
index 05f813291bc5f3644789dab5aa472face3496659..69dd4d7473c4df10d78e638bb22537db48f03c0b 100644
(file)
--- a/
test/web/federator_test.exs
+++ b/
test/web/federator_test.exs
@@
-3,31
+3,23
@@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.FederatorTest do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.FederatorTest do
- alias Pleroma.Web.{CommonAPI, Federator}
alias Pleroma.Instances
alias Pleroma.Instances
+ alias Pleroma.Web.CommonAPI
+ alias Pleroma.Web.Federator
use Pleroma.DataCase
import Pleroma.Factory
import Mock
setup_all do
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
use Pleroma.DataCase
import Pleroma.Factory
import Mock
setup_all do
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
- :ok
- end
-
- test "enqueues an element according to priority" do
- queue = [%{item: 1, priority: 2}]
-
- new_queue = Federator.enqueue_sorted(queue, 2, 1)
- assert new_queue == [%{item: 2, priority: 1}, %{item: 1, priority: 2}]
- new_queue = Federator.enqueue_sorted(queue, 2, 3)
- assert new_queue == [%{item: 1, priority: 2}, %{item: 2, priority: 3}]
- end
+ config_path = [:instance, :federating]
+ initial_setting = Pleroma.Config.get(config_path)
- test "pop first item" do
- queue = [%{item: 2, priority: 1}, %{item: 1, priority: 2}]
+ Pleroma.Config.put(config_path, true)
+ on_exit(fn -> Pleroma.Config.put(config_path, initial_setting) end)
- assert {2, [%{item: 1, priority: 2}]} = Federator.queue_pop(queue)
+ :ok
end
describe "Publish an activity" do
end
describe "Publish an activity" do
@@
-49,7
+41,7
@@
defmodule Pleroma.Web.FederatorTest do
relay_mock: relay_mock
} do
with_mocks([relay_mock]) do
relay_mock: relay_mock
} do
with_mocks([relay_mock]) do
- Federator.
handle(:publish,
activity)
+ Federator.
publish(
activity)
end
assert_received :relay_publish
end
assert_received :relay_publish
@@
-62,7
+54,7
@@
defmodule Pleroma.Web.FederatorTest do
Pleroma.Config.put([:instance, :allow_relay], false)
with_mocks([relay_mock]) do
Pleroma.Config.put([:instance, :allow_relay], false)
with_mocks([relay_mock]) do
- Federator.
handle(:publish,
activity)
+ Federator.
publish(
activity)
end
refute_received :relay_publish
end
refute_received :relay_publish
@@
-73,7
+65,7
@@
defmodule Pleroma.Web.FederatorTest do
describe "Targets reachability filtering in `publish`" do
test_with_mock "it federates only to reachable instances via AP",
describe "Targets reachability filtering in `publish`" do
test_with_mock "it federates only to reachable instances via AP",
-
Federato
r,
+
Pleroma.Web.ActivityPub.Publishe
r,
[:passthrough],
[] do
user = insert(:user)
[:passthrough],
[] do
user = insert(:user)
@@
-104,14
+96,17
@@
defmodule Pleroma.Web.FederatorTest do
CommonAPI.post(user, %{"status" => "HI @nick1@domain.com, @nick2@domain2.com!"})
assert called(
CommonAPI.post(user, %{"status" => "HI @nick1@domain.com, @nick2@domain2.com!"})
assert called(
- Federator.enqueue(:publish_single_ap, %{inbox: inbox1, unreachable_since: dt})
+ Pleroma.Web.ActivityPub.Publisher.publish_one(%{
+ inbox: inbox1,
+ unreachable_since: dt
+ })
)
)
- refute called(
Federator.enqueue(:publish_single_ap,
%{inbox: inbox2}))
+ refute called(
Pleroma.Web.ActivityPub.Publisher.publish_one(
%{inbox: inbox2}))
end
test_with_mock "it federates only to reachable instances via Websub",
end
test_with_mock "it federates only to reachable instances via Websub",
-
Federator
,
+
Pleroma.Web.Websub
,
[:passthrough],
[] do
user = insert(:user)
[:passthrough],
[] do
user = insert(:user)
@@
-139,17
+134,17
@@
defmodule Pleroma.Web.FederatorTest do
{:ok, _activity} = CommonAPI.post(user, %{"status" => "HI"})
assert called(
{:ok, _activity} = CommonAPI.post(user, %{"status" => "HI"})
assert called(
-
Federator.enqueue(:publish_single_websub,
%{
+
Pleroma.Web.Websub.publish_one(
%{
callback: sub2.callback,
unreachable_since: dt
})
)
callback: sub2.callback,
unreachable_since: dt
})
)
- refute called(
Federator.enqueue(:publish_single_websub,
%{callback: sub1.callback}))
+ refute called(
Pleroma.Web.Websub.publish_one(
%{callback: sub1.callback}))
end
test_with_mock "it federates only to reachable instances via Salmon",
end
test_with_mock "it federates only to reachable instances via Salmon",
-
Federator
,
+
Pleroma.Web.Salmon
,
[:passthrough],
[] do
user = insert(:user)
[:passthrough],
[] do
user = insert(:user)
@@
-179,13
+174,13
@@
defmodule Pleroma.Web.FederatorTest do
CommonAPI.post(user, %{"status" => "HI @nick1@domain.com, @nick2@domain2.com!"})
assert called(
CommonAPI.post(user, %{"status" => "HI @nick1@domain.com, @nick2@domain2.com!"})
assert called(
-
Federator.enqueue(:publish_single_salmon,
%{
+
Pleroma.Web.Salmon.publish_one(
%{
recipient: remote_user2,
unreachable_since: dt
})
)
recipient: remote_user2,
unreachable_since: dt
})
)
- refute called(
Federator.enqueue(:publish_single_websub,
%{recipient: remote_user1}))
+ refute called(
Pleroma.Web.Salmon.publish_one(
%{recipient: remote_user1}))
end
end
end
end
@@
-205,7
+200,7
@@
defmodule Pleroma.Web.FederatorTest do
"to" => ["https://www.w3.org/ns/activitystreams#Public"]
}
"to" => ["https://www.w3.org/ns/activitystreams#Public"]
}
- {:ok, _activity} = Federator.
handle(:incoming_ap_doc,
params)
+ {:ok, _activity} = Federator.
incoming_ap_doc(
params)
end
test "rejects incoming AP docs with incorrect origin" do
end
test "rejects incoming AP docs with incorrect origin" do
@@
-223,7
+218,7
@@
defmodule Pleroma.Web.FederatorTest do
"to" => ["https://www.w3.org/ns/activitystreams#Public"]
}
"to" => ["https://www.w3.org/ns/activitystreams#Public"]
}
- :error = Federator.
handle(:incoming_ap_doc,
params)
+ :error = Federator.
incoming_ap_doc(
params)
end
end
end
end
end
end