incubator-heraldry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ket...@apache.org
Subject svn commit: r493374 - in /incubator/heraldry/libraries/python/openid/trunk/openid: consumer/consumer.py test/test_auth_request.py
Date Sat, 06 Jan 2007 05:26:01 GMT
Author: keturn
Date: Fri Jan  5 21:26:00 2007
New Revision: 493374

URL: http://svn.apache.org/viewvc?view=rev&rev=493374
Log:
[python-to-heraldry @ trust_root -> realm for OpenID2]

Original author: Josh Hoyt <josh@janrain.com>
Date: 2006-12-26 23:30:21+00:00

Modified:
    incubator/heraldry/libraries/python/openid/trunk/openid/consumer/consumer.py
    incubator/heraldry/libraries/python/openid/trunk/openid/test/test_auth_request.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=493374&r1=493373&r2=493374
==============================================================================
--- 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:26:00 2007
@@ -141,7 +141,7 @@
     C{L{redirectURL<AuthRequest.redirectURL>}} method on the
     C{L{AuthRequest}} object.  The parameter C{return_to} is the URL
     that the OpenID server will send the user back to after attempting
-    to verify his or her identity.  The C{trust_root} parameter is the
+    to verify his or her identity.  The C{realm} parameter is the
     URL (or URL pattern) that identifies your web site to the user
     when he or she is authorizing it.  Send a redirect to the
     resulting URL to the user's browser.
@@ -1102,7 +1102,10 @@
         """
         self.message.setArg(namespace, key, value)
 
-    def getMessage(self, trust_root, return_to, immediate=False):
+    def getMessage(self, realm, return_to, immediate=False):
+        """
+        @raises: ValueError if the request is marked
+        """
         return_to = oidutil.appendArgs(return_to, self.return_to_args)
 
         if immediate:
@@ -1111,11 +1114,17 @@
             mode = 'checkid_setup'
 
         message = self.message.copy()
+        if message.isOpenID1():
+            realm_key = 'trust_root'
+        else:
+            realm_key = 'realm'
+
         message.updateArgs(OPENID_NS,
-            {'mode':mode,
-             'return_to':return_to,
-             'trust_root':trust_root,
-             })
+            {
+            realm_key:realm,
+            'mode':mode,
+            'return_to':return_to,
+            })
 
         if not self._anonymous:
             if self.endpoint.isOPIdentifier():
@@ -1133,11 +1142,11 @@
 
         return message
 
-    def redirectURL(self, trust_root, return_to, immediate=False):
-        message = self.getMessage(trust_root, return_to, immediate)
+    def redirectURL(self, realm, return_to, immediate=False):
+        message = self.getMessage(realm, return_to, immediate)
         return message.toURL(self.endpoint.server_url)
 
-    def formMarkup(self, trust_root, return_to, immediate=False,
+    def formMarkup(self, realm, return_to, immediate=False,
             form_tag_attrs=None):
         """Get html for a form to submit this request to the IDP.
 
@@ -1147,7 +1156,7 @@
             'action' or 'method', it will be replaced.
         @type form_tag_attrs: {unicode: unicode}
         """
-        message = self.getMessage(trust_root, return_to, immediate)
+        message = self.getMessage(realm, return_to, immediate)
         return message.toFormMarkup(self.endpoint.server_url,
                     form_tag_attrs)
 

Modified: incubator/heraldry/libraries/python/openid/trunk/openid/test/test_auth_request.py
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/python/openid/trunk/openid/test/test_auth_request.py?view=diff&rev=493374&r1=493373&r2=493374
==============================================================================
--- incubator/heraldry/libraries/python/openid/trunk/openid/test/test_auth_request.py (original)
+++ incubator/heraldry/libraries/python/openid/trunk/openid/test/test_auth_request.py Fri
Jan  5 21:26:00 2007
@@ -91,6 +91,12 @@
         self.failUnlessEqual(message.IDENTIFIER_SELECT,
                              msg.getArg(message.OPENID2_NS, 'identity'))
 
+    def test_realm(self):
+        msg = self.authreq.getMessage(self.realm, self.return_to)
+        self.failIf(msg.getArg(message.OPENID2_NS, 'trust_root'))
+        self.failUnlessEqual(self.realm,
+                             msg.getArg(message.OPENID2_NS, 'realm'))
+
 class TestAuthRequestOpenID1(TestAuthRequestBase, unittest.TestCase):
     preferred_namespace = message.OPENID1_NS
 
@@ -114,6 +120,13 @@
         msg = self.authreq.getMessage(self.realm, self.return_to)
         self.failUnlessEqual(message.IDENTIFIER_SELECT,
                              msg.getArg(message.OPENID1_NS, 'identity'))
+
+    def test_trustRoot(self):
+        """Realm used to be called 'trust_root'"""
+        msg = self.authreq.getMessage(self.realm, self.return_to)
+        self.failIf(msg.getArg(message.OPENID1_NS, 'realm'))
+        self.failUnlessEqual(self.realm,
+                             msg.getArg(message.OPENID1_NS, 'trust_root'))
 
 if __name__ == '__main__':
     unittest.main()



Mime
View raw message