tests WebFinger
This commit is contained in:
parent
b7fae304d3
commit
55341ac717
7 changed files with 141 additions and 24 deletions
|
|
@ -19,6 +19,19 @@ defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
test "GET host-meta" do
|
||||
response =
|
||||
build_conn()
|
||||
|> get("/.well-known/host-meta")
|
||||
|
||||
assert response.status == 200
|
||||
|
||||
assert response.resp_body ==
|
||||
~s(<?xml version="1.0" encoding="UTF-8"?><XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"><Link rel="lrdd" template="#{
|
||||
Pleroma.Web.base_url()
|
||||
}/.well-known/webfinger?resource={uri}" type="application/xrd+xml" /></XRD>)
|
||||
end
|
||||
|
||||
test "Webfinger JRD" do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
@ -30,6 +43,16 @@ defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
|
|||
assert json_response(response, 200)["subject"] == "acct:#{user.nickname}@localhost"
|
||||
end
|
||||
|
||||
test "it returns 404 when user isn't found (JSON)" do
|
||||
result =
|
||||
build_conn()
|
||||
|> put_req_header("accept", "application/jrd+json")
|
||||
|> get("/.well-known/webfinger?resource=acct:jimm@localhost")
|
||||
|> json_response(404)
|
||||
|
||||
assert result == "Couldn't find user"
|
||||
end
|
||||
|
||||
test "Webfinger XML" do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
@ -41,6 +64,26 @@ defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
|
|||
assert response(response, 200)
|
||||
end
|
||||
|
||||
test "it returns 404 when user isn't found (XML)" do
|
||||
result =
|
||||
build_conn()
|
||||
|> put_req_header("accept", "application/xrd+xml")
|
||||
|> get("/.well-known/webfinger?resource=acct:jimm@localhost")
|
||||
|> response(404)
|
||||
|
||||
assert result == "Couldn't find user"
|
||||
end
|
||||
|
||||
test "Sends a 404 when invalid format" do
|
||||
user = insert(:user)
|
||||
|
||||
assert_raise Phoenix.NotAcceptableError, fn ->
|
||||
build_conn()
|
||||
|> put_req_header("accept", "text/html")
|
||||
|> get("/.well-known/webfinger?resource=acct:#{user.nickname}@localhost")
|
||||
end
|
||||
end
|
||||
|
||||
test "Sends a 400 when resource param is missing" do
|
||||
response =
|
||||
build_conn()
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ defmodule Pleroma.Web.WebFingerTest do
|
|||
end
|
||||
|
||||
describe "fingering" do
|
||||
test "returns error when fails parse xml or json" do
|
||||
user = "invalid_content@social.heldscal.la"
|
||||
assert {:error, %Jason.DecodeError{}} = WebFinger.finger(user)
|
||||
end
|
||||
|
||||
test "returns the info for an OStatus user" do
|
||||
user = "shp@social.heldscal.la"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue