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

Side by Side Diff: telemetry/telemetry/internal/backends/form_based_credentials_backend.py

Issue 2050863003: [Telemetry] Move the deprecate decorator of form_based_credentials_backend to LoginNeeded method (Closed) Base URL: https://github.com/catapult-project/catapult@master
Patch Set: Created 4 years, 6 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import logging 4 import logging
5 5
6 from telemetry import decorators 6 from telemetry import decorators
7 from telemetry.core import exceptions 7 from telemetry.core import exceptions
8 8
9 9
10 # pylint: disable=line-too-long
11 @decorators.Deprecated(2017, 5, 5, 'Use the login helper modules in '
12 'https://code.google.com/p/chromium/codesearch#chromium/s rc/tools/perf/page_sets/login_helpers/'
13 ' instead.')
14 # pylint: enable=line-too-long
15 class FormBasedCredentialsBackend(object): 10 class FormBasedCredentialsBackend(object):
16 def __init__(self): 11 def __init__(self):
17 self._logged_in = False 12 self._logged_in = False
18 13
19 def IsAlreadyLoggedIn(self, tab): 14 def IsAlreadyLoggedIn(self, tab):
20 return tab.EvaluateJavaScript(self.logged_in_javascript) 15 return tab.EvaluateJavaScript(self.logged_in_javascript)
21 16
22 @property 17 @property
23 def credentials_type(self): 18 def credentials_type(self):
24 raise NotImplementedError() 19 raise NotImplementedError()
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 tab.ExecuteJavaScript(email_id) 69 tab.ExecuteJavaScript(email_id)
75 tab.ExecuteJavaScript(password) 70 tab.ExecuteJavaScript(password)
76 if self.login_button_javascript: 71 if self.login_button_javascript:
77 tab.ExecuteJavaScript(self.login_button_javascript) 72 tab.ExecuteJavaScript(self.login_button_javascript)
78 else: 73 else:
79 tab.ExecuteJavaScript( 74 tab.ExecuteJavaScript(
80 'document.getElementById("%s").submit();' % self.login_form_id) 75 'document.getElementById("%s").submit();' % self.login_form_id)
81 # Wait for the form element to disappear as confirmation of the navigation. 76 # Wait for the form element to disappear as confirmation of the navigation.
82 action_runner.WaitForNavigate() 77 action_runner.WaitForNavigate()
83 78
84 79 # pylint: disable=line-too-long
80 @decorators.Deprecated(2017, 5, 5,
81 'FormBasedCredentialsBackend is deprecated. Use the '
82 'login helper modules in '
83 'https://code.google.com/p/chromium/codesearch#chromium /src/tools/perf/page_sets/login_helpers/'
84 ' instead.')
85 # pylint: enable=line-too-long
85 def LoginNeeded(self, tab, action_runner, config): 86 def LoginNeeded(self, tab, action_runner, config):
86 """Logs in to a test account. 87 """Logs in to a test account.
87 88
88 Raises: 89 Raises:
89 RuntimeError: if could not get credential information. 90 RuntimeError: if could not get credential information.
90 """ 91 """
91 if self._logged_in: 92 if self._logged_in:
92 return True 93 return True
93 94
94 if 'username' not in config or 'password' not in config: 95 if 'username' not in config or 'password' not in config:
(...skipping 21 matching lines...) Expand all
116 action_runner, tab, config['username'], config['password']) 117 action_runner, tab, config['username'], config['password'])
117 118
118 self._logged_in = True 119 self._logged_in = True
119 return True 120 return True
120 except exceptions.TimeoutException: 121 except exceptions.TimeoutException:
121 logging.warning('Timed out while loading: %s', url) 122 logging.warning('Timed out while loading: %s', url)
122 return False 123 return False
123 124
124 def LoginNoLongerNeeded(self, tab): # pylint: disable=unused-argument 125 def LoginNoLongerNeeded(self, tab): # pylint: disable=unused-argument
125 assert self._logged_in 126 assert self._logged_in
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698