2020-10-15 22:32:20 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 20:38:50 +00:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2020-10-15 22:32:20 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.PleromaApi.InstancesControllerTest do
|
|
|
|
use Pleroma.Web.ConnCase
|
|
|
|
|
|
|
|
alias Pleroma.Instances
|
|
|
|
|
|
|
|
setup_all do: clear_config([:instance, :federation_reachability_timeout_days], 1)
|
|
|
|
|
|
|
|
setup do
|
|
|
|
constant = "http://consistently-unreachable.name/"
|
|
|
|
eventual = "http://eventually-unreachable.com/path"
|
|
|
|
|
|
|
|
{:ok, %Pleroma.Instances.Instance{unreachable_since: constant_unreachable}} =
|
|
|
|
Instances.set_consistently_unreachable(constant)
|
|
|
|
|
2023-12-27 23:15:32 +00:00
|
|
|
_eventual_unreachable = Instances.set_unreachable(eventual)
|
2020-10-15 22:32:20 +00:00
|
|
|
|
|
|
|
%{constant_unreachable: constant_unreachable, constant: constant}
|
|
|
|
end
|
|
|
|
|
|
|
|
test "GET /api/v1/pleroma/federation_status", %{
|
|
|
|
conn: conn,
|
|
|
|
constant_unreachable: constant_unreachable,
|
|
|
|
constant: constant
|
|
|
|
} do
|
2023-08-08 17:08:59 +00:00
|
|
|
clear_config([:instance, :public], false)
|
|
|
|
|
2020-10-15 22:32:20 +00:00
|
|
|
constant_host = URI.parse(constant).host
|
|
|
|
|
|
|
|
assert conn
|
|
|
|
|> put_req_header("content-type", "application/json")
|
|
|
|
|> get("/api/v1/pleroma/federation_status")
|
2020-10-15 23:13:52 +00:00
|
|
|
|> json_response_and_validate_schema(200) == %{
|
2020-10-15 22:32:20 +00:00
|
|
|
"unreachable" => %{constant_host => to_string(constant_unreachable)}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|