Support for normalizing email.
Remove dots from username, add @gmail.com if necessary.
Allow username, password to be specified for login_GaiaLogin.
BUG=chromium:618466
TEST=login_GaiaLogin
Change-Id: I8cd1340ec90e0d6d750cbde39cdbbcab3960ac0c
Reviewed-on: https://chromium-review.googlesource.com/351120
Commit-Ready: Achuith Bhandarkar <achuith@chromium.org>
Tested-by: Achuith Bhandarkar <achuith@chromium.org>
Reviewed-by: Jacob Dufault <jdufault@chromium.org>
diff --git a/client/common_lib/cros/chrome.py b/client/common_lib/cros/chrome.py
index 20c331a..4acc8be 100644
--- a/client/common_lib/cros/chrome.py
+++ b/client/common_lib/cros/chrome.py
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import logging, os
+import logging, os, re
from autotest_lib.client.cros import constants
from autotest_lib.client.bin import utils
@@ -41,6 +41,21 @@
from autotest_lib.client.common_lib.cros import arc_util
+def NormalizeEmail(username):
+ """Remove dots from username. Add @gmail.com if necessary.
+
+ TODO(achuith): Get rid of this when crbug.com/358427 is fixed.
+
+ @param username: username/email to be scrubbed.
+ """
+ parts = re.split('@', username)
+ parts[0] = re.sub('\.', '', parts[0])
+
+ if len(parts) == 1:
+ parts.append('gmail.com')
+ return '@'.join(parts)
+
+
class Chrome(object):
"""Wrapper for creating a telemetry browser instance with extensions."""
@@ -137,6 +152,7 @@
b_options.gaia_login = gaia_login
self.username = b_options.username if username is None else username
self.password = b_options.password if password is None else password
+ self.username = NormalizeEmail(self.username)
b_options.username = self.username
b_options.password = self.password
# gaia_id will be added to telemetry code in chromium repository later