diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/webfinger.xml | 20 | ||||
-rw-r--r-- | test/web/web_finger/web_finger_test.exs | 20 |
2 files changed, 39 insertions, 1 deletions
diff --git a/test/fixtures/webfinger.xml b/test/fixtures/webfinger.xml new file mode 100644 index 000000000..4cde42e3f --- /dev/null +++ b/test/fixtures/webfinger.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> + <Subject>acct:shp@social.heldscal.la</Subject> + <Alias>https://social.heldscal.la/user/29191</Alias> + <Alias>https://social.heldscal.la/shp</Alias> + <Alias>https://social.heldscal.la/index.php/user/29191</Alias> + <Alias>https://social.heldscal.la/index.php/shp</Alias> + <Link rel="http://webfinger.net/rel/profile-page" type="text/html" href="https://social.heldscal.la/shp"/> + <Link rel="http://gmpg.org/xfn/11" type="text/html" href="https://social.heldscal.la/shp"/> + <Link rel="describedby" type="application/rdf+xml" href="https://social.heldscal.la/shp/foaf"/> + <Link rel="http://apinamespace.org/atom" type="application/atomsvc+xml" href="https://social.heldscal.la/api/statusnet/app/service/shp.xml"/> + <Link rel="http://apinamespace.org/twitter" href="https://social.heldscal.la/api/"/> + <Link rel="http://specs.openid.net/auth/2.0/provider" href="https://social.heldscal.la/shp"/> + <Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="https://social.heldscal.la/api/statuses/user_timeline/29191.atom"/> + <Link rel="magic-public-key" href="data:application/magic-public-key,RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB"/> + <Link rel="salmon" href="https://social.heldscal.la/main/salmon/user/29191"/> + <Link rel="http://salmon-protocol.org/ns/salmon-replies" href="https://social.heldscal.la/main/salmon/user/29191"/> + <Link rel="http://salmon-protocol.org/ns/salmon-mention" href="https://social.heldscal.la/main/salmon/user/29191"/> + <Link rel="http://ostatus.org/schema/1.0/subscribe" template="https://social.heldscal.la/main/ostatussub?profile={uri}"/> +</XRD> diff --git a/test/web/web_finger/web_finger_test.exs b/test/web/web_finger/web_finger_test.exs index 8a3007ff9..e5347a2b0 100644 --- a/test/web/web_finger/web_finger_test.exs +++ b/test/web/web_finger/web_finger_test.exs @@ -1,11 +1,29 @@ defmodule Pleroma.Web.WebFingerTest do use Pleroma.DataCase + alias Pleroma.Web.WebFinger describe "host meta" do test "returns a link to the xml lrdd" do - host_info = Pleroma.Web.WebFinger.host_meta + host_info = WebFinger.host_meta() assert String.contains?(host_info, Pleroma.Web.base_url) end end + + describe "fingering" do + test "returns the info for a user" do + user = "shp@social.heldscal.la" + + getter = fn(_url, _headers, [params: [resource: ^user]]) -> + {:ok, %{status_code: 200, body: File.read!("test/fixtures/webfinger.xml")}} + end + + {:ok, data} = WebFinger.finger(user, getter) + + assert data.magic_key == "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB" + assert data.topic == "https://social.heldscal.la/api/statuses/user_timeline/29191.atom" + assert data.subject == "acct:shp@social.heldscal.la" + assert data.salmon == "https://social.heldscal.la/main/salmon/user/29191" + end + end end |