nulla/test/nulla_web/controllers/nodeinfo_controller_test.exs
2025-06-29 14:59:33 +02:00

55 lines
1.6 KiB
Elixir

defmodule NullaWeb.NodeinfoControllerTest do
use NullaWeb.ConnCase
import Nulla.Fixtures.Data
setup do
create_data()
:ok
end
describe "GET /.well-known/nodeinfo" do
test "returns Nodeinfo JSON index", %{conn: conn} do
conn =
conn
|> get(~p"/.well-known/nodeinfo")
assert response = json_response(conn, 200)
assert is_list(response["links"])
Enum.each(response["links"], fn link ->
assert is_map(link)
assert is_binary(link["rel"])
assert is_binary(link["href"])
end)
end
end
describe "GET /nodeinfo/2.0" do
test "returns Nodeinfo JSON show", %{conn: conn} do
conn =
conn
|> get(~p"/nodeinfo/2.0")
assert response = json_response(conn, 200)
assert response["version"] == "2.0"
assert is_map(response["software"])
assert response["software"]["name"] == "nulla"
assert is_binary(response["software"]["version"])
assert "activitypub" in response["protocols"]
assert is_map(response["services"])
assert is_list(response["services"]["outbound"])
assert is_list(response["services"]["inbound"])
assert is_map(response["usage"])
assert is_map(response["usage"]["users"])
assert response["usage"]["users"]["total"] > 0
assert response["usage"]["users"]["activeMonth"] > 0
assert response["usage"]["users"]["activeHalfyear"] > 0
assert is_boolean(response["openRegistrations"])
assert is_map(response["metadata"])
assert is_binary(response["metadata"]["nodeName"])
assert is_binary(response["metadata"]["nodeDescription"])
end
end
end