Skip to content

Commit f305567

Browse files
author
Kevin Turner
committed
[project @ test.test_consumer.TestDiscoveryVerification: fix OPENID2_NS/TYPE confusion]
These tests were still passing, but they were passing because failUnlessRaises(ProtocolError) was too broad.
1 parent f479ce5 commit f305567

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

‎openid/test/test_consumer.py‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,26 +1620,33 @@ def test_theGoodStuff(self):
16201620
def test_otherServer(self):
16211621
# a set of things without the stuff
16221622
endpoint = OpenIDServiceEndpoint()
1623-
endpoint.type_uris = [OPENID2_NS]
1623+
endpoint.type_uris = [OPENID_2_0_TYPE]
16241624
endpoint.claimed_id = self.identifier
16251625
endpoint.server_url = "http://the-MOON.unittest/"
16261626
endpoint.local_id = self.identifier
16271627
self.services = [endpoint]
1628-
self.failUnlessRaises(ProtocolError,
1629-
self.consumer._verifyDiscoveryResults,
1630-
self.message, endpoint)
1631-
1628+
try:
1629+
r = self.consumer._verifyDiscoveryResults(self.message, endpoint)
1630+
except ProtocolError, e:
1631+
# Should we make more ProtocolError subclasses?
1632+
self.failUnless('OP Endpoint mismatch' in str(e), e)
1633+
else:
1634+
self.fail("expected ProtocolError, %r returned." % (r,))
1635+
16321636

16331637
def test_foreignDelegate(self):
16341638
# a set of things with the server stuff but other delegate
16351639
endpoint = OpenIDServiceEndpoint()
1636-
endpoint.type_uris = [OPENID2_NS]
1640+
endpoint.type_uris = [OPENID_2_0_TYPE]
16371641
endpoint.claimed_id = self.identifier
16381642
endpoint.server_url = self.server_url
16391643
endpoint.local_id = "http://unittest/juan-carlos"
1640-
self.failUnlessRaises(ProtocolError,
1641-
self.consumer._verifyDiscoveryResults,
1642-
self.message, endpoint)
1644+
try:
1645+
r = self.consumer._verifyDiscoveryResults(self.message, endpoint)
1646+
except ProtocolError, e:
1647+
self.failUnless('local_id mismatch' in str(e), e)
1648+
else:
1649+
self.fail("expected ProtocolError, %r returned." % (r,))
16431650

16441651

16451652
def test_nothingDiscovered(self):

0 commit comments

Comments
 (0)