incubator-heraldry-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?view=rev&rev=493353
Log:
[python-to-heraldry @ When making a compatibility-mode no-encryption association request,
don't send session_type.]

Original author: Josh Hoyt <josh@janrain.com>
Date: 2006-12-21 01:21:25+00:00

Modified:
    incubator/heraldry/libraries/python/openid/trunk/openid/consumer/consumer.py
    incubator/heraldry/libraries/python/openid/trunk/openid/test/test_consumer.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=493353&r1=493352&r2=493353
==============================================================================
--- 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:24:16 2007
@@ -819,7 +819,10 @@
         if not endpoint.compatibilityMode():
             args['openid.ns'] = OPENID2_NS
 
-        if assoc_session.session_type != 'no-encryption':
+        # Leave out the session type if we're in compatibility mode
+        # *and* it's no-encryption.
+        if (not endpoint.compatibilityMode() or
+            assoc_session.session_type != 'no-encryption'):
             args['openid.session_type'] = assoc_session.session_type
 
         args.update(assoc_session.getRequest())

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=493353&r1=493352&r2=493353
==============================================================================
--- 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:24:16 2007
@@ -10,7 +10,7 @@
 from openid.consumer.consumer import \
      AuthRequest, GenericConsumer, SUCCESS, FAILURE, CANCEL, SETUP_NEEDED, \
      SuccessResponse, FailureResponse, SetupNeededResponse, CancelResponse, \
-     DiffieHellmanSHA1ConsumerSession, Consumer
+     DiffieHellmanSHA1ConsumerSession, Consumer, PlainTextConsumerSession
 from openid import association
 from openid.server.server import \
      PlainTextServerSession, DiffieHellmanSHA1ServerSession
@@ -1380,6 +1380,62 @@
         return identifier, self.services
 
 
+class TestCreateAssociationRequest(unittest.TestCase):
+    def setUp(self):
+        class DummyEndpoint(object):
+            use_compatibility = False
+
+            def compatibilityMode(self):
+                return self.use_compatibility
+
+        self.endpoint = DummyEndpoint()
+        self.consumer = GenericConsumer(store=None)
+        self.assoc_type = 'HMAC-SHA1'
+
+    def test_noEncryptionSendsType(self):
+        session_type = 'no-encryption'
+        session, args = self.consumer._createAssociateRequest(
+            self.endpoint, self.assoc_type, session_type)
+
+        self.failUnless(isinstance(session, PlainTextConsumerSession))
+        self.failUnlessEqual({'openid.ns':OPENID2_NS,
+                              'openid.session_type':session_type,
+                              'openid.mode':'associate',
+                              'openid.assoc_type':self.assoc_type,
+                              }, args)
+
+    def test_noEncryptionCompatibility(self):
+        self.endpoint.use_compatibility = True
+        session_type = 'no-encryption'
+        session, args = self.consumer._createAssociateRequest(
+            self.endpoint, self.assoc_type, session_type)
+
+        self.failUnless(isinstance(session, PlainTextConsumerSession))
+        self.failUnlessEqual({'openid.mode':'associate',
+                              'openid.assoc_type':self.assoc_type,
+                              }, args)
+
+    def test_dhSHA1Compatibility(self):
+        self.endpoint.use_compatibility = True
+        session_type = 'DH-SHA1'
+        session, args = self.consumer._createAssociateRequest(
+            self.endpoint, self.assoc_type, session_type)
+
+        self.failUnless(isinstance(session, DiffieHellmanSHA1ConsumerSession))
+
+        # This is a random base-64 value, so just check that it's
+        # present.
+        self.failUnless(args['openid.dh_consumer_public'])
+        del args['openid.dh_consumer_public']
+
+        # OK, session_type is set here and not for no-encryption
+        # compatibility
+        self.failUnlessEqual({'openid.mode':'associate',
+                              'openid.session_type':'DH-SHA1',
+                              'openid.assoc_type':self.assoc_type,
+                              }, args)
+
+    # XXX: test the other types
 
 if __name__ == '__main__':
     unittest.main()



Mime
View raw message