Compare commits
2 commits
39be25bf3c
...
9d72fb293b
Author | SHA1 | Date | |
---|---|---|---|
9d72fb293b | |||
589c0abb01 |
2 changed files with 84 additions and 2 deletions
|
@ -65,8 +65,8 @@ defmodule NullaWeb.ActorControllerTest do
|
|||
assert is_list(response["tag"])
|
||||
assert is_list(response["attachment"])
|
||||
assert is_map(response["endpoints"])
|
||||
assert is_map(response["icon"])
|
||||
assert is_map(response["image"])
|
||||
assert is_map(response["icon"]) or is_nil(response["icon"])
|
||||
assert is_map(response["image"]) or is_nil(response["image"])
|
||||
assert is_binary(response["vcard:bday"]) or is_nil(response["vcard:bday"])
|
||||
assert is_binary(response["vcard:Address"]) or is_nil(response["vcard:Address"])
|
||||
end
|
||||
|
|
82
test/nulla_web/controllers/webfinger_controller_test.exs
Normal file
82
test/nulla_web/controllers/webfinger_controller_test.exs
Normal file
|
@ -0,0 +1,82 @@
|
|||
defmodule NullaWeb.WebfingerControllerTest do
|
||||
use NullaWeb.ConnCase
|
||||
alias Nulla.Models.Actor
|
||||
|
||||
setup do
|
||||
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")
|
||||
})
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
describe "GET /.well-known/webfinger" do
|
||||
test "returns 400 without parameters", %{conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> get(~p"/.well-known/webfinger")
|
||||
|
||||
assert conn.status == 400
|
||||
end
|
||||
|
||||
test "returns 400 without :acct", %{conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> get(~p"/.well-known/webfinger?resource=test@localhost")
|
||||
|
||||
assert conn.status == 400
|
||||
end
|
||||
|
||||
test "returns 400 without domain", %{conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> get(~p"/.well-known/webfinger?resource=acct:test")
|
||||
|
||||
assert conn.status == 400
|
||||
end
|
||||
|
||||
test "returns 404 with invalid domain", %{conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> get(~p"/.well-known/webfinger?resource=acct:test@example")
|
||||
|
||||
assert conn.status == 404
|
||||
end
|
||||
|
||||
test "returns Webfinger", %{conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> get(~p"/.well-known/webfinger?resource=acct:test@localhost")
|
||||
|
||||
assert response = json_response(conn, 200)
|
||||
|
||||
assert is_binary(response["subject"])
|
||||
assert is_list(response["aliases"])
|
||||
assert is_list(response["links"])
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue