incubator-heraldry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ket...@apache.org
Subject svn commit: r493327 - in /incubator/heraldry/libraries/python/openid/trunk/openid: consumer/consumer.py consumer/discover.py test/test_consumer.py test/test_discover.py test/test_openidyadis.py
Date Sat, 06 Jan 2007 05:21:15 GMT
Author: keturn
Date: Fri Jan  5 21:21:14 2007
New Revision: 493327

URL: http://svn.apache.org/viewvc?view=rev&rev=493327
Log:
[python-to-heraldry @ Un-broke all tests for real this time]

Original author: cygnus@janrain.com
Date: 2006-12-19 00:38:14+00:00

Modified:
    incubator/heraldry/libraries/python/openid/trunk/openid/consumer/consumer.py
    incubator/heraldry/libraries/python/openid/trunk/openid/consumer/discover.py
    incubator/heraldry/libraries/python/openid/trunk/openid/test/test_consumer.py
    incubator/heraldry/libraries/python/openid/trunk/openid/test/test_discover.py
    incubator/heraldry/libraries/python/openid/trunk/openid/test/test_openidyadis.py

Modified: incubator/heraldry/libraries/python/openid/trunk/openid/consumer/consumer.py
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/python/openid/trunk/openid/consumer/consumer.py?view=diff&rev=493327&r1=493326&r2=493327
==============================================================================
--- incubator/heraldry/libraries/python/openid/trunk/openid/consumer/consumer.py (original)
+++ incubator/heraldry/libraries/python/openid/trunk/openid/consumer/consumer.py Fri Jan 
5 21:21:14 2007
@@ -554,7 +554,8 @@
         elif endpoint.getLocalID() != response_identity:
             fmt = 'Mismatch between delegate (%r) and server (%r) response'
             return FailureResponse(
-                endpoint, fmt % (endpoint.delegate, response_identity))
+                endpoint, fmt % (endpoint.getLocalID(),
+                                 response_identity))
 
         signed_fields = ['openid.' + f for f in signed_list]
         return SuccessResponse(endpoint, message, signed_fields)
@@ -651,6 +652,11 @@
             identifier = resp_msg.getArg(OPENID_NS, 'claimed_id')
         else:
             identifier = resp_msg.getArg(OPENID_NS, 'identity')
+
+        # Identifier absent, so return the original endpoint because
+        # we don't have any discovery'ing to do
+        if identifier is None:
+            return orig_endpoint
 
         # Pick the right discovery method.
         if xri.identifierScheme(identifier) == "XRI":

Modified: incubator/heraldry/libraries/python/openid/trunk/openid/consumer/discover.py
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/python/openid/trunk/openid/consumer/discover.py?view=diff&rev=493327&r1=493326&r2=493327
==============================================================================
--- incubator/heraldry/libraries/python/openid/trunk/openid/consumer/discover.py (original)
+++ incubator/heraldry/libraries/python/openid/trunk/openid/consumer/discover.py Fri Jan 
5 21:21:14 2007
@@ -126,7 +126,7 @@
 
             service = cls()
             service.claimed_id = uri
-            service.delegate = html_parse.findFirstHref(
+            service.local_id = html_parse.findFirstHref(
                 link_attrs, local_id_rel)
             service.server_url = op_endpoint_url
             service.type_uris = [type_uri]
@@ -201,7 +201,7 @@
 
         # Try to parse the response as HTML to get OpenID 1.0/1.1
         # <link rel="...">
-        openid_services = OpenIDServiceEndpoint.fromHTML(claimed_id, body)
+        openid_services = OpenIDServiceEndpoint.fromHTML(yadis_url, body)
 
     return (yadis_url, openid_services)
 

Modified: incubator/heraldry/libraries/python/openid/trunk/openid/test/test_consumer.py
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/python/openid/trunk/openid/test/test_consumer.py?view=diff&rev=493327&r1=493326&r2=493327
==============================================================================
--- incubator/heraldry/libraries/python/openid/trunk/openid/test/test_consumer.py (original)
+++ incubator/heraldry/libraries/python/openid/trunk/openid/test/test_consumer.py Fri Jan
 5 21:21:14 2007
@@ -141,7 +141,7 @@
     endpoint = OpenIDServiceEndpoint()
     endpoint.claimed_id = user_url
     endpoint.server_url = server_url
-    endpoint.delegate = delegate_url
+    endpoint.local_id = delegate_url
 
     fetcher = TestFetcher(None, None, assocs[0])
     fetchers.setDefaultFetcher(fetcher, wrap_exceptions=False)
@@ -267,7 +267,7 @@
         self.endpoint = OpenIDServiceEndpoint()
         self.endpoint.claimed_id = self.consumer_id = "consu"
         self.endpoint.server_url = self.server_url = "serlie"
-        self.endpoint.delegate = self.server_id = "sirod"
+        self.endpoint.local_id = self.server_id = "sirod"
 
 
 
@@ -421,18 +421,24 @@
         self.server_url = "http://idp.unittest/"
         CatchLogs.setUp(self)
 
+        claimed_id = 'bogus.claimed'
+
         self.message = Message.fromPostArgs(
             {'openid.mode': 'id_res',
              'openid.return_to': 'return_to (just anything)',
-             'openid.identity': 'something something',
+             'openid.identity': claimed_id,
              'openid.assoc_handle': 'does not matter',
              'openid.sig': GOODSIG,
              'openid.response_nonce': mkNonce(),
-             'openid.signed': 'identity,return_to,response_nonce',
+             'openid.signed': 'identity,return_to,response_nonce,assoc_handle,claimed_id',
+             'openid.claimed_id': claimed_id,
+             'openid.op_endpoint': self.server_url,
              'openid.ns':OPENID2_NS,
              })
+
         self.endpoint = OpenIDServiceEndpoint()
         self.endpoint.server_url = self.server_url
+        self.endpoint.claimed_id = claimed_id
 
     def tearDown(self):
         CatchLogs.tearDown(self)
@@ -443,7 +449,7 @@
             endpoint = OpenIDServiceEndpoint()
             endpoint.claimed_id = vid
             endpoint.server_url = surl
-            endpoint.delegate = vid
+            endpoint.local_id = vid
             return endpoint
 
         self.consumer._verifyDiscoveryResults = _vrfy
@@ -453,19 +459,33 @@
 
     def test_idResNoIdentity(self):
         self.message.delArg(OPENID_NS, 'identity')
-        self.message.setArg(OPENID_NS, 'signed', 'return_to,response_nonce')
+        self.message.delArg(OPENID_NS, 'claimed_id')
+        self.endpoint.claimed_id = None
+        self.message.setArg(OPENID_NS, 'signed', 'return_to,response_nonce,assoc_handle')
         r = self.consumer.complete(self.message, self.endpoint)
         self.failUnlessSuccess(r)
 
 
     def test_idResMissingIdentitySig(self):
-        self.message.setArg(OPENID_NS, 'signed', 'return_to,response_nonce')
+        self.message.setArg(OPENID_NS, 'signed', 'return_to,response_nonce,assoc_handle,claimed_id')
         r = self.consumer.complete(self.message, self.endpoint)
         self.failUnlessEqual(r.status, FAILURE)
 
 
     def test_idResMissingReturnToSig(self):
-        self.message.setArg(OPENID_NS, 'signed', 'identity,response_nonce')
+        self.message.setArg(OPENID_NS, 'signed', 'identity,response_nonce,assoc_handle,claimed_id')
+        r = self.consumer.complete(self.message, self.endpoint)
+        self.failUnlessEqual(r.status, FAILURE)
+
+
+    def test_idResMissingAssocHandleSig(self):
+        self.message.setArg(OPENID_NS, 'signed', 'identity,response_nonce,return_to,claimed_id')
+        r = self.consumer.complete(self.message, self.endpoint)
+        self.failUnlessEqual(r.status, FAILURE)
+
+
+    def test_idResMissingClaimedIDSig(self):
+        self.message.setArg(OPENID_NS, 'signed', 'identity,response_nonce,return_to,assoc_handle')
         r = self.consumer.complete(self.message, self.endpoint)
         self.failUnlessEqual(r.status, FAILURE)
 
@@ -911,7 +931,7 @@
 class TestAuthRequest(unittest.TestCase):
     def setUp(self):
         self.endpoint = OpenIDServiceEndpoint()
-        self.endpoint.delegate = 'http://server.unittest/joe'
+        self.endpoint.local_id = 'http://server.unittest/joe'
         self.endpoint.server_url = 'http://server.unittest/'
         self.assoc = self
         self.assoc.handle = 'assoc@handle'
@@ -933,7 +953,7 @@
                         'extension arg not found in %s' % (url,))
 
     def test_idpEndpoint(self):
-        self.endpoint.delegate = None
+        self.endpoint.local_id = None
         self.endpoint.claimed_id = None
         url = self.authreq.redirectURL('http://7.utest/', 'http://7.utest/r')
         _, qstring = url.split('?')
@@ -941,7 +961,7 @@
         self.failUnlessEqual(params['openid.identity'], IDENTIFIER_SELECT)
 
     def test_idpAnonymous(self):
-        self.endpoint.delegate = None
+        self.endpoint.local_id = None
         self.endpoint.claimed_id = None
         self.authreq.anonymous = True
         url = self.authreq.redirectURL('http://7.utest/', 'http://7.utest/r')
@@ -1233,7 +1253,7 @@
         endpoint = OpenIDServiceEndpoint()
         endpoint.claimed_id = identifier
         endpoint.server_url = self.endpoint.server_url
-        endpoint.delegate = identifier
+        endpoint.local_id = identifier
         iverified = []
         def verifyDiscoveryResults(identifier, server_url):
             iverified.append(endpoint)
@@ -1303,7 +1323,7 @@
         endpoint.type_uris = [OPENID2_NS]
         endpoint.claimed_id = self.identifier
         endpoint.server_url = self.server_url
-        endpoint.delegate = self.identifier
+        endpoint.local_id = self.identifier
         self.services = [endpoint]
         r = self.consumer._verifyDiscoveryResults(endpoint, self.message)
 
@@ -1315,7 +1335,7 @@
         endpoint = OpenIDServiceEndpoint()
         endpoint.claimed_id = self.identifier
         endpoint.server_url = "http://the-MOON.unittest/"
-        endpoint.delegate = self.identifier
+        endpoint.local_id = self.identifier
         self.services = [endpoint]
         self.failUnlessRaises(DiscoveryFailure,
                               self.consumer._verifyDiscoveryResults,
@@ -1327,7 +1347,7 @@
         endpoint = OpenIDServiceEndpoint()
         endpoint.claimed_id = self.identifier
         endpoint.server_url = self.server_url
-        endpoint.delegate = "http://unittest/juan-carlos"
+        endpoint.local_id = "http://unittest/juan-carlos"
         self.failUnlessRaises(DiscoveryFailure,
                               self.consumer._verifyDiscoveryResults,
                               endpoint, self.message)

Modified: incubator/heraldry/libraries/python/openid/trunk/openid/test/test_discover.py
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/python/openid/trunk/openid/test/test_discover.py?view=diff&rev=493327&r1=493326&r2=493327
==============================================================================
--- incubator/heraldry/libraries/python/openid/trunk/openid/test/test_discover.py (original)
+++ incubator/heraldry/libraries/python/openid/trunk/openid/test/test_discover.py Fri Jan
 5 21:21:14 2007
@@ -340,7 +340,7 @@
                              "More than one service in %r" % (services,))
         self.failUnlessEqual(services[0].server_url,
                              "http://www.myopenid.com/server")
-        self.failUnlessEqual(services[0].delegate,
+        self.failUnlessEqual(services[0].local_id,
                              "http://smoker.myopenid.com/")
         self.failUnlessEqual(services[0].claimed_id, self.id_url)
         self._notUsedYadis(services[0])
@@ -381,7 +381,7 @@
                              "More than one service in %r" % (services,))
         self.failUnlessEqual(services[0].server_url,
                              "http://www.myopenid.com/server")
-        self.failUnlessEqual(services[0].delegate,
+        self.failUnlessEqual(services[0].local_id,
                              "http://smoker.myopenid.com/")
         self.failUnlessEqual(services[0].claimed_id, expected_final_url)
         self._notUsedYadis(services[0])
@@ -418,9 +418,9 @@
                              "Not 1 service in %r" % (services,))
         self.failUnlessEqual(services[0].server_url,
                              "http://www.myopenid.com/server")
-        self.failUnless(services[0].delegate is None,
+        self.failUnless(services[0].local_id is None,
                         'Delegate should be None. Got %r' %
-                        (services[0].delegate,))
+                        (services[0].local_id,))
         self._usedYadis(services[0])
 
     def test_yadisIDP(self):
@@ -433,9 +433,9 @@
         self.failUnlessEqual(services[0].server_url,
                              "http://www.myopenid.com/server")
         self.failUnlessEqual(services[0].claimed_id, None)
-        self.failUnless(services[0].delegate is None,
+        self.failUnless(services[0].local_id is None,
                         'Delegate should be None. Got %r' %
-                        (services[0].delegate,))
+                        (services[0].local_id,))
         self._usedYadis(services[0])
 
     def test_yadisIDPdelegate(self):
@@ -449,9 +449,9 @@
         self.failUnlessEqual(services[0].server_url,
                              "http://www.myopenid.com/server")
         self.failUnlessEqual(services[0].claimed_id, None)
-        self.failUnless(services[0].delegate is None,
+        self.failUnless(services[0].local_id is None,
                         'Delegate should be None. Got %r' %
-                        (services[0].delegate,))
+                        (services[0].local_id,))
         self._usedYadis(services[0])
 
 
@@ -464,9 +464,9 @@
         self.failUnlessEqual(services[0].server_url,
                              "http://www.myopenid.com/server")
         self.failUnlessEqual(services[0].claimed_id, self.id_url)
-        self.failUnless(services[0].delegate is None,
+        self.failUnless(services[0].local_id is None,
                         'Delegate should be None. Got %r' %
-                        (services[0].delegate,))
+                        (services[0].local_id,))
 
         self._notUsedYadis(services[0])
 
@@ -480,7 +480,7 @@
                              "http://www.myopenid.com/server")
         self.failUnlessEqual(services[0].claimed_id, self.id_url)
         self.failUnlessEqual('http://smoker.myopenid.com/',
-                             services[0].delegate)
+                             services[0].local_id)
         self.failUnlessEqual([discover.OPENID_2_0_TYPE], services[0].type_uris)
         self._notUsedYadis(services[0])
         self.failUnlessEqual(1, len(services))
@@ -495,7 +495,7 @@
                              "http://www.myopenid.com/server")
         self.failUnlessEqual(services[0].claimed_id, self.id_url)
         self.failUnlessEqual('http://smoker.myopenid.com/',
-                             services[0].delegate)
+                             services[0].local_id)
         self.failUnlessEqual([discover.OPENID_1_1_TYPE], services[0].type_uris)
         self._notUsedYadis(services[0])
         self.failUnlessEqual(1, len(services))
@@ -514,7 +514,7 @@
                              "http://www.myopenid.com/server")
         self.failUnlessEqual(services[1].claimed_id, self.id_url)
         self.failUnlessEqual('http://smoker.myopenid.com/',
-                             services[1].delegate)
+                             services[1].local_id)
         self.failUnlessEqual([discover.OPENID_2_0_TYPE], services[1].type_uris)
         self._notUsedYadis(services[1])
 
@@ -523,7 +523,7 @@
                              "http://www.myopenid.com/server")
         self.failUnlessEqual(services[0].claimed_id, self.id_url)
         self.failUnlessEqual('http://smoker.myopenid.com/',
-                             services[0].delegate)
+                             services[0].local_id)
         self.failUnlessEqual([discover.OPENID_1_1_TYPE], services[0].type_uris)
         self._notUsedYadis(services[0])
 

Modified: incubator/heraldry/libraries/python/openid/trunk/openid/test/test_openidyadis.py
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/python/openid/trunk/openid/test/test_openidyadis.py?view=diff&rev=493327&r1=493326&r2=493327
==============================================================================
--- incubator/heraldry/libraries/python/openid/trunk/openid/test/test_openidyadis.py (original)
+++ incubator/heraldry/libraries/python/openid/trunk/openid/test/test_openidyadis.py Fri Jan
 5 21:21:14 2007
@@ -19,7 +19,7 @@
 def mkXRDS(services):
     return XRDS_BOILERPLATE % (services,)
 
-def mkService(uris=None, type_uris=None, delegate=None, dent='        '):
+def mkService(uris=None, type_uris=None, local_id=None, dent='        '):
     chunks = [dent, '<Service>\n']
     dent2 = dent + '    '
     if type_uris:
@@ -38,9 +38,9 @@
                 chunks.extend([' priority="', str(prio), '"'])
             chunks.extend(['>', uri, '</URI>\n'])
 
-    if delegate:
+    if local_id:
         chunks.extend(
-            [dent2, '<openid:Delegate>', delegate, '</openid:Delegate>\n'])
+            [dent2, '<openid:Delegate>', local_id, '</openid:Delegate>\n'])
 
     chunks.extend([dent, '</Service>\n'])
 
@@ -85,7 +85,7 @@
     ]
 
 # Range of valid Delegate tag values for generating test data
-delegate_options = [
+local_id_options = [
     None,
     'http://vanity.domain/',
     'https://somewhere/yadis/',
@@ -93,18 +93,18 @@
 
 # All combinations of valid URIs, Type URIs and Delegate tags
 data = [
-    (uris, type_uris, delegate)
+    (uris, type_uris, local_id)
     for uris in server_url_options
     for type_uris in type_uri_options
-    for delegate in delegate_options
+    for local_id in local_id_options
     ]
 
 class OpenIDYadisTest(unittest.TestCase):
-    def __init__(self, uris, type_uris, delegate):
+    def __init__(self, uris, type_uris, local_id):
         unittest.TestCase.__init__(self)
         self.uris = uris
         self.type_uris = type_uris
-        self.delegate = delegate
+        self.local_id = local_id
 
     def shortDescription(self):
         # XXX:
@@ -116,7 +116,7 @@
         # Create an XRDS document to parse
         services = mkService(uris=self.uris,
                              type_uris=self.type_uris,
-                             delegate=self.delegate)
+                             local_id=self.local_id)
         self.xrds = mkXRDS(services)
 
     def runTest(self):
@@ -140,8 +140,8 @@
             # All endpoints will have same yadis_url
             self.failUnlessEqual(self.yadis_url, endpoint.claimed_id)
 
-            # and delegate
-            self.failUnlessEqual(self.delegate, endpoint.delegate)
+            # and local_id
+            self.failUnlessEqual(self.local_id, endpoint.local_id)
 
             # and types
             actual_types = list(endpoint.type_uris)



Mime
View raw message