incubator-heraldry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ket...@apache.org
Subject svn commit: r493404 - in /incubator/heraldry/libraries/python/openid/trunk/openid: server/server.py test/test_server.py
Date Sat, 06 Jan 2007 05:28:16 GMT
Author: keturn
Date: Fri Jan  5 21:28:16 2007
New Revision: 493404

URL: http://svn.apache.org/viewvc?view=rev&rev=493404
Log:
[python-to-heraldry @ Fix #1611: Server does not accept OpenID1 checkid_* without identity,
and requires identity to be present in response]

Original author: cygnus@janrain.com
Date: 2006-12-28 01:20:26+00:00

Modified:
    incubator/heraldry/libraries/python/openid/trunk/openid/server/server.py
    incubator/heraldry/libraries/python/openid/trunk/openid/test/test_server.py

Modified: incubator/heraldry/libraries/python/openid/trunk/openid/server/server.py
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/python/openid/trunk/openid/server/server.py?view=diff&rev=493404&r1=493403&r2=493404
==============================================================================
--- incubator/heraldry/libraries/python/openid/trunk/openid/server/server.py (original)
+++ incubator/heraldry/libraries/python/openid/trunk/openid/server/server.py Fri Jan  5 21:28:16
2007
@@ -105,7 +105,8 @@
 from openid.store.nonce import mkNonce
 from openid.server.trustroot import TrustRoot
 from openid.association import Association, default_negotiator, getSecretSize
-from openid.message import Message, OPENID_NS, OPENID2_NS, IDENTIFIER_SELECT
+from openid.message import Message, OPENID_NS, OPENID1_NS, \
+     OPENID2_NS, IDENTIFIER_SELECT
 
 HTTP_OK = 200
 HTTP_REDIRECT = 302
@@ -550,6 +551,10 @@
 
         self.identity = message.getArg(OPENID_NS, 'identity')
 
+        if self.identity is None and self.namespace == OPENID1_NS:
+            s = "OpenID 1 message did not contain openid.identity"
+            raise ProtocolError(message, text=s)
+
         # There's a case for making self.trust_root be a TrustRoot
         # here.  But if TrustRoot isn't currently part of the "public" API,
         # I'm not sure it's worth doing.
@@ -653,6 +658,12 @@
                         "This request specified no identity and you "
                         "supplied %r" % (identity,))
                 response_identity = None
+
+            if self.namespace == OPENID1_NS and response_identity is None:
+                raise ValueError(
+                    "Request was an OpenID 1 request, so response must "
+                    "include an identifier."
+                    )
 
             response.fields.updateArgs(OPENID_NS, {
                 'mode': mode,

Modified: incubator/heraldry/libraries/python/openid/trunk/openid/test/test_server.py
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/python/openid/trunk/openid/test/test_server.py?view=diff&rev=493404&r1=493403&r2=493404
==============================================================================
--- incubator/heraldry/libraries/python/openid/trunk/openid/test/test_server.py (original)
+++ incubator/heraldry/libraries/python/openid/trunk/openid/test/test_server.py Fri Jan  5
21:28:16 2007
@@ -145,8 +145,9 @@
         self.failUnlessEqual(r.trust_root, self.tr_url)
         self.failUnlessEqual(r.return_to, self.rt_url)
 
-    def test_checkidSetupNoIdentity(self):
+    def test_checkidSetupNoIdentityOpenID2(self):
         args = {
+            'openid.ns': OPENID2_NS,
             'openid.mode': 'checkid_setup',
             'openid.assoc_handle': self.assoc_handle,
             'openid.return_to': self.rt_url,
@@ -603,6 +604,23 @@
     def test_answerAllowWithAnotherIdentity(self):
         self.failUnlessRaises(ValueError, self.request.answer, True,
                               identity="http://pebbles.unittest/")
+
+    def test_answerAllowNoIdentityOpenID1(self):
+        self.request.namespace = OPENID1_NS
+        self.request.identity = None
+        self.failUnlessRaises(ValueError, self.request.answer, True,
+                              identity=None)
+
+    def test_checkIDWithNoIdentityOpenID1(self):
+        msg = Message(OPENID1_NS)
+        msg.setArg(OPENID_NS, 'return_to', 'bogus')
+        msg.setArg(OPENID_NS, 'trust_root', 'bogus')
+        msg.setArg(OPENID_NS, 'mode', 'checkid_setup')
+        msg.setArg(OPENID_NS, 'assoc_handle', 'bogus')
+
+        self.failUnlessRaises(server.ProtocolError,
+                              server.CheckIDRequest.fromMessage,
+                              msg)
 
     def test_answerAllowNoTrustRoot(self):
         self.request.trust_root = None



Mime
View raw message