incubator-heraldry-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?view=rev&rev=493380
Log:
[python-to-heraldry @ Added claimed_id to the consumer's checkid_* request]
Started adding tests for the form of a request

Original author: Josh Hoyt <josh@janrain.com>
Date: 2006-12-27 18:32:55+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=493380&r1=493379&r2=493380
==============================================================================
--- 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:26 2007
@@ -1173,11 +1173,16 @@
                 # This will never happen when we're in compatibility
                 # mode, as long as isOPIdentifier() returns False
                 # whenever preferredNamespace() returns OPENID1_NS.
-                request_identity = IDENTIFIER_SELECT
+                claimed_id = request_identity = IDENTIFIER_SELECT
             else:
                 request_identity = self.endpoint.getLocalID()
+                claimed_id = self.endpoint.claimed_id
 
+            # This is true for both OpenID 1 and 2
             message.setArg(OPENID_NS, 'identity', request_identity)
+
+            if message.isOpenID2():
+                message.setArg(OPENID2_NS, 'claimed_id', claimed_id)
 
         if self.assoc:
             message.setArg(OPENID_NS, 'assoc_handle', self.assoc.handle)

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=493380&r1=493379&r2=493380
==============================================================================
--- 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:26 2007
@@ -30,6 +30,7 @@
     def setUp(self):
         self.endpoint = DummyEndpoint()
         self.endpoint.local_id = 'http://server.unittest/joe'
+        self.endpoint.claimed_id = 'http://joe.vanity.example/'
         self.endpoint.server_url = 'http://server.unittest/'
         self.endpoint.preferred_namespace = self.preferred_namespace
         self.realm = 'http://example/'
@@ -38,9 +39,27 @@
         self.authreq = consumer.AuthRequest(self.endpoint, self.assoc)
 
     def failUnlessAnonymous(self, msg):
-        self.failUnlessEqual(
-            None, msg.getArg(message.OPENID_NS, 'identity'),
-            'unwanted openid.identity arg appeared in %r' % (msg,))
+        for key in ['claimed_id', 'identity']:
+            self.failUnlessEqual(
+                None, msg.getArg(message.OPENID_NS, key),
+                'unwanted openid.%s arg appeared in %r' % (msg, key))
+
+    def failUnlessOpenIDValueEquals(self, msg, key, expected, ns=None):
+        if ns is None:
+            ns = OPENID_NS
+
+        actual = msg.getKey(ns, key)
+        error_format = 'Wrong value for openid.%s: expected=%s, actual=%s'
+        error_message = error_format %  % (key, expected, actual))
+        self.failUnlessEqual(expected, actual, error_message)
+
+    def failIfOpenIDKeyExists(self, msg, key, ns=None):
+        if ns is None:
+            ns = OPENID_NS
+
+        actual = msg.getKey(ns, key)
+        error_message = 'openid.%s unexpectedly present: %s' % (key, actual)
+        self.failIf(actual is not None, error_message)
 
     def test_justConstruct(self):
         """Make sure that the internal state of the AuthRequest
@@ -68,6 +87,15 @@
 class TestAuthRequestOpenID2(TestAuthRequestBase, unittest.TestCase):
     preferred_namespace = message.OPENID2_NS
 
+    def failUnlessHasIdentifiers(self, msg, op_specific_id, claimed_id):
+        self.failUnlessOpenIDValueEquals(msg, 'identity', op_specific_id)
+        self.failUnlessOpenIDValueEquals(msg, 'claimed_id', claimed_id)
+
+    def test_standard(self):
+        msg = self.authreq.getMessage(self.realm, self.return_to)
+        self.failUnlessHasIdentifiers(
+            msg, self.endpoint.local_id, self.endpoint.claimed_id)
+
     def test_setAnonymousWorksForOpenID2(self):
         """OpenID AuthRequests should be able to set 'anonymous' to true."""
         self.failUnless(self.authreq.message.isOpenID2())
@@ -88,8 +116,8 @@
     def test_opIdentifierSendsIdentifierSelect(self):
         self.endpoint.is_op_identifier = True
         msg = self.authreq.getMessage(self.realm, self.return_to)
-        self.failUnlessEqual(message.IDENTIFIER_SELECT,
-                             msg.getArg(message.OPENID2_NS, 'identity'))
+        self.failUnlessHasIdentifiers(
+            msg, message.IDENTIFIER_SELECT, message.IDENTIFIER_SELECT)
 
     def test_realm(self):
         msg = self.authreq.getMessage(self.realm, self.return_to)



Mime
View raw message