summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorskrul@chromium.org <skrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-13 21:01:52 +0000
committerskrul@chromium.org <skrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-13 21:01:52 +0000
commit9a437d9e3d73ad9262b105aa8ecb6070d69ace13 (patch)
tree82fbfa407c9cd575bb1f99a1e903714719e7ec2d /net
parentbc0cb2f2bdcab8930dcc29ecead765a43c13cee4 (diff)
downloadchromium_src-9a437d9e3d73ad9262b105aa8ecb6070d69ace13.zip
chromium_src-9a437d9e3d73ad9262b105aa8ecb6070d69ace13.tar.gz
chromium_src-9a437d9e3d73ad9262b105aa8ecb6070d69ace13.tar.bz2
Simple offline startup integration test.
This is a simple offline startup integration test. This change also includes the groundwork for more complex offline startup test cases, including the ability to enable and disable network connectivity as well as configure the mock sync server with a username. BUG=47918 Review URL: http://codereview.chromium.org/3078031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56087 0039d316-1c4b-4281-b951-d872f2087c98
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.