prune_objects can prune orphaned activities
[akkoma] / test / pleroma / integration / federation_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Integration.FederationTest do
6 use Pleroma.DataCase
7 @moduletag :federated
8 import Pleroma.Cluster
9
10 setup_all do
11 Pleroma.Cluster.spawn_default_cluster()
12 :ok
13 end
14
15 @federated1 :"federated1@127.0.0.1"
16 describe "federated cluster primitives" do
17 test "within/2 captures local bindings and executes block on remote node" do
18 captured_binding = :captured
19
20 result =
21 within @federated1 do
22 user = Pleroma.Factory.insert(:user)
23 {captured_binding, node(), user}
24 end
25
26 assert {:captured, @federated1, user} = result
27 refute Pleroma.User.get_by_id(user.id)
28 assert user.id == within(@federated1, do: Pleroma.User.get_by_id(user.id)).id
29 end
30
31 test "runs webserver on customized port" do
32 {nickname, url, url_404} =
33 within @federated1 do
34 import Pleroma.Web.Router.Helpers
35 user = Pleroma.Factory.insert(:user)
36 user_url = account_url(Pleroma.Web.Endpoint, :show, user)
37 url_404 = account_url(Pleroma.Web.Endpoint, :show, "not-exists")
38
39 {user.nickname, user_url, url_404}
40 end
41
42 assert {:ok, {{_, 200, _}, _headers, body}} = :httpc.request(~c"#{url}")
43 assert %{"acct" => ^nickname} = Jason.decode!(body)
44 assert {:ok, {{_, 404, _}, _headers, _body}} = :httpc.request(~c"#{url_404}")
45 end
46 end
47 end