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

Unified Diff: sync/tools/testserver/chromiumsync.py

Issue 58093002: [sync] Serve fake OAuth2 tokens from python sync server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 7 years, 1 month 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
« no previous file with comments | « no previous file | sync/tools/testserver/sync_testserver.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/tools/testserver/chromiumsync.py
diff --git a/sync/tools/testserver/chromiumsync.py b/sync/tools/testserver/chromiumsync.py
index 7e898c2b572bd30e116b2008db0c177f7674d576..0f401d13222ac965c5f45f980ea31afdc122778a 100644
--- a/sync/tools/testserver/chromiumsync.py
+++ b/sync/tools/testserver/chromiumsync.py
@@ -1158,6 +1158,13 @@ class TestServer(object):
for times in xrange(0, sys.maxint) for c in xrange(ord('A'), ord('Z')))
self.transient_error = False
self.sync_count = 0
+ # Gaia OAuth2 Token fields and their default values.
+ self.response_code = 200
+ self.request_token = 'rt1'
+ self.access_token = 'at1'
+ self.expires_in = 3600
+ self.token_type = 'Bearer'
+
def GetShortClientName(self, query):
parsed = cgi.parse_qs(query[query.find('?')+1:])
@@ -1482,3 +1489,35 @@ class TestServer(object):
if update_request.need_encryption_key or sending_nigori_node:
update_response.encryption_keys.extend(self.account.GetKeystoreKeys())
+
+ def HandleGetOauth2Token(self):
+ return (int(self.response_code),
+ '{\n'
+ ' \"refresh_token\": \"' + self.request_token + '\",\n'
+ ' \"access_token\": \"' + self.access_token + '\",\n'
+ ' \"expires_in\": ' + str(self.expires_in) + ',\n'
+ ' \"token_type\": \"' + self.token_type +'\"\n'
+ '}')
+
+ def HandleSetOauth2Token(self, response_code, request_token, access_token,
+ expires_in, token_type):
+ if response_code != 0:
+ self.response_code = response_code
+ if request_token != '':
+ self.request_token = request_token
+ if access_token != '':
+ self.access_token = access_token
+ if expires_in != 0:
+ self.expires_in = expires_in
+ if token_type != '':
+ self.token_type = token_type
+
+ return (200,
+ '<html><title>Set OAuth2 Token</title>'
+ '<H1>This server will now return the OAuth2 Token:</H1>'
+ '<p>response_code: ' + str(self.response_code) + '</p>'
+ '<p>request_token: ' + self.request_token + '</p>'
+ '<p>access_token: ' + self.access_token + '</p>'
+ '<p>expires_in: ' + str(self.expires_in) + '</p>'
+ '<p>token_type: ' + self.token_type + '</p>'
+ '</html>')
« no previous file with comments | « no previous file | sync/tools/testserver/sync_testserver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698