Skip to content
Browse files

[project @ Normalize XRIs when doing discovery in accordance with the…

… OpenID 2 spec]
  • Loading branch information...
1 parent 220bdb0 commit ccd6784ecb571b21ac9d203791c84a2f0f1202a2 tailor committed Dec 19, 2008
Showing with 30 additions and 0 deletions.
  1. +8 −0 lib/openid/consumer/discovery.rb
  2. +22 −0 test/test_discover.rb
View
8 lib/openid/consumer/discovery.rb
@@ -288,6 +288,13 @@ def self.find_op_local_identifier(service_element, type_uris)
return local_id
end
+ def self.normalize_xri(xri)
+ # Normalize an XRI, stripping its scheme if present
+ m = /^xri:\/\/(.*)/.match(xri)
+ xri = m[1] if m
+ return xri
+ end
+
def self.normalize_url(url)
# Normalize a URL, converting normalization failures to
# DiscoveryFailure
@@ -411,6 +418,7 @@ def self.discover_yadis(uri)
def self.discover_xri(iname)
endpoints = []
+ iname = self.normalize_xri(iname)
begin
canonical_id, services = Yadis::XRI::ProxyResolver.new().query(
View
22 test/test_discover.rb
@@ -571,6 +571,28 @@ def test_xri
'=smoker')
end
+ def test_xri_normalize
+ user_xri, services = OpenID.discover_xri('xri://=smoker')
+
+ _checkService(services[0],
+ "http://www.myopenid.com/server",
+ Yadis::XRI.make_xri("=!1000"),
+ 'http://smoker.myopenid.com/',
+ Yadis::XRI.make_xri("=!1000"),
+ ['1.0'],
+ true,
+ '=smoker')
+
+ _checkService(services[1],
+ "http://www.livejournal.com/openid/server.bml",
+ Yadis::XRI.make_xri("=!1000"),
+ 'http://frank.livejournal.com/',
+ Yadis::XRI.make_xri("=!1000"),
+ ['1.0'],
+ true,
+ '=smoker')
+ end
+
def test_xriNoCanonicalID
silence_logging {
user_xri, services = OpenID.discover_xri('=smoker*bad')

0 comments on commit ccd6784

Please sign in to comment.
Something went wrong with that request. Please try again.