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
19 WebFinger.webfinger("#{user.nickname}@#{Pleroma.Web.Endpoint.host()}", "XML")
21 assert is_binary(result)
24 test "works for ap_ids" do
27 {:ok, result} = WebFinger.webfinger(user.ap_id, "XML")
28 assert is_binary(result)
32 describe "fingering" do
33 test "returns the info for an OStatus user" do
34 user = "shp@social.heldscal.la"
36 {:ok, data} = WebFinger.finger(user)
38 assert data["magic_key"] ==
39 "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB"
41 assert data["topic"] == "https://social.heldscal.la/api/statuses/user_timeline/29191.atom"
42 assert data["subject"] == "acct:shp@social.heldscal.la"
43 assert data["salmon"] == "https://social.heldscal.la/main/salmon/user/29191"
46 test "returns the ActivityPub actor URI for an ActivityPub user" do
47 user = "framasoft@framatube.org"
49 {:ok, _data} = WebFinger.finger(user)
52 test "returns the ActivityPub actor URI for an ActivityPub user with the ld+json mimetype" do
53 user = "kaniini@gerzilla.de"
55 {:ok, data} = WebFinger.finger(user)
57 assert data["ap_id"] == "https://gerzilla.de/channel/kaniini"
60 test "returns the correctly for json ostatus users" do
61 user = "winterdienst@gnusocial.de"
63 {:ok, data} = WebFinger.finger(user)
65 assert data["magic_key"] ==
66 "RSA.qfYaxztz7ZELrE4v5WpJrPM99SKI3iv9Y3Tw6nfLGk-4CRljNYqV8IYX2FXjeucC_DKhPNnlF6fXyASpcSmA_qupX9WC66eVhFhZ5OuyBOeLvJ1C4x7Hi7Di8MNBxY3VdQuQR0tTaS_YAZCwASKp7H6XEid3EJpGt0EQZoNzRd8=.AQAB"
68 assert data["topic"] == "https://gnusocial.de/api/statuses/user_timeline/249296.atom"
69 assert data["subject"] == "acct:winterdienst@gnusocial.de"
70 assert data["salmon"] == "https://gnusocial.de/main/salmon/user/249296"
71 assert data["subscribe_address"] == "https://gnusocial.de/main/ostatussub?profile={uri}"
74 test "it works for friendica" do
75 user = "lain@squeet.me"
77 {:ok, _data} = WebFinger.finger(user)
80 test "it gets the xrd endpoint" do
81 {:ok, template} = WebFinger.find_lrdd_template("social.heldscal.la")
83 assert template == "https://social.heldscal.la/.well-known/webfinger?resource={uri}"
86 test "it gets the xrd endpoint for hubzilla" do
87 {:ok, template} = WebFinger.find_lrdd_template("macgirvin.com")
89 assert template == "https://macgirvin.com/xrd/?uri={uri}"
92 test "it gets the xrd endpoint for statusnet" do
93 {:ok, template} = WebFinger.find_lrdd_template("status.alpicola.com")
95 assert template == "http://status.alpicola.com/main/xrd?uri={uri}"
99 describe "ensure_keys_present" do
100 test "it creates keys for a user and stores them in info" do
102 refute is_binary(user.info["keys"])
103 {:ok, user} = WebFinger.ensure_keys_present(user)
104 assert is_binary(user.info["keys"])
107 test "it doesn't create keys if there already are some" do
108 user = insert(:user, %{info: %{"keys" => "xxx"}})
109 {:ok, user} = WebFinger.ensure_keys_present(user)
110 assert user.info["keys"] == "xxx"