Add inbox_controller_test.exs

This commit is contained in:
Mirai Kumiko 2025-06-29 08:35:12 +02:00
parent c30541830f
commit 748baff8f3
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
2 changed files with 99 additions and 22 deletions

View file

@ -5,23 +5,29 @@ defmodule Nulla.Fixtures.Data do
alias Nulla.Models.Note
def create do
endpoint_config = Application.fetch_env!(:nulla, NullaWeb.Endpoint)
ip = endpoint_config[:http][:ip]
host = :inet_parse.ntoa(ip) |> to_string()
port = endpoint_config[:http][:port]
base_url = "http://#{host}:#{port}"
{publicKeyPem, privateKeyPem} = KeyGen.gen()
{:ok, actor} =
Actor.create_actor(%{
domain: "localhost",
ap_id: "http://localhost/users/test",
ap_id: "#{base_url}/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",
following: "#{base_url}/users/test/following",
followers: "#{base_url}/users/test/followers",
inbox: "#{base_url}/users/test/inbox",
outbox: "#{base_url}/users/test/outbox",
featured: "#{base_url}/users/test/collections/featured",
featuredTags: "#{base_url}/users/test/collections/tags",
preferredUsername: "test",
name: "Test",
summary: "Test User",
url: "http://localhost/@test",
url: "#{base_url}/@test",
manuallyApprovesFollowers: false,
discoverable: true,
indexable: true,
@ -29,11 +35,11 @@ defmodule Nulla.Fixtures.Data do
memorial: false,
publicKey:
Jason.OrderedObject.new(
id: "http://localhost/users/test#main-key",
owner: "http://localhost/users/test",
id: "#{base_url}/users/test#main-key",
owner: "#{base_url}/users/test",
publicKeyPem: publicKeyPem
),
endpoints: Jason.OrderedObject.new(sharedInbox: "http://localhost/inbox")
endpoints: Jason.OrderedObject.new(sharedInbox: "#{base_url}/inbox")
})
User.create_user(%{
@ -56,18 +62,18 @@ defmodule Nulla.Fixtures.Data do
{:ok, actor} =
Actor.create_actor(%{
domain: "localhost",
ap_id: "http://localhost/users/test2",
ap_id: "#{base_url}/users/test2",
type: "Person",
following: "http://localhost/users/test2/following",
followers: "http://localhost/users/test2/followers",
inbox: "http://localhost/users/test2/inbox",
outbox: "http://localhost/users/test2/outbox",
featured: "http://localhost/users/test2/collections/featured",
featuredTags: "http://localhost/users/test2/collections/tags",
following: "#{base_url}/users/test2/following",
followers: "#{base_url}/users/test2/followers",
inbox: "#{base_url}/users/test2/inbox",
outbox: "#{base_url}/users/test2/outbox",
featured: "#{base_url}/users/test2/collections/featured",
featuredTags: "#{base_url}/users/test2/collections/tags",
preferredUsername: "test2",
name: "Test",
summary: "Test User",
url: "http://localhost/@test2",
url: "#{base_url}/@test2",
manuallyApprovesFollowers: false,
discoverable: true,
indexable: true,
@ -75,11 +81,11 @@ defmodule Nulla.Fixtures.Data do
memorial: false,
publicKey:
Jason.OrderedObject.new(
id: "http://localhost/users/test2#main-key",
owner: "http://localhost/users/test2",
id: "#{base_url}/users/test2#main-key",
owner: "#{base_url}/users/test2",
publicKeyPem: publicKeyPem
),
endpoints: Jason.OrderedObject.new(sharedInbox: "http://localhost/inbox")
endpoints: Jason.OrderedObject.new(sharedInbox: "#{base_url}/inbox")
})
User.create_user(%{