Commit 71529f78 authored by Ned Nguyen's avatar Ned Nguyen Committed by Commit Bot

Ensure login_utils fetch credential file from cloud storage if not already exist

This allows us to remove credentials_path later on as it's currently handled
by Telemetry's page (https://cs.chromium.org/chromium/src/third_party/catapult/telemetry/telemetry/page/__init__.py?rcl=a12fb2d1ad961877f3fc1ca4b72965394270419d&l=47)

Bug: 787500
Change-Id: I74217522183322fd533aaa0e84c029c9f4b9d2b8
Reviewed-on: https://chromium-review.googlesource.com/806802Reviewed-by: default avatarJuan Antonio Navarro Pérez <perezju@chromium.org>
Commit-Queue: Ned Nguyen <nednguyen@google.com>
Cr-Commit-Position: refs/heads/master@{#521665}
parent 6ef4e359
......@@ -5,9 +5,13 @@
import json
import os
from py_utils import cloud_storage
DEFAULT_CREDENTIAL_PATH = os.path.join(
os.path.dirname(__file__), os.path.pardir, 'data', 'credentials.json')
os.path.dirname(__file__), '..', 'data', 'credentials.json')
DEFAULT_CREDENTIAL_BUCKET = cloud_storage.PUBLIC_BUCKET
def GetAccountNameAndPassword(credential,
......@@ -22,6 +26,11 @@ def GetAccountNameAndPassword(credential,
A tuple (username, password) in which both are username and password
strings.
"""
if (credentials_path == DEFAULT_CREDENTIAL_PATH and not
os.path.exists(DEFAULT_CREDENTIAL_PATH)):
cloud_storage.GetIfChanged(
DEFAULT_CREDENTIAL_PATH, DEFAULT_CREDENTIAL_BUCKET)
with open(credentials_path, 'r') as f:
credentials = json.load(f)
c = credentials.get(credential)
......
......@@ -59,8 +59,7 @@ class AccessibilityGmailComposeStory(_AccessibilityStory):
TAGS = [story_tags.ACCESSIBILITY, story_tags.KEYBOARD_INPUT]
def RunNavigateSteps(self, action_runner):
google_login.LoginGoogleAccount(action_runner, 'googletest',
self.credentials_path)
google_login.LoginGoogleAccount(action_runner, 'googletest')
# Navigating to https://mail.google.com immediately leads to an infinite
# redirection loop due to a bug in WPR (see
......
......@@ -475,8 +475,7 @@ class PinterestDesktopStory(_MediaBrowsingStory):
SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
def _Login(self, action_runner):
pinterest_login.LoginDesktopAccount(action_runner, 'googletest',
self.credentials_path)
pinterest_login.LoginDesktopAccount(action_runner, 'googletest')
def _ViewMediaItem(self, action_runner, index):
super(PinterestDesktopStory, self)._ViewMediaItem(action_runner, index)
......@@ -892,8 +891,7 @@ class FacebookScrollMobileStory(_InfiniteScrollStory):
SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
def _Login(self, action_runner):
facebook_login.LoginWithMobileSite(
action_runner, 'facebook3', self.credentials_path)
facebook_login.LoginWithMobileSite(action_runner, 'facebook3')
class FlickrDesktopStory(_InfiniteScrollStory):
......
......@@ -288,8 +288,7 @@ class _LoadGmailBaseStory(_LoadingStory):
ABSTRACT_STORY = True
def _Login(self, action_runner):
google_login.LoginGoogleAccount(action_runner, 'googletest',
self.credentials_path)
google_login.LoginGoogleAccount(action_runner, 'googletest')
# Navigating to https://mail.google.com immediately leads to an infinite
# redirection loop due to a bug in WPR (see
......@@ -333,7 +332,7 @@ class LoadDropboxStory(_LoadingStory):
URL = 'https://www.dropbox.com'
def _Login(self, action_runner):
dropbox_login.LoginAccount(action_runner, 'dropbox', self.credentials_path)
dropbox_login.LoginAccount(action_runner, 'dropbox')
class LoadWeatherStory(_LoadingStory):
......@@ -348,8 +347,7 @@ class LoadDriveStory(_LoadingStory):
TAGS = [story_tags.JAVASCRIPT_HEAVY]
def _Login(self, action_runner):
google_login.LoginGoogleAccount(action_runner, 'googletest',
self.credentials_path)
google_login.LoginGoogleAccount(action_runner, 'googletest')
################################################################################
......
......@@ -49,8 +49,7 @@ class _LongRunningGmailBase(_LongRunningStory):
ABSTRACT_STORY = True
def _Login(self, action_runner):
google_login.LoginGoogleAccount(action_runner, 'googletest',
self.credentials_path)
google_login.LoginGoogleAccount(action_runner, 'googletest')
# Navigating to https://mail.google.com immediately leads to an infinite
# redirection loop due to a bug in WPR (see
......
......@@ -65,8 +65,7 @@ class GooglePlayMusicDesktopStory(_MediaStory):
NAVIGATE_SELECTOR = '.description.tooltip.fade-out'
def _Login(self, action_runner):
google_login.LoginGoogleAccount(action_runner, 'googletest',
self.credentials_path)
google_login.LoginGoogleAccount(action_runner, 'googletest')
def _NavigateToMedia(self, action_runner):
# Clicks on Today's top hits.
......@@ -107,7 +106,7 @@ class PandoraDesktopStory(_MediaStory):
SEARCH_SELECTOR = '.searchInput'
def _Login(self, action_runner):
pandora_login.LoginAccount(action_runner, 'pandora', self.credentials_path)
pandora_login.LoginAccount(action_runner, 'pandora')
def _NavigateToMedia(self, action_runner):
pass # Audio autoplays on Pandora, no need to search.
......@@ -65,7 +65,6 @@ class SystemHealthStory(page.Page):
super(SystemHealthStory, self).__init__(
shared_page_state_class=_SystemHealthSharedState,
page_set=story_set, name=self.NAME, url=self.URL, tags=tags,
credentials_path='../data/credentials.json',
grouping_keys={'case': case, 'group': group},
platform_specific=self.PLATFORM_SPECIFIC,
extra_browser_args=extra_browser_args)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment