1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Integration.FederationTest do
11 Pleroma.Cluster.spawn_default_cluster()
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
22 user = Pleroma.Factory.insert(:user)
23 {captured_binding, node(), user}
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
31 test "runs webserver on customized port" do
32 {nickname, url, url_404} =
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")
39 {user.nickname, user_url, url_404}
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}")