2020-01-26 20:36:50 +00:00
|
|
|
defmodule Mobilizon.Web.NodeInfoControllerTest do
|
|
|
|
use Mobilizon.Web.ConnCase
|
2018-08-01 12:45:18 +00:00
|
|
|
|
2019-09-07 22:05:54 +00:00
|
|
|
alias Mobilizon.Config
|
2018-08-01 12:45:18 +00:00
|
|
|
|
2020-01-26 20:36:50 +00:00
|
|
|
alias Mobilizon.Web.Endpoint
|
|
|
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
2019-09-22 16:29:13 +00:00
|
|
|
|
2018-08-01 12:45:18 +00:00
|
|
|
test "Get node info schemas", %{conn: conn} do
|
2018-11-06 09:30:27 +00:00
|
|
|
conn = get(conn, node_info_path(conn, :schemas))
|
2018-08-01 12:45:18 +00:00
|
|
|
|
|
|
|
assert json_response(conn, 200) == %{
|
|
|
|
"links" => [
|
2019-07-08 15:26:47 +00:00
|
|
|
%{
|
2019-09-22 16:29:13 +00:00
|
|
|
"href" => Routes.node_info_url(Endpoint, :nodeinfo, "2.0"),
|
2019-07-08 15:26:47 +00:00
|
|
|
"rel" => "http://nodeinfo.diaspora.software/ns/schema/2.0"
|
|
|
|
},
|
2018-08-01 12:45:18 +00:00
|
|
|
%{
|
2019-09-22 16:29:13 +00:00
|
|
|
"href" => Routes.node_info_url(Endpoint, :nodeinfo, "2.1"),
|
2019-05-24 07:18:19 +00:00
|
|
|
"rel" => "http://nodeinfo.diaspora.software/ns/schema/2.1"
|
2018-08-01 12:45:18 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
test "Get node info", %{conn: conn} do
|
2019-09-09 07:31:08 +00:00
|
|
|
# We clear the cache because it might have been initialized by other tests
|
|
|
|
Cachex.clear(:statistics)
|
2019-05-24 07:18:19 +00:00
|
|
|
conn = get(conn, node_info_path(conn, :nodeinfo, "2.1"))
|
2018-08-01 12:45:18 +00:00
|
|
|
resp = json_response(conn, 200)
|
|
|
|
|
2018-11-12 17:17:53 +00:00
|
|
|
assert resp == %{
|
2019-07-08 15:26:47 +00:00
|
|
|
"metadata" => %{
|
2019-09-07 22:05:54 +00:00
|
|
|
"nodeName" => Config.instance_name(),
|
|
|
|
"nodeDescription" => Config.instance_description()
|
2019-07-08 15:26:47 +00:00
|
|
|
},
|
2019-09-07 22:05:54 +00:00
|
|
|
"openRegistrations" => Config.instance_registrations_open?(),
|
2018-08-01 12:45:18 +00:00
|
|
|
"protocols" => ["activitypub"],
|
2019-07-08 15:26:47 +00:00
|
|
|
"services" => %{"inbound" => [], "outbound" => ["atom1.0"]},
|
2019-05-24 07:18:19 +00:00
|
|
|
"software" => %{
|
2019-09-09 07:31:08 +00:00
|
|
|
"name" => "Mobilizon",
|
2019-09-07 22:05:54 +00:00
|
|
|
"version" => Config.instance_version(),
|
|
|
|
"repository" => Config.instance_repository()
|
2019-05-24 07:18:19 +00:00
|
|
|
},
|
2018-11-12 17:17:53 +00:00
|
|
|
"usage" => %{"localComments" => 0, "localPosts" => 0, "users" => %{"total" => 0}},
|
2019-05-24 07:18:19 +00:00
|
|
|
"version" => "2.1"
|
2018-08-01 12:45:18 +00:00
|
|
|
}
|
|
|
|
end
|
2018-11-28 09:49:16 +00:00
|
|
|
|
|
|
|
test "Get node info with non supported version (1.0)", %{conn: conn} do
|
|
|
|
conn = get(conn, node_info_path(conn, :nodeinfo, "1.0"))
|
|
|
|
|
|
|
|
assert json_response(conn, 404) == %{"error" => "Nodeinfo schema version not handled"}
|
|
|
|
end
|
2018-08-01 12:45:18 +00:00
|
|
|
end
|