1 defmodule Pleroma.Web.WebFingerTest do
3 alias Pleroma.Web.WebFinger
6 describe "host meta" do
7 test "returns a link to the xml lrdd" do
8 host_info = WebFinger.host_meta()
10 assert String.contains?(host_info, Pleroma.Web.base_url)
14 describe "incoming webfinger request" do
15 test "works for fqns" do
18 {:ok, result} = WebFinger.webfinger("#{user.nickname}@#{Pleroma.Web.Endpoint.host}", "XML")
19 assert is_binary(result)
22 test "works for ap_ids" do
25 {:ok, result} = WebFinger.webfinger(user.ap_id, "XML")
26 assert is_binary(result)
30 describe "fingering" do
31 test "returns the info for a user" do
32 user = "shp@social.heldscal.la"
34 {:ok, data} = WebFinger.finger(user)
36 assert data["magic_key"] == "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB"
37 assert data["topic"] == "https://social.heldscal.la/api/statuses/user_timeline/29191.atom"
38 assert data["subject"] == "acct:shp@social.heldscal.la"
39 assert data["salmon"] == "https://social.heldscal.la/main/salmon/user/29191"
42 test "it works for friendica" do
43 user = "lain@squeet.me"
45 {:ok, _data} = WebFinger.finger(user)
48 test "it gets the xrd endpoint" do
49 {:ok, template} = WebFinger.find_lrdd_template("social.heldscal.la")
51 assert template == "https://social.heldscal.la/.well-known/webfinger?resource={uri}"
54 test "it gets the xrd endpoint for hubzilla" do
55 {:ok, template} = WebFinger.find_lrdd_template("macgirvin.com")
57 assert template == "https://macgirvin.com/xrd/?uri={uri}"
61 describe "ensure_keys_present" do
62 test "it creates keys for a user and stores them in info" do
64 refute is_binary(user.info["keys"])
65 {:ok, user} = WebFinger.ensure_keys_present(user)
66 assert is_binary(user.info["keys"])
69 test "it doesn't create keys if there already are some" do
70 user = insert(:user, %{info: %{"keys" => "xxx"}})
71 {:ok, user} = WebFinger.ensure_keys_present(user)
72 assert user.info["keys"] == "xxx"