incubator-heraldry-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?view=rev&rev=493408
Log:
[python-to-heraldry @ Look for openid.trust_root/realm based on OpenID version]

Original author: cygnus@janrain.com
Date: 2006-12-28 23:57:05+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=493408&r1=493407&r2=493408
==============================================================================
--- 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:33
2007
@@ -573,8 +573,13 @@
         # 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.
-        self.trust_root = message.getArg(
-            OPENID_NS, 'trust_root', self.return_to)
+        if self.namespace == OPENID1_NS:
+            self.trust_root = message.getArg(
+                OPENID_NS, 'trust_root', self.return_to)
+        else:
+            self.trust_root = message.getArg(
+                OPENID_NS, 'realm', self.return_to)
+
         self.assoc_handle = message.getArg(OPENID_NS, 'assoc_handle')
 
         # Using TrustRoot.parse here is a bit misleading, as we're not
@@ -721,7 +726,10 @@
              'identity': self.identity,
              'return_to': self.return_to}
         if self.trust_root:
-            q['trust_root'] = self.trust_root
+            if self.namespace == OPENID1_NS:
+                q['trust_root'] = self.trust_root
+            else:
+                q['realm'] = self.trust_root
         if self.assoc_handle:
             q['assoc_handle'] = self.assoc_handle
 

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=493408&r1=493407&r2=493408
==============================================================================
--- 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:33 2007
@@ -151,7 +151,7 @@
             'openid.mode': 'checkid_setup',
             'openid.assoc_handle': self.assoc_handle,
             'openid.return_to': self.rt_url,
-            'openid.trust_root': self.tr_url,
+            'openid.realm': self.tr_url,
             }
         r = self.decode(args)
         self.failUnless(isinstance(r, server.CheckIDRequest))
@@ -625,6 +625,34 @@
         self.failUnlessRaises(server.ProtocolError,
                               server.CheckIDRequest.fromMessage,
                               msg)
+
+    def test_trustRootOpenID1(self):
+        """Ignore openid.realm in OpenID 1"""
+        msg = Message(OPENID1_NS)
+        msg.setArg(OPENID_NS, 'mode', 'checkid_setup')
+        msg.setArg(OPENID_NS, 'trust_root', 'http://real_trust_root/')
+        msg.setArg(OPENID_NS, 'realm', 'http://fake_trust_root/')
+        msg.setArg(OPENID_NS, 'return_to', 'http://real_trust_root/foo')
+        msg.setArg(OPENID_NS, 'assoc_handle', 'bogus')
+        msg.setArg(OPENID_NS, 'identity', 'george')
+
+        result = server.CheckIDRequest.fromMessage(msg)
+
+        self.failUnless(result.trust_root == 'http://real_trust_root/')
+
+    def test_trustRootOpenID2(self):
+        """Ignore openid.trust_root in OpenID 2"""
+        msg = Message(OPENID2_NS)
+        msg.setArg(OPENID_NS, 'mode', 'checkid_setup')
+        msg.setArg(OPENID_NS, 'realm', 'http://real_trust_root/')
+        msg.setArg(OPENID_NS, 'trust_root', 'http://fake_trust_root/')
+        msg.setArg(OPENID_NS, 'return_to', 'http://real_trust_root/foo')
+        msg.setArg(OPENID_NS, 'assoc_handle', 'bogus')
+        msg.setArg(OPENID_NS, 'identity', 'george')
+
+        result = server.CheckIDRequest.fromMessage(msg)
+
+        self.failUnless(result.trust_root == 'http://real_trust_root/')
 
     def test_answerAllowNoTrustRoot(self):
         self.request.trust_root = None



Mime
View raw message