Compare commits
No commits in common. "0c38e169700e77ef93d47e466229912199d27c8a" and "74514f02a1a13adfea853b9b964f910dbf113872" have entirely different histories.
0c38e16970
...
74514f02a1
2 changed files with 2 additions and 89 deletions
|
@ -4,6 +4,7 @@ defmodule Nulla.Models.User do
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
alias Nulla.Repo
|
alias Nulla.Repo
|
||||||
alias Nulla.Models.User
|
alias Nulla.Models.User
|
||||||
|
alias Nulla.Models.Actor
|
||||||
alias Nulla.Models.Session
|
alias Nulla.Models.Session
|
||||||
|
|
||||||
@primary_key {:id, :integer, autogenerate: false}
|
@primary_key {:id, :integer, autogenerate: false}
|
||||||
|
@ -13,6 +14,7 @@ defmodule Nulla.Models.User do
|
||||||
field :privateKeyPem, :string
|
field :privateKeyPem, :string
|
||||||
field :last_active_at, :utc_datetime
|
field :last_active_at, :utc_datetime
|
||||||
|
|
||||||
|
belongs_to :actor, Actor, define_field: false, foreign_key: :id, type: :integer
|
||||||
has_many :user_sessions, Session
|
has_many :user_sessions, Session
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime)
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
defmodule NullaWeb.NodeinfoControllerTest do
|
|
||||||
use NullaWeb.ConnCase
|
|
||||||
alias Nulla.Models.User
|
|
||||||
alias Nulla.Models.Actor
|
|
||||||
|
|
||||||
setup do
|
|
||||||
{:ok, actor} = Actor.create_actor(%{
|
|
||||||
domain: "localhost",
|
|
||||||
ap_id: "http://localhost/users/test",
|
|
||||||
type: "Person",
|
|
||||||
following: "http://localhost/users/test/following",
|
|
||||||
followers: "http://localhost/users/test/followers",
|
|
||||||
inbox: "http://localhost/users/test/inbox",
|
|
||||||
outbox: "http://localhost/users/test/outbox",
|
|
||||||
featured: "http://localhost/users/test/collections/featured",
|
|
||||||
featuredTags: "http://localhost/users/test/collections/tags",
|
|
||||||
preferredUsername: "test",
|
|
||||||
name: "Test",
|
|
||||||
summary: "Test User",
|
|
||||||
url: "http://localhost/@test",
|
|
||||||
manuallyApprovesFollowers: false,
|
|
||||||
discoverable: true,
|
|
||||||
indexable: true,
|
|
||||||
published: DateTime.utc_now(),
|
|
||||||
memorial: false,
|
|
||||||
publicKey:
|
|
||||||
Jason.OrderedObject.new(
|
|
||||||
id: "http://localhost/users/test#main-key",
|
|
||||||
owner: "http://localhost/users/test",
|
|
||||||
publicKeyPem: "PUBLIC KEY"
|
|
||||||
),
|
|
||||||
endpoints: Jason.OrderedObject.new(sharedInbox: "http://localhost/inbox")
|
|
||||||
})
|
|
||||||
|
|
||||||
User.create_user(%{
|
|
||||||
id: actor.id,
|
|
||||||
email: "test@localhost",
|
|
||||||
password: "password",
|
|
||||||
privateKeyPem: "PRIVATE KEY",
|
|
||||||
last_active_at: DateTime.utc_now()
|
|
||||||
})
|
|
||||||
|
|
||||||
: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
|
|
||||||
|
|
||||||
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"] == 1
|
|
||||||
assert response["usage"]["users"]["activeMonth"] == 1
|
|
||||||
assert response["usage"]["users"]["activeHalfyear"] == 1
|
|
||||||
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
|
|
Loading…
Add table
Add a link
Reference in a new issue