Changeset 246082 in webkit
- Timestamp:
- Jun 4, 2019, 2:40:00 PM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
-
BuildSlaveSupport/ews-app/ews/common/bugzilla.py (modified) (4 diffs)
-
ChangeLog (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/BuildSlaveSupport/ews-app/ews/common/bugzilla.py
r238636 r246082 26 26 import re 27 27 import socket 28 import time 28 29 29 30 from datetime import datetime, timedelta … … 62 63 63 64 attachment_url = '{}rest/bug/attachment/{}'.format(config.BUG_SERVER_URL, attachment_id) 65 api_key = os.getenv('BUGZILLA_API_KEY', None) 66 if api_key: 67 attachment_url += '?api_key={}'.format(api_key) 64 68 attachment = util.fetch_data_from_url(attachment_url) 65 69 if not attachment: … … 102 106 browser = property(_get_browser, _set_browser) 103 107 108 def authenticate(self): 109 username = os.getenv('BUGZILLA_USERNAME', None) 110 password = os.getenv('BUGZILLA_PASSWORD', None) 111 if not username or not password: 112 _log.warn('Bugzilla username/password not configured in environment variables. Skipping authentication.') 113 return 114 115 authenticated = False 116 attempts = 0 117 while not authenticated: 118 attempts += 1 119 _log.info('Logging in as {}...'.format(username)) 120 self.browser.open(config.BUG_SERVER_URL + 'index.cgi?GoAheadAndLogIn=1') 121 self.browser.select_form(name="login") 122 self.browser['Bugzilla_login'] = username 123 self.browser['Bugzilla_password'] = password 124 self.browser.find_control("Bugzilla_restrictlogin").items[0].selected = False 125 response = self.browser.submit() 126 127 match = re.search("<title>(.+?)</title>", response.read()) 128 # If the resulting page has a title, and it contains the word 129 # "invalid" assume it's the login failure page. 130 if match and re.search("Invalid", match.group(1), re.IGNORECASE): 131 errorMessage = 'Bugzilla login failed: {}'.format(match.group(1)) 132 if attempts >= 5: 133 # raise an exception only if this was the last attempt 134 raise Exception(errorMessage) 135 _log.error(errorMessage) 136 time.sleep(5) 137 else: 138 authenticated = True 139 104 140 def fetch_attachment_ids_from_review_queue(self, since=None, only_security_bugs=False): 105 141 review_queue_url = 'request.cgi?action=queue&type=review&group=type' … … 109 145 110 146 def _load_query(self, query): 111 # TODO: check if we need to authenticate.147 self.authenticate() 112 148 full_url = '{}{}'.format(config.BUG_SERVER_URL, query) 113 149 _log.info('Getting list of patches needing review, URL: {}'.format(full_url)) -
trunk/Tools/ChangeLog
r246080 r246082 1 2019-06-04 Aakash Jain <aakash_jain@apple.com> 2 3 [ews-app] Add authentication while fetching bugs 4 https://bugs.webkit.org/show_bug.cgi?id=198415 5 <rdar://problem/51298710> 6 7 Reviewed by Jonathan Bedard. 8 9 * BuildSlaveSupport/ews-app/ews/common/bugzilla.py: 10 (Bugzilla._fetch_attachment_json): Use api_key if configured in environment variable. 11 (BugzillaBeautifulSoup.authenticate): Method to authenticate, logic copied from webkitpy/common/net/bugzilla/bugzilla.py 12 (BugzillaBeautifulSoup._load_query): 13 1 14 2019-06-04 Aakash Jain <aakash_jain@apple.com> 2 15
Note:
See TracChangeset
for help on using the changeset viewer.