diff --git a/lib/nulla/models/user.ex b/lib/nulla/models/user.ex index 29f3a8e..334a41a 100644 --- a/lib/nulla/models/user.ex +++ b/lib/nulla/models/user.ex @@ -4,6 +4,7 @@ defmodule Nulla.Models.User do import Ecto.Query alias Nulla.Repo alias Nulla.Models.User + alias Nulla.Models.Actor alias Nulla.Models.Session @primary_key {:id, :integer, autogenerate: false} @@ -13,6 +14,7 @@ defmodule Nulla.Models.User do field :privateKeyPem, :string field :last_active_at, :utc_datetime + belongs_to :actor, Actor, define_field: false, foreign_key: :id, type: :integer has_many :user_sessions, Session timestamps(type: :utc_datetime) diff --git a/test/nulla_web/controllers/nodeinfo_controller_test.exs b/test/nulla_web/controllers/nodeinfo_controller_test.exs deleted file mode 100644 index 085b5a0..0000000 --- a/test/nulla_web/controllers/nodeinfo_controller_test.exs +++ /dev/null @@ -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