summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorlipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-23 01:26:10 +0000
committerlipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-23 01:26:10 +0000
commit4b663dd78b78a65a03641283852211b98d0599af (patch)
tree8205686085c3025b481fcf4869525f1ae1dd76b9 /net
parent24fa159784476ccb997919108fdaa08ed2f2f7e5 (diff)
downloadchromium_src-4b663dd78b78a65a03641283852211b98d0599af.zip
chromium_src-4b663dd78b78a65a03641283852211b98d0599af.tar.gz
chromium_src-4b663dd78b78a65a03641283852211b98d0599af.tar.bz2
Sending auth error from python server. After posting a request to the /chromiumsync/cred url with the parameter valid=false the server starts sending auth errors repeatedly . To stop the auth errors we have to navigate to the same url with valid=True.
BUG= TEST= Review URL: http://codereview.chromium.org/7978043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102417 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rwxr-xr-xnet/tools/testserver/testserver.py47
1 files changed, 44 insertions, 3 deletions
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 7affa1f..7f9e17a 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -132,6 +132,7 @@ class SyncHTTPServer(StoppableHTTPServer):
self._xmpp_server = xmppserver.XmppServer(
self._xmpp_socket_map, ('localhost', 0))
self.xmpp_port = self._xmpp_server.getsockname()[1]
+ self.authenticated = True
def GetXmppServer(self):
return self._xmpp_server
@@ -155,6 +156,12 @@ class SyncHTTPServer(StoppableHTTPServer):
self.handle_error(request, client_address)
self.close_request(request)
+ def SetAuthenticated(self, auth_valid):
+ self.authenticated = auth_valid
+
+ def GetAuthenticated(self):
+ return self.authenticated
+
def serve_forever(self):
"""This is a merge of asyncore.loop() and SocketServer.serve_forever().
"""
@@ -1415,7 +1422,8 @@ class SyncPageHandler(BasePageHandler):
self.ChromiumSyncBirthdayErrorOpHandler,
self.ChromiumSyncTransientErrorOpHandler,
self.ChromiumSyncSyncTabsOpHandler,
- self.ChromiumSyncErrorOpHandler]
+ self.ChromiumSyncErrorOpHandler,
+ self.ChromiumSyncCredHandler]
post_handlers = [self.ChromiumSyncCommandHandler,
self.ChromiumSyncTimeHandler]
@@ -1423,6 +1431,7 @@ class SyncPageHandler(BasePageHandler):
sync_http_server, [], get_handlers,
post_handlers, [])
+
def ChromiumSyncTimeHandler(self):
"""Handle Chromium sync .../time requests.
@@ -1455,10 +1464,19 @@ class SyncPageHandler(BasePageHandler):
length = int(self.headers.getheader('content-length'))
raw_request = self.rfile.read(length)
+ http_response = 200
+ raw_reply = None
+ if not self.server.GetAuthenticated():
+ http_response = 401
+ challenge = 'GoogleLogin realm="http://127.0.0.1", service="chromiumsync"'
+ else:
+ http_response, raw_reply = self.server.HandleCommand(
+ self.path, raw_request)
- http_response, raw_reply = self.server.HandleCommand(
- self.path, raw_request)
+ ### Now send the response to the client. ###
self.send_response(http_response)
+ if http_response == 401:
+ self.send_header('www-Authenticate', challenge)
self.end_headers()
self.wfile.write(raw_reply)
return True
@@ -1477,6 +1495,29 @@ class SyncPageHandler(BasePageHandler):
self.wfile.write(raw_reply)
return True
+ def ChromiumSyncCredHandler(self):
+ test_name = "/chromiumsync/cred"
+ if not self._ShouldHandleRequest(test_name):
+ return False
+ try:
+ query = urlparse.urlparse(self.path)[4]
+ cred_valid = urlparse.parse_qs(query)['valid']
+ if cred_valid[0] == 'True':
+ self.server.SetAuthenticated(True)
+ else:
+ self.server.SetAuthenticated(False)
+ except:
+ self.server.SetAuthenticated(False)
+
+ http_response = 200
+ raw_reply = 'Authenticated: %s ' % self.server.GetAuthenticated()
+ self.send_response(http_response)
+ self.send_header('Content-Type', 'text/html')
+ self.send_header('Content-Length', len(raw_reply))
+ self.end_headers()
+ self.wfile.write(raw_reply)
+ return True
+
def ChromiumSyncDisableNotificationsOpHandler(self):
test_name = "/chromiumsync/disablenotifications"
if not self._ShouldHandleRequest(test_name):