Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(795)

Unified Diff: net/tools/testserver/testserver.py

Issue 5814005: Minimize login prompts (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add browsertest Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/tools/testserver/testserver.py
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 0cd663d8434551dc1f4b442edf67c8bbd222059e..23472b0ddc75e35f072ee40f862e7773544a26a4 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -914,6 +914,11 @@ class TestPageHandler(BasePageHandler):
set_cookie_if_challenged = self.path.find('?set-cookie-if-challenged') > 0
cbentzel 2010/12/17 19:22:56 Could you shift this to urlparse and cgi.parse_qs
+ pw_list = re.findall(r'[&?]password=([^&]+)', self.path) + ['secret']
+ realm_list = re.findall(r'[&?]realm=([^&]+)', self.path) + ['testrealm']
+ expected_password = pw_list[0]
+ realm = realm_list[0]
+
auth = self.headers.getheader('authorization')
try:
if not auth:
@@ -921,12 +926,12 @@ class TestPageHandler(BasePageHandler):
b64str = re.findall(r'Basic (\S+)', auth)[0]
userpass = base64.b64decode(b64str)
username, password = re.findall(r'([^:]+):(\S+)', userpass)[0]
- if password != 'secret':
+ if password != expected_password:
raise Exception('wrong password')
except Exception, e:
# Authentication failed.
self.send_response(401)
- self.send_header('WWW-Authenticate', 'Basic realm="testrealm"')
+ self.send_header('WWW-Authenticate', 'Basic realm="%s"' % realm)
self.send_header('Content-type', 'text/html')
if set_cookie_if_challenged:
self.send_header('Set-Cookie', 'got_challenged=true')

Powered by Google App Engine
This is Rietveld 408576698