summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rwxr-xr-xnet/tools/testserver/chromiumsync.py15
-rw-r--r--net/tools/testserver/testserver.py24
2 files changed, 38 insertions, 1 deletions
diff --git a/net/tools/testserver/chromiumsync.py b/net/tools/testserver/chromiumsync.py
index 8e3ea46..33ab8be 100755
--- a/net/tools/testserver/chromiumsync.py
+++ b/net/tools/testserver/chromiumsync.py
@@ -592,6 +592,19 @@ class TestServer(object):
# The implementation supports exactly one account; its state is here.
self.account = SyncDataModel()
self.account_lock = threading.Lock()
+ self.account_user_email = 'syncjuser@chromium.org'
+
+ def HandleConfigure(self, config):
+ """Handles various test configuration parameters sent from the client.
+
+ Args:
+ config: Dictionary of configuration parameters.
+ Returns:
+ True if configuration was successful.
+ """
+ if config.has_key('user_email'):
+ self.account_user_email = config['user_email'][0]
+ return True
def HandleCommand(self, raw_request):
"""Decode and handle a sync command from a raw input of bytes.
@@ -621,7 +634,7 @@ class TestServer(object):
print 'Authenticate'
# We accept any authentication token, and support only one account.
# TODO(nick): Mock out the GAIA authentication as well; hook up here.
- response.authenticate.user.email = 'syncjuser@chromium'
+ response.authenticate.user.email = self.account_user_email
response.authenticate.user.display_name = 'Sync J User'
elif contents == sync_pb2.ClientToServerMessage.COMMIT:
print 'Commit'
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 0ad5d28..849ec17 100644
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -127,6 +127,7 @@ class TestPageHandler(BaseHTTPServer.BaseHTTPRequestHandler):
self.WriteFile,
self.EchoTitleHandler,
self.EchoAllHandler,
+ self.ChromiumSyncConfigureHandler,
self.ChromiumSyncCommandHandler,
self.EchoHandler] + self._get_handlers
self._put_handlers = [
@@ -1007,6 +1008,29 @@ class TestPageHandler(BaseHTTPServer.BaseHTTPRequestHandler):
self.end_headers()
return True
+ def ChromiumSyncConfigureHandler(self):
+ """Handle updating the configuration of the sync server.
+
+ The name and value pairs of the post payload will update the
+ configuration of the sync server. Supported tuples are:
+ user_email,<email address> - Sets the email for the fake user account
+ """
+ test_name = "/chromiumsync/configure"
+ if not self._ShouldHandleRequest(test_name):
+ return False
+
+ length = int(self.headers.getheader('content-length'))
+ raw_request = self.rfile.read(length)
+ config = cgi.parse_qs(raw_request, keep_blank_values=1)
+
+ success = self._sync_handler.HandleConfigure(config)
+ if success:
+ self.send_response(200)
+ else:
+ self.send_response(500)
+ self.end_headers()
+ return True
+
def ChromiumSyncCommandHandler(self):
"""Handle a chromiumsync command arriving via http.