summaryrefslogtreecommitdiffstats
path: root/net/tools
diff options
context:
space:
mode:
authortonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-31 22:06:10 +0000
committertonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-31 22:06:10 +0000
commit60d71f46387b6f9f42c627db4d5edb72f34ed8cc (patch)
treec2a86efab2bdae2d2b5f249e6a3c708d6d3666d8 /net/tools
parent7b1f3aa3557418470589eb499f1ee466757c54b7 (diff)
downloadchromium_src-60d71f46387b6f9f42c627db4d5edb72f34ed8cc.zip
chromium_src-60d71f46387b6f9f42c627db4d5edb72f34ed8cc.tar.gz
chromium_src-60d71f46387b6f9f42c627db4d5edb72f34ed8cc.tar.bz2
Removing a clock dependent behavior in testserver which caused
TestTwoAuths and TestDigestAuth to fail when they take more than 10 seconds to send auth (which happens sometimes under valgrind). Now the unittest can control whether it wants to receive a stale nonce reply by requesting /auth-digest/stale. I plan to add a test for the stale flow in a subsequent patch. Also, this patch cleans up NavigateToURL calls in LoginPromptTest so that they are all in-place ASSERTs. This makes the messages more useful. BUG=36163,25794,38580 TEST=sh tools/valgrind/chrome_tests.sh -t ui --gtest_filter=LoginPromptTest.* Review URL: http://codereview.chromium.org/1508001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43266 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools')
-rw-r--r--net/tools/testserver/testserver.py41
1 files changed, 24 insertions, 17 deletions
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 931d846..94ad3da 100644
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -47,7 +47,7 @@ class StoppableHTTPServer(BaseHTTPServer.HTTPServer):
def serve_forever(self):
self.stop = False
- self.nonce = None
+ self.nonce_time = None
while not self.stop:
self.handle_request()
self.socket.close()
@@ -814,27 +814,34 @@ class TestPageHandler(BaseHTTPServer.BaseHTTPRequestHandler):
return True
+ def GetNonce(self, force_reset=False):
+ """Returns a nonce that's stable per request path for the server's lifetime.
+
+ This is a fake implementation. A real implementation would only use a given
+ nonce a single time (hence the name n-once). However, for the purposes of
+ unittesting, we don't care about the security of the nonce.
+
+ Args:
+ force_reset: Iff set, the nonce will be changed. Useful for testing the
+ "stale" response.
+ """
+ if force_reset or not self.server.nonce_time:
+ self.server.nonce_time = time.time()
+ return _new_md5('privatekey%s%d' %
+ (self.path, self.server.nonce_time)).hexdigest()
+
def AuthDigestHandler(self):
- """This handler tests 'Digest' authentication. It just sends a page with
- title 'user/pass' if you succeed."""
+ """This handler tests 'Digest' authentication.
+
+ It just sends a page with title 'user/pass' if you succeed.
+ A stale response is sent iff "stale" is present in the request path.
+ """
if not self._ShouldHandleRequest("/auth-digest"):
return False
- # Periodically generate a new nonce. Technically we should incorporate
- # the request URL into this, but we don't care for testing.
- nonce_life = 10
- stale = False
- if (not self.server.nonce or
- (time.time() - self.server.nonce_time > nonce_life)):
- if self.server.nonce:
- stale = True
- self.server.nonce_time = time.time()
- self.server.nonce = \
- _new_md5(time.ctime(self.server.nonce_time) +
- 'privatekey').hexdigest()
-
- nonce = self.server.nonce
+ stale = 'stale' in self.path
+ nonce = self.GetNonce(force_reset=stale)
opaque = _new_md5('opaque').hexdigest()
password = 'secret'
realm = 'testrealm'