Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

… OpenID 2 spec]
  • Loading branch information...
commit dba285c1eb1997b10e9d74f15ba8b25bc0f6a21b 1 parent 81a4d2f
tailor authored
Showing with 32 additions and 0 deletions.
  1. +7 −0 openid/consumer/discover.py
  2. +25 −0 openid/test/test_discover.py
View
7 openid/consumer/discover.py
@@ -309,6 +309,12 @@ def normalizeURL(url):
else:
return urlparse.urldefrag(normalized)[0]
+def normalizeXRI(xri):
+ """Normalize an XRI, stripping its scheme if present"""
+ if xri.startswith("xri://"):
+ xri = xri[6:]
+ return xri
+
def arrangeByType(service_list, preferred_types):
"""Rearrange service_list in a new list so services are ordered by
types listed in preferred_types. Return the new list."""
@@ -407,6 +413,7 @@ def discoverYadis(uri):
def discoverXRI(iname):
endpoints = []
+ iname = normalizeXRI(iname)
try:
canonicalID, services = xrires.ProxyResolver().query(
iname, OpenIDServiceEndpoint.openid_type_uris)
View
25 openid/test/test_discover.py
@@ -549,6 +549,31 @@ def test_xri(self):
display_identifier='=smoker'
)
+ def test_xri_normalize(self):
+ user_xri, services = discover.discoverXRI('xri://=smoker')
+
+ self._checkService(
+ services[0],
+ used_yadis=True,
+ types=['1.0'],
+ server_url="http://www.myopenid.com/server",
+ claimed_id=XRI("=!1000"),
+ canonical_id=XRI("=!1000"),
+ local_id='http://smoker.myopenid.com/',
+ display_identifier='=smoker'
+ )
+
+ self._checkService(
+ services[1],
+ used_yadis=True,
+ types=['1.0'],
+ server_url="http://www.livejournal.com/openid/server.bml",
+ claimed_id=XRI("=!1000"),
+ canonical_id=XRI("=!1000"),
+ local_id='http://frank.livejournal.com/',
+ display_identifier='=smoker'
+ )
+
def test_xriNoCanonicalID(self):
user_xri, services = discover.discoverXRI('=smoker*bad')
self.failIf(services)
Please sign in to comment.
Something went wrong with that request. Please try again.