[CalendarServer-changes] [10633] CalendarServer/branches/users/glyph/digest-auth-redux

source_changes at macosforge.org source_changes at macosforge.org
Fri Feb 1 15:53:32 PST 2013


Revision: 10633
          http://trac.calendarserver.org//changeset/10633
Author:   glyph at apple.com
Date:     2013-02-01 15:53:32 -0800 (Fri, 01 Feb 2013)
Log Message:
-----------
Refer to the nonce by constant value rather than by the generation method (which ought to have different results each time anyway).  More hygienically patch the time value used to calculate timeouts.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/digest-auth-redux/twistedcaldav/directory/test/test_digest.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/digest-auth-redux/

Modified: CalendarServer/branches/users/glyph/digest-auth-redux/twistedcaldav/directory/test/test_digest.py
===================================================================
--- CalendarServer/branches/users/glyph/digest-auth-redux/twistedcaldav/directory/test/test_digest.py	2013-02-01 23:53:31 UTC (rev 10632)
+++ CalendarServer/branches/users/glyph/digest-auth-redux/twistedcaldav/directory/test/test_digest.py	2013-02-01 23:53:32 UTC (rev 10633)
@@ -31,6 +31,7 @@
 from twistedcaldav.config import config
 from twext.web2.auth.digest import DigestCredentialFactory
 from twext.web2.test.test_httpauth import makeDigestDeterministic
+from twext.web2.test.test_httpauth import FAKE_STATIC_NONCE
 
 class FakeDigestCredentialFactory(QopDigestCredentialFactory):
     """
@@ -429,7 +430,7 @@
                 request
             )
 
-            factory._invalidate(factory.generateNonce())
+            factory._invalidate(FAKE_STATIC_NONCE)
             response = (yield UnauthorizedResponse.makeResponse(
                 {"Digest":factory},
                 request.remoteAddr
@@ -522,10 +523,13 @@
         """
         Test that we can decode a valid response to our challenge
         """
+        theTime = 0
+        class newtime(object):
+            def time(self):
+                return theTime
+        from twistedcaldav.directory import digest
+        self.patch(digest, "time", newtime())
 
-        oldTime = DigestCredentialFactory.CHALLENGE_LIFETIME_SECS
-        DigestCredentialFactory.CHALLENGE_LIFETIME_SECS = 2
-
         for ctr, factory in enumerate(self.credentialFactories):
             challenge = (yield factory.getChallenge(clientAddress))
     
@@ -537,7 +541,7 @@
             creds = (yield factory.decode(clientResponse, _trivial_GET()))
             self.failUnless(creds.checkPassword('password'))
             
-            time.sleep(3)
+            theTime += DigestCredentialFactory.CHALLENGE_LIFETIME_SECS + 1
             request = _trivial_GET()
             try:
                 clientResponse = authRequest2[ctr] % (
@@ -553,7 +557,6 @@
             challenge = (yield factory.getChallenge(request.remoteAddr))
             self.assertTrue(challenge.get("stale") == "true")
             
-        DigestCredentialFactory.CHALLENGE_LIFETIME_SECS = oldTime
 
 def _trivial_GET():
     return SimpleRequest(None, 'GET', '/')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130201/858c28a8/attachment-0001.html>


More information about the calendarserver-changes mailing list