Skip to content

Commit 15da557

Browse files
author
tailor
committed
[project @ Set display_identifier in discoverXRI, add tests]
1 parent 6fc69e2 commit 15da557

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎openid/consumer/discover.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ def discoverXRI(iname):
422422
# constructor instead of tacking it on after?
423423
endpoint.canonicalID = canonicalID
424424
endpoint.claimed_id = canonicalID
425+
endpoint.display_identifier = iname
425426

426427
# FIXME: returned xri should probably be in some normal form
427428
return iname, getOPOrUserServices(endpoints)

‎openid/test/test_discover.py‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ def _checkService(self, s,
172172
local_id=None,
173173
canonical_id=None,
174174
types=None,
175-
used_yadis=False
175+
used_yadis=False,
176+
display_identifier=None
176177
):
177178
self.failUnlessEqual(server_url, s.server_url)
178179
if types == ['2.0 OP']:
@@ -206,6 +207,14 @@ def _checkService(self, s,
206207
self.failUnlessEqual(type_uris, s.type_uris)
207208
self.failUnlessEqual(canonical_id, s.canonicalID)
208209

210+
if s.canonicalID:
211+
self.failUnless(s.getDisplayIdentifier() != claimed_id)
212+
self.failUnless(s.getDisplayIdentifier() is not None)
213+
214+
self.failUnlessEqual(s.claimed_id, s.canonicalID)
215+
216+
self.failUnlessEqual(s.display_identifier or s.claimed_id, s.getDisplayIdentifier())
217+
209218
def setUp(self):
210219
self.documents = self.documents.copy()
211220
self.fetcher = self.fetcherClass(self.documents)
@@ -270,6 +279,7 @@ def test_html1(self):
270279
server_url="http://www.myopenid.com/server",
271280
claimed_id=self.id_url,
272281
local_id='http://smoker.myopenid.com/',
282+
display_identifier=self.id_url,
273283
)
274284

275285
def test_html1Fragment(self):
@@ -293,6 +303,7 @@ def test_html1Fragment(self):
293303
server_url="http://www.myopenid.com/server",
294304
claimed_id=expected_id,
295305
local_id='http://smoker.myopenid.com/',
306+
display_identifier=expected_id,
296307
)
297308

298309
def test_html2(self):
@@ -309,6 +320,7 @@ def test_html2(self):
309320
server_url="http://www.myopenid.com/server",
310321
claimed_id=self.id_url,
311322
local_id='http://smoker.myopenid.com/',
323+
display_identifier=self.id_url,
312324
)
313325

314326
def test_html1And2(self):
@@ -326,6 +338,7 @@ def test_html1And2(self):
326338
server_url="http://www.myopenid.com/server",
327339
claimed_id=self.id_url,
328340
local_id='http://smoker.myopenid.com/',
341+
display_identifier=self.id_url,
329342
)
330343

331344
def test_yadisEmpty(self):
@@ -351,6 +364,7 @@ def test_htmlEmptyYadis(self):
351364
server_url="http://www.myopenid.com/server",
352365
claimed_id=self.id_url,
353366
local_id='http://smoker.myopenid.com/',
367+
display_identifier=self.id_url,
354368
)
355369

356370
def test_yadis1NoDelegate(self):
@@ -365,6 +379,7 @@ def test_yadis1NoDelegate(self):
365379
server_url="http://www.myopenid.com/server",
366380
claimed_id=self.id_url,
367381
local_id=self.id_url,
382+
display_identifier=self.id_url,
368383
)
369384

370385
def test_yadis2NoLocalID(self):
@@ -381,6 +396,7 @@ def test_yadis2NoLocalID(self):
381396
server_url="http://www.myopenid.com/server",
382397
claimed_id=self.id_url,
383398
local_id=self.id_url,
399+
display_identifier=self.id_url,
384400
)
385401

386402
def test_yadis2(self):
@@ -397,6 +413,7 @@ def test_yadis2(self):
397413
server_url="http://www.myopenid.com/server",
398414
claimed_id=self.id_url,
399415
local_id='http://smoker.myopenid.com/',
416+
display_identifier=self.id_url,
400417
)
401418

402419
def test_yadis2OP(self):
@@ -411,6 +428,7 @@ def test_yadis2OP(self):
411428
used_yadis=True,
412429
types=['2.0 OP'],
413430
server_url="http://www.myopenid.com/server",
431+
display_identifier=self.id_url,
414432
)
415433

416434
def test_yadis2OPDelegate(self):
@@ -426,6 +444,7 @@ def test_yadis2OPDelegate(self):
426444
used_yadis=True,
427445
types=['2.0 OP'],
428446
server_url="http://www.myopenid.com/server",
447+
display_identifier=self.id_url,
429448
)
430449

431450
def test_yadis2BadLocalID(self):
@@ -449,6 +468,7 @@ def test_yadis1And2(self):
449468
server_url="http://www.myopenid.com/server",
450469
claimed_id=self.id_url,
451470
local_id='http://smoker.myopenid.com/',
471+
display_identifier=self.id_url,
452472
)
453473

454474
def test_yadis1And2BadLocalID(self):
@@ -512,6 +532,7 @@ def test_xri(self):
512532
claimed_id=XRI("=!1000"),
513533
canonical_id=XRI("=!1000"),
514534
local_id='http://smoker.myopenid.com/',
535+
display_identifier='=smoker'
515536
)
516537

517538
self._checkService(
@@ -522,6 +543,7 @@ def test_xri(self):
522543
claimed_id=XRI("=!1000"),
523544
canonical_id=XRI("=!1000"),
524545
local_id='http://frank.livejournal.com/',
546+
display_identifier='=smoker'
525547
)
526548

527549
def test_xriNoCanonicalID(self):

0 commit comments

Comments
 (0)