debianize-mobilizon/test/mobilizon_web/controllers/nodeinfo_controller_test.exs

56 lines
1.9 KiB
Elixir
Raw Normal View History

defmodule MobilizonWeb.NodeInfoControllerTest do
use MobilizonWeb.ConnCase
2019-09-08 00:05:54 +02:00
alias Mobilizon.Config
2019-09-22 18:29:13 +02:00
alias MobilizonWeb.Endpoint
alias MobilizonWeb.Router.Helpers, as: Routes
test "Get node info schemas", %{conn: conn} do
conn = get(conn, node_info_path(conn, :schemas))
assert json_response(conn, 200) == %{
"links" => [
%{
2019-09-22 18:29:13 +02:00
"href" => Routes.node_info_url(Endpoint, :nodeinfo, "2.0"),
"rel" => "http://nodeinfo.diaspora.software/ns/schema/2.0"
},
%{
2019-09-22 18:29:13 +02:00
"href" => Routes.node_info_url(Endpoint, :nodeinfo, "2.1"),
2019-05-24 09:18:19 +02:00
"rel" => "http://nodeinfo.diaspora.software/ns/schema/2.1"
}
]
}
end
test "Get node info", %{conn: conn} do
# We clear the cache because it might have been initialized by other tests
Cachex.clear(:statistics)
2019-05-24 09:18:19 +02:00
conn = get(conn, node_info_path(conn, :nodeinfo, "2.1"))
resp = json_response(conn, 200)
assert resp == %{
"metadata" => %{
2019-09-08 00:05:54 +02:00
"nodeName" => Config.instance_name(),
"nodeDescription" => Config.instance_description()
},
2019-09-08 00:05:54 +02:00
"openRegistrations" => Config.instance_registrations_open?(),
"protocols" => ["activitypub"],
"services" => %{"inbound" => [], "outbound" => ["atom1.0"]},
2019-05-24 09:18:19 +02:00
"software" => %{
"name" => "Mobilizon",
2019-09-08 00:05:54 +02:00
"version" => Config.instance_version(),
"repository" => Config.instance_repository()
2019-05-24 09:18:19 +02:00
},
"usage" => %{"localComments" => 0, "localPosts" => 0, "users" => %{"total" => 0}},
2019-05-24 09:18:19 +02:00
"version" => "2.1"
}
end
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
end