Package list python-castellan / 59f9380
Add handler for Bad Request error during Vault authentication Vault returns Bad Request error if invalid secret ID is provided. It's better to have such errors handled instad of generic "KeyError: 'auth'" execption. Change-Id: Ibc068af70de4022f544d394ec4b014443a9c16b5 Ivan Kolodyazhny 1 year, 4 months ago
1 changed file(s) with 7 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
172172 if resp.status_code == requests.codes['forbidden']:
173173 raise exception.Forbidden()
174174
175 resp = resp.json()
176 self._cached_approle_token_id = resp['auth']['client_token']
175 resp_data = resp.json()
176
177 if resp.status_code == requests.codes['bad_request']:
178 raise exception.KeyManagerError(', '.join(resp_data['errors']))
179
180 self._cached_approle_token_id = resp_data['auth']['client_token']
177181 self._approle_token_issue = token_issue_utc
178 self._approle_token_ttl = resp['auth']['lease_duration']
182 self._approle_token_ttl = resp_data['auth']['lease_duration']
179183 return {'X-Vault-Token': self._approle_token_id}
180184
181185 return {}