rename WebFinger module to Discovery
This commit is contained in:
parent
c4173fa18c
commit
09904b54d0
16 changed files with 62 additions and 62 deletions
|
|
@ -46,7 +46,7 @@ DiasporaFederation.configure do |config|
|
||||||
on :person_webfinger_fetch do |handle|
|
on :person_webfinger_fetch do |handle|
|
||||||
person = Person.find_local_by_diaspora_handle(handle)
|
person = Person.find_local_by_diaspora_handle(handle)
|
||||||
if person
|
if person
|
||||||
DiasporaFederation::WebFinger::WebFinger.new(
|
DiasporaFederation::Discovery::WebFinger.new(
|
||||||
# ...
|
# ...
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,11 @@ module DiasporaFederation
|
||||||
# creates the host-meta xml with the configured server_uri and caches it
|
# creates the host-meta xml with the configured server_uri and caches it
|
||||||
# @return [String] XML string
|
# @return [String] XML string
|
||||||
def self.host_meta_xml
|
def self.host_meta_xml
|
||||||
@host_meta_xml ||= WebFinger::HostMeta.from_base_url(DiasporaFederation.server_uri.to_s).to_xml
|
@host_meta_xml ||= Discovery::HostMeta.from_base_url(DiasporaFederation.server_uri.to_s).to_xml
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_person_webfinger(query)
|
def find_person_webfinger(query)
|
||||||
DiasporaFederation.callbacks.trigger(:person_webfinger_fetch, query.strip.downcase.gsub("acct:", ""))
|
DiasporaFederation.callbacks.trigger(:person_webfinger_fetch, query.strip.downcase.sub("acct:", ""))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ require "diaspora_federation/callbacks"
|
||||||
require "diaspora_federation/properties_dsl"
|
require "diaspora_federation/properties_dsl"
|
||||||
require "diaspora_federation/entity"
|
require "diaspora_federation/entity"
|
||||||
|
|
||||||
require "diaspora_federation/web_finger"
|
require "diaspora_federation/discovery"
|
||||||
|
|
||||||
# diaspora* federation library
|
# diaspora* federation library
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
|
|
|
||||||
13
lib/diaspora_federation/discovery.rb
Normal file
13
lib/diaspora_federation/discovery.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
module DiasporaFederation
|
||||||
|
# This module provides the namespace for the various classes implementing
|
||||||
|
# WebFinger and other protocols used for metadata discovery on remote servers
|
||||||
|
# in the Diaspora* network.
|
||||||
|
module Discovery
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
require "diaspora_federation/discovery/exceptions"
|
||||||
|
require "diaspora_federation/discovery/xrd_document"
|
||||||
|
require "diaspora_federation/discovery/host_meta"
|
||||||
|
require "diaspora_federation/discovery/web_finger"
|
||||||
|
require "diaspora_federation/discovery/h_card"
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
module WebFinger
|
module Discovery
|
||||||
# Raised, if the XML structure is invalid
|
# Raised, if the XML structure is invalid
|
||||||
class InvalidDocument < RuntimeError
|
class InvalidDocument < RuntimeError
|
||||||
end
|
end
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
module WebFinger
|
module Discovery
|
||||||
# This class provides the means of generating an parsing account data to and
|
# This class provides the means of generating an parsing account data to and
|
||||||
# from the hCard format.
|
# from the hCard format.
|
||||||
# hCard is based on +RFC 2426+ (vCard) which got superseded by +RFC 6350+.
|
# hCard is based on +RFC 2426+ (vCard) which got superseded by +RFC 6350+.
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
module WebFinger
|
module Discovery
|
||||||
# Generates and parses Host Meta documents.
|
# Generates and parses Host Meta documents.
|
||||||
#
|
#
|
||||||
# This is a minimal implementation of the standard, only to the degree of what
|
# This is a minimal implementation of the standard, only to the degree of what
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
module WebFinger
|
module Discovery
|
||||||
# The WebFinger document used for Diaspora* user discovery is based on an older
|
# The WebFinger document used for Diaspora* user discovery is based on an older
|
||||||
# draft of the specification you can find in the wiki of the "webfinger" project
|
# draft of the specification you can find in the wiki of the "webfinger" project
|
||||||
# on {http://code.google.com/p/webfinger/wiki/WebFingerProtocol Google Code}
|
# on {http://code.google.com/p/webfinger/wiki/WebFingerProtocol Google Code}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
module WebFinger
|
module Discovery
|
||||||
# This class implements basic handling of XRD documents as far as it is
|
# This class implements basic handling of XRD documents as far as it is
|
||||||
# necessary in the context of the protocols used with Diaspora* federation.
|
# necessary in the context of the protocols used with Diaspora* federation.
|
||||||
#
|
#
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
module DiasporaFederation
|
|
||||||
# This module provides the namespace for the various classes implementing
|
|
||||||
# WebFinger and other protocols used for metadata discovery on remote servers
|
|
||||||
# in the Diaspora* network.
|
|
||||||
module WebFinger
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
require "diaspora_federation/web_finger/exceptions"
|
|
||||||
require "diaspora_federation/web_finger/xrd_document"
|
|
||||||
require "diaspora_federation/web_finger/host_meta"
|
|
||||||
require "diaspora_federation/web_finger/web_finger"
|
|
||||||
require "diaspora_federation/web_finger/h_card"
|
|
||||||
|
|
@ -24,13 +24,13 @@ module DiasporaFederation
|
||||||
expect(response.header["Content-Type"]).to include "application/xrd+xml"
|
expect(response.header["Content-Type"]).to include "application/xrd+xml"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calls WebFinger::HostMeta.from_base_url with the base url" do
|
it "calls Discovery::HostMeta.from_base_url with the base url" do
|
||||||
expect(WebFinger::HostMeta).to receive(:from_base_url).with("http://localhost:3000/").and_call_original
|
expect(Discovery::HostMeta).to receive(:from_base_url).with("http://localhost:3000/").and_call_original
|
||||||
get :host_meta
|
get :host_meta
|
||||||
end
|
end
|
||||||
|
|
||||||
it "caches the xml" do
|
it "caches the xml" do
|
||||||
expect(WebFinger::HostMeta).to receive(:from_base_url).exactly(1).times.and_call_original
|
expect(Discovery::HostMeta).to receive(:from_base_url).exactly(1).times.and_call_original
|
||||||
get :host_meta
|
get :host_meta
|
||||||
get :host_meta
|
get :host_meta
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
describe WebFinger::HCard do
|
describe Discovery::HCard do
|
||||||
let(:person) { FactoryGirl.create(:person) }
|
let(:person) { FactoryGirl.create(:person) }
|
||||||
let(:photo_large_url) { "#{person.url}/upload/large.png" }
|
let(:photo_large_url) { "#{person.url}/upload/large.png" }
|
||||||
let(:photo_medium_url) { "#{person.url}/upload/medium.png" }
|
let(:photo_medium_url) { "#{person.url}/upload/medium.png" }
|
||||||
|
|
@ -93,12 +93,12 @@ HTML
|
||||||
}
|
}
|
||||||
|
|
||||||
it "must not create blank instances" do
|
it "must not create blank instances" do
|
||||||
expect { WebFinger::HCard.new({}) }.to raise_error ArgumentError
|
expect { Discovery::HCard.new({}) }.to raise_error ArgumentError
|
||||||
end
|
end
|
||||||
|
|
||||||
context "generation" do
|
context "generation" do
|
||||||
it "creates an instance from a data hash" do
|
it "creates an instance from a data hash" do
|
||||||
hcard = WebFinger::HCard.new(
|
hcard = Discovery::HCard.new(
|
||||||
guid: person.guid,
|
guid: person.guid,
|
||||||
nickname: person.nickname,
|
nickname: person.nickname,
|
||||||
full_name: person.full_name,
|
full_name: person.full_name,
|
||||||
|
|
@ -115,13 +115,13 @@ HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails if nil was given" do
|
it "fails if nil was given" do
|
||||||
expect { WebFinger::HCard.new(nil) }.to raise_error ArgumentError, "expected a Hash"
|
expect { Discovery::HCard.new(nil) }.to raise_error ArgumentError, "expected a Hash"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "parsing" do
|
context "parsing" do
|
||||||
it "reads its own output" do
|
it "reads its own output" do
|
||||||
hcard = WebFinger::HCard.from_html(html)
|
hcard = Discovery::HCard.from_html(html)
|
||||||
expect(hcard.guid).to eq(person.guid)
|
expect(hcard.guid).to eq(person.guid)
|
||||||
expect(hcard.nickname).to eq(person.nickname)
|
expect(hcard.nickname).to eq(person.nickname)
|
||||||
expect(hcard.full_name).to eq(person.full_name)
|
expect(hcard.full_name).to eq(person.full_name)
|
||||||
|
|
@ -137,7 +137,7 @@ HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is frozen after parsing" do
|
it "is frozen after parsing" do
|
||||||
hcard = WebFinger::HCard.from_html(html)
|
hcard = Discovery::HCard.from_html(html)
|
||||||
expect(hcard).to be_frozen
|
expect(hcard).to be_frozen
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -147,7 +147,7 @@ HTML
|
||||||
"class=\"searchable\"><"
|
"class=\"searchable\"><"
|
||||||
)
|
)
|
||||||
|
|
||||||
hcard = WebFinger::HCard.from_html(changed_html)
|
hcard = Discovery::HCard.from_html(changed_html)
|
||||||
|
|
||||||
expect(hcard.searchable).to eq(false)
|
expect(hcard.searchable).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
@ -218,7 +218,7 @@ HTML
|
||||||
</div>
|
</div>
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
hcard = WebFinger::HCard.from_html(historic_html)
|
hcard = Discovery::HCard.from_html(historic_html)
|
||||||
expect(hcard.url).to eq(person.url)
|
expect(hcard.url).to eq(person.url)
|
||||||
expect(hcard.photo_large_url).to eq(photo_large_url)
|
expect(hcard.photo_large_url).to eq(photo_large_url)
|
||||||
expect(hcard.photo_medium_url).to eq(photo_medium_url)
|
expect(hcard.photo_medium_url).to eq(photo_medium_url)
|
||||||
|
|
@ -235,11 +235,11 @@ HTML
|
||||||
<span class="fn">#{person.full_name}</span>
|
<span class="fn">#{person.full_name}</span>
|
||||||
</div>
|
</div>
|
||||||
HTML
|
HTML
|
||||||
expect { WebFinger::HCard.from_html(invalid_html) }.to raise_error WebFinger::InvalidData
|
expect { Discovery::HCard.from_html(invalid_html) }.to raise_error Discovery::InvalidData
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails if the document is not HTML" do
|
it "fails if the document is not HTML" do
|
||||||
expect { WebFinger::HCard.from_html("") }.to raise_error WebFinger::InvalidData
|
expect { Discovery::HCard.from_html("") }.to raise_error Discovery::InvalidData
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
describe WebFinger::HostMeta do
|
describe Discovery::HostMeta do
|
||||||
let(:base_url) { "https://pod.example.tld/" }
|
let(:base_url) { "https://pod.example.tld/" }
|
||||||
let(:xml) {
|
let(:xml) {
|
||||||
<<-XML
|
<<-XML
|
||||||
|
|
@ -11,28 +11,28 @@ XML
|
||||||
}
|
}
|
||||||
|
|
||||||
it "must not create blank instances" do
|
it "must not create blank instances" do
|
||||||
expect { WebFinger::HostMeta.new }.to raise_error NoMethodError
|
expect { Discovery::HostMeta.new }.to raise_error NoMethodError
|
||||||
end
|
end
|
||||||
|
|
||||||
context "generation" do
|
context "generation" do
|
||||||
it "creates a nice XML document" do
|
it "creates a nice XML document" do
|
||||||
hm = WebFinger::HostMeta.from_base_url(base_url)
|
hm = Discovery::HostMeta.from_base_url(base_url)
|
||||||
expect(hm.to_xml).to eq(xml)
|
expect(hm.to_xml).to eq(xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "appends a '/' if necessary" do
|
it "appends a '/' if necessary" do
|
||||||
hm = WebFinger::HostMeta.from_base_url("https://pod.example.tld")
|
hm = Discovery::HostMeta.from_base_url("https://pod.example.tld")
|
||||||
expect(hm.to_xml).to eq(xml)
|
expect(hm.to_xml).to eq(xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails if the base_url was omitted" do
|
it "fails if the base_url was omitted" do
|
||||||
expect { WebFinger::HostMeta.from_base_url("") }.to raise_error WebFinger::InvalidData
|
expect { Discovery::HostMeta.from_base_url("") }.to raise_error Discovery::InvalidData
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "parsing" do
|
context "parsing" do
|
||||||
it "parses its own output" do
|
it "parses its own output" do
|
||||||
hm = WebFinger::HostMeta.from_xml(xml)
|
hm = Discovery::HostMeta.from_xml(xml)
|
||||||
expect(hm.webfinger_template_url).to eq("#{base_url}webfinger?q={uri}")
|
expect(hm.webfinger_template_url).to eq("#{base_url}webfinger?q={uri}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -49,7 +49,7 @@ XML
|
||||||
|
|
||||||
</XRD>
|
</XRD>
|
||||||
XML
|
XML
|
||||||
hm = WebFinger::HostMeta.from_xml(historic_xml)
|
hm = Discovery::HostMeta.from_xml(historic_xml)
|
||||||
expect(hm.webfinger_template_url).to eq("#{base_url}webfinger?q={uri}")
|
expect(hm.webfinger_template_url).to eq("#{base_url}webfinger?q={uri}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ XML
|
||||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||||
</XRD>
|
</XRD>
|
||||||
XML
|
XML
|
||||||
expect { WebFinger::HostMeta.from_xml(invalid_xml) }.to raise_error WebFinger::InvalidData
|
expect { Discovery::HostMeta.from_xml(invalid_xml) }.to raise_error Discovery::InvalidData
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails if the document contains a malformed webfinger url" do
|
it "fails if the document contains a malformed webfinger url" do
|
||||||
|
|
@ -69,11 +69,11 @@ XML
|
||||||
<Link rel="lrdd" type="application/xrd+xml" template="#{base_url}webfinger?q="/>
|
<Link rel="lrdd" type="application/xrd+xml" template="#{base_url}webfinger?q="/>
|
||||||
</XRD>
|
</XRD>
|
||||||
XML
|
XML
|
||||||
expect { WebFinger::HostMeta.from_xml(invalid_xml) }.to raise_error WebFinger::InvalidData
|
expect { Discovery::HostMeta.from_xml(invalid_xml) }.to raise_error Discovery::InvalidData
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails if the document is invalid" do
|
it "fails if the document is invalid" do
|
||||||
expect { WebFinger::HostMeta.from_xml("") }.to raise_error WebFinger::InvalidDocument
|
expect { Discovery::HostMeta.from_xml("") }.to raise_error Discovery::InvalidDocument
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
describe WebFinger::WebFinger do
|
describe Discovery::WebFinger do
|
||||||
let(:person) { FactoryGirl.create(:person) }
|
let(:person) { FactoryGirl.create(:person) }
|
||||||
let(:acct) { "acct:#{person.diaspora_handle}" }
|
let(:acct) { "acct:#{person.diaspora_handle}" }
|
||||||
let(:public_key_base64) { Base64.strict_encode64(person.serialized_public_key) }
|
let(:public_key_base64) { Base64.strict_encode64(person.serialized_public_key) }
|
||||||
|
|
@ -22,12 +22,12 @@ XML
|
||||||
}
|
}
|
||||||
|
|
||||||
it "must not create blank instances" do
|
it "must not create blank instances" do
|
||||||
expect { WebFinger::WebFinger.new({}) }.to raise_error ArgumentError
|
expect { Discovery::WebFinger.new({}) }.to raise_error ArgumentError
|
||||||
end
|
end
|
||||||
|
|
||||||
context "generation" do
|
context "generation" do
|
||||||
it "creates a nice XML document" do
|
it "creates a nice XML document" do
|
||||||
wf = WebFinger::WebFinger.new(
|
wf = Discovery::WebFinger.new(
|
||||||
acct_uri: "acct:#{person.diaspora_handle}",
|
acct_uri: "acct:#{person.diaspora_handle}",
|
||||||
alias_url: person.alias_url,
|
alias_url: person.alias_url,
|
||||||
hcard_url: person.hcard_url,
|
hcard_url: person.hcard_url,
|
||||||
|
|
@ -42,13 +42,13 @@ XML
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails if nil was given" do
|
it "fails if nil was given" do
|
||||||
expect { WebFinger::WebFinger.new(nil) }.to raise_error ArgumentError, "expected a Hash"
|
expect { Discovery::WebFinger.new(nil) }.to raise_error ArgumentError, "expected a Hash"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "parsing" do
|
context "parsing" do
|
||||||
it "reads its own output" do
|
it "reads its own output" do
|
||||||
wf = WebFinger::WebFinger.from_xml(xml)
|
wf = Discovery::WebFinger.from_xml(xml)
|
||||||
expect(wf.acct_uri).to eq(acct)
|
expect(wf.acct_uri).to eq(acct)
|
||||||
expect(wf.alias_url).to eq(person.alias_url)
|
expect(wf.alias_url).to eq(person.alias_url)
|
||||||
expect(wf.hcard_url).to eq(person.hcard_url)
|
expect(wf.hcard_url).to eq(person.hcard_url)
|
||||||
|
|
@ -62,7 +62,7 @@ XML
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is frozen after parsing" do
|
it "is frozen after parsing" do
|
||||||
wf = WebFinger::WebFinger.from_xml(xml)
|
wf = Discovery::WebFinger.from_xml(xml)
|
||||||
expect(wf).to be_frozen
|
expect(wf).to be_frozen
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -84,7 +84,7 @@ XML
|
||||||
</XRD>
|
</XRD>
|
||||||
XML
|
XML
|
||||||
|
|
||||||
wf = WebFinger::WebFinger.from_xml(historic_xml)
|
wf = Discovery::WebFinger.from_xml(historic_xml)
|
||||||
expect(wf.acct_uri).to eq(acct)
|
expect(wf.acct_uri).to eq(acct)
|
||||||
expect(wf.alias_url).to eq(person.alias_url)
|
expect(wf.alias_url).to eq(person.alias_url)
|
||||||
expect(wf.hcard_url).to eq(person.hcard_url)
|
expect(wf.hcard_url).to eq(person.hcard_url)
|
||||||
|
|
@ -103,11 +103,11 @@ XML
|
||||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||||
</XRD>
|
</XRD>
|
||||||
XML
|
XML
|
||||||
expect { WebFinger::WebFinger.from_xml(invalid_xml) }.to raise_error WebFinger::InvalidData
|
expect { Discovery::WebFinger.from_xml(invalid_xml) }.to raise_error Discovery::InvalidData
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails if the document is not XML" do
|
it "fails if the document is not XML" do
|
||||||
expect { WebFinger::WebFinger.from_xml("") }.to raise_error WebFinger::InvalidDocument
|
expect { Discovery::WebFinger.from_xml("") }.to raise_error Discovery::InvalidDocument
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
describe WebFinger::XrdDocument do
|
describe Discovery::XrdDocument do
|
||||||
let(:xml) {
|
let(:xml) {
|
||||||
<<XML
|
<<XML
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
@ -49,7 +49,7 @@ XML
|
||||||
|
|
||||||
context "generation" do
|
context "generation" do
|
||||||
it "creates the xml document" do
|
it "creates the xml document" do
|
||||||
doc = WebFinger::XrdDocument.new
|
doc = Discovery::XrdDocument.new
|
||||||
doc.expires = data[:expires]
|
doc.expires = data[:expires]
|
||||||
doc.subject = data[:subject]
|
doc.subject = data[:subject]
|
||||||
|
|
||||||
|
|
@ -71,16 +71,16 @@ XML
|
||||||
|
|
||||||
context "parsing" do
|
context "parsing" do
|
||||||
it "reads the xml document" do
|
it "reads the xml document" do
|
||||||
doc = WebFinger::XrdDocument.xml_data(xml)
|
doc = Discovery::XrdDocument.xml_data(xml)
|
||||||
expect(doc).to eq(data)
|
expect(doc).to eq(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises InvalidDocument if the xml is empty" do
|
it "raises InvalidDocument if the xml is empty" do
|
||||||
expect { WebFinger::XrdDocument.xml_data("") }.to raise_error WebFinger::InvalidDocument
|
expect { Discovery::XrdDocument.xml_data("") }.to raise_error Discovery::InvalidDocument
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises InvalidDocument if the xml is no XRD document" do
|
it "raises InvalidDocument if the xml is no XRD document" do
|
||||||
expect { WebFinger::XrdDocument.xml_data("<html></html>") }.to raise_error WebFinger::InvalidDocument
|
expect { Discovery::XrdDocument.xml_data("<html></html>") }.to raise_error Discovery::InvalidDocument
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
require "diaspora_federation/web_finger"
|
require "diaspora_federation/discovery"
|
||||||
|
|
||||||
# configure the federation engine
|
# configure the federation engine
|
||||||
DiasporaFederation.configure do |config|
|
DiasporaFederation.configure do |config|
|
||||||
|
|
@ -9,7 +9,7 @@ DiasporaFederation.configure do |config|
|
||||||
on :person_webfinger_fetch do |handle|
|
on :person_webfinger_fetch do |handle|
|
||||||
person = Person.find_by(diaspora_handle: handle)
|
person = Person.find_by(diaspora_handle: handle)
|
||||||
if person
|
if person
|
||||||
DiasporaFederation::WebFinger::WebFinger.new(
|
DiasporaFederation::Discovery::WebFinger.new(
|
||||||
acct_uri: "acct:#{person.diaspora_handle}",
|
acct_uri: "acct:#{person.diaspora_handle}",
|
||||||
alias_url: person.alias_url,
|
alias_url: person.alias_url,
|
||||||
hcard_url: person.hcard_url,
|
hcard_url: person.hcard_url,
|
||||||
|
|
@ -26,7 +26,7 @@ DiasporaFederation.configure do |config|
|
||||||
on :person_hcard_fetch do |guid|
|
on :person_hcard_fetch do |guid|
|
||||||
person = Person.find_by(guid: guid)
|
person = Person.find_by(guid: guid)
|
||||||
if person
|
if person
|
||||||
DiasporaFederation::WebFinger::HCard.new(
|
DiasporaFederation::Discovery::HCard.new(
|
||||||
guid: person.guid,
|
guid: person.guid,
|
||||||
nickname: person.nickname,
|
nickname: person.nickname,
|
||||||
full_name: person.full_name,
|
full_name: person.full_name,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue