diff --git a/lib/diaspora_federation/web_finger.rb b/lib/diaspora_federation/web_finger.rb
index 1012dae..e658e0a 100644
--- a/lib/diaspora_federation/web_finger.rb
+++ b/lib/diaspora_federation/web_finger.rb
@@ -7,5 +7,6 @@ module DiasporaFederation
end
end
+require "diaspora_federation/webfinger/exceptions"
require "diaspora_federation/webfinger/xrd_document"
require "diaspora_federation/webfinger/host_meta"
diff --git a/lib/diaspora_federation/webfinger/exceptions.rb b/lib/diaspora_federation/webfinger/exceptions.rb
new file mode 100644
index 0000000..9e21972
--- /dev/null
+++ b/lib/diaspora_federation/webfinger/exceptions.rb
@@ -0,0 +1,17 @@
+module DiasporaFederation
+ module WebFinger
+ ##
+ # Raised, if the XML structure is invalid
+ class InvalidDocument < RuntimeError
+ end
+
+ ##
+ # Raised, if something is wrong with the webfinger data
+ #
+ # * if the +webfinger_url+ is missing or malformed in {HostMeta.from_base_url} or {HostMeta.from_xml}
+ # * if the +data+ given to {WebFinger.from_account} is an invalid type or doesn't contain all required entries
+ # * if the parsed XML from {WebFinger.from_xml} is incomplete
+ class InvalidData < RuntimeError
+ end
+ end
+end
diff --git a/lib/diaspora_federation/webfinger/host_meta.rb b/lib/diaspora_federation/webfinger/host_meta.rb
index 525d8bb..f990cd1 100644
--- a/lib/diaspora_federation/webfinger/host_meta.rb
+++ b/lib/diaspora_federation/webfinger/host_meta.rb
@@ -77,6 +77,8 @@ module DiasporaFederation
hm
end
+ private
+
##
# Applies some basic sanity-checking to the given URL
# @param [String] url validation subject
@@ -84,7 +86,6 @@ module DiasporaFederation
def self.webfinger_url_valid?(url)
!url.nil? && url.instance_of?(String) && url =~ %r{^https?:\/\/.*\{uri\}}i
end
- private_class_method :webfinger_url_valid?
##
# Gets the webfinger url from an XRD data structure
@@ -94,11 +95,6 @@ module DiasporaFederation
link = data[:links].find {|l| (l[:rel] == "lrdd" && l[:type] == "application/xrd+xml") }
return link[:template] unless link.nil?
end
- private_class_method :webfinger_url_from_xrd
-
- # Raised, if the +webfinger_url+ is missing or malformed
- class InvalidData < RuntimeError
- end
end
end
end
diff --git a/lib/diaspora_federation/webfinger/xrd_document.rb b/lib/diaspora_federation/webfinger/xrd_document.rb
index 9c8d949..081d69c 100644
--- a/lib/diaspora_federation/webfinger/xrd_document.rb
+++ b/lib/diaspora_federation/webfinger/xrd_document.rb
@@ -165,10 +165,6 @@ module DiasporaFederation
end
data[:links] = links unless links.empty?
end
-
- # Raised, if the XML structure is invalid
- class InvalidDocument < RuntimeError
- end
end
end
end
diff --git a/spec/lib/webfinger/host_meta_spec.rb b/spec/lib/webfinger/host_meta_spec.rb
index 7fc74ca..90f78e0 100644
--- a/spec/lib/webfinger/host_meta_spec.rb
+++ b/spec/lib/webfinger/host_meta_spec.rb
@@ -24,7 +24,7 @@ XML
end
it "fails if the base_url was omitted" do
- expect { WebFinger::HostMeta.from_base_url("") }.to raise_error(WebFinger::HostMeta::InvalidData)
+ expect { WebFinger::HostMeta.from_base_url("") }.to raise_error(WebFinger::InvalidData)
end
end
@@ -57,7 +57,7 @@ XML
XML
- expect { WebFinger::HostMeta.from_xml(invalid_xml) }.to raise_error(WebFinger::HostMeta::InvalidData)
+ expect { WebFinger::HostMeta.from_xml(invalid_xml) }.to raise_error(WebFinger::InvalidData)
end
it "fails if the document contains a malformed webfinger url" do
@@ -67,11 +67,11 @@ XML
XML
- expect { WebFinger::HostMeta.from_xml(invalid_xml) }.to raise_error(WebFinger::HostMeta::InvalidData)
+ expect { WebFinger::HostMeta.from_xml(invalid_xml) }.to raise_error(WebFinger::InvalidData)
end
it "fails if the document is invalid" do
- expect { WebFinger::HostMeta.from_xml("") }.to raise_error(WebFinger::XrdDocument::InvalidDocument)
+ expect { WebFinger::HostMeta.from_xml("") }.to raise_error(WebFinger::InvalidDocument)
end
end
end