Lots of small NPE and other exception fixes
This commit is contained in:
parent
511ee12a58
commit
e8ad01cb41
5 changed files with 22 additions and 4 deletions
|
@ -135,8 +135,15 @@ def process_token(auth):
|
|||
logger.warning('Invalid token format: %s' % auth)
|
||||
abort(401, message='Invalid token format: %(auth)s', issue='invalid-auth-token', auth=auth)
|
||||
|
||||
token_vals = {val[0]: val[1] for val in
|
||||
def safe_get(lst, index, default_value):
|
||||
try:
|
||||
return lst[index]
|
||||
except IndexError:
|
||||
return default_value
|
||||
|
||||
token_vals = {val[0]: safe_get(val, 1, '') for val in
|
||||
(detail.split('=') for detail in token_details)}
|
||||
|
||||
if 'signature' not in token_vals:
|
||||
logger.warning('Token does not contain signature: %s' % auth)
|
||||
abort(401, message='Token does not contain a valid signature: %(auth)s',
|
||||
|
|
|
@ -46,7 +46,7 @@ class DatabaseAuthorizationProvider(AuthorizationProvider):
|
|||
def validate_redirect_uri(self, client_id, redirect_uri):
|
||||
try:
|
||||
app = OAuthApplication.get(client_id=client_id)
|
||||
if app.redirect_uri and redirect_uri.startswith(app.redirect_uri):
|
||||
if app.redirect_uri and redirect_uri and redirect_uri.startswith(app.redirect_uri):
|
||||
return True
|
||||
return False
|
||||
except OAuthApplication.DoesNotExist:
|
||||
|
|
|
@ -66,6 +66,9 @@ def generate_headers(role='read'):
|
|||
@index.route('/users/', methods=['POST'])
|
||||
def create_user():
|
||||
user_data = request.get_json()
|
||||
if not 'username' in user_data:
|
||||
abort(400, 'Missing username')
|
||||
|
||||
username = user_data['username']
|
||||
password = user_data.get('password', '')
|
||||
|
||||
|
|
|
@ -556,7 +556,7 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
|||
// If an error occurred, report it and done.
|
||||
if (ping < 0) {
|
||||
cached['pings'] = [-1];
|
||||
invokeCallback($scope, pings, callback);
|
||||
invokeCallback($scope, [-1], callback);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1518,7 +1518,12 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
|||
};
|
||||
|
||||
notificationService.getPage = function(notification) {
|
||||
var page = notificationKinds[notification['kind']]['page'];
|
||||
var kindInfo = notificationKinds[notification['kind']];
|
||||
if (!kindInfo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var page = kindInfo['page'];
|
||||
if (typeof page != 'string') {
|
||||
page = page(notification['metadata']);
|
||||
}
|
||||
|
|
|
@ -205,6 +205,9 @@ class _CloudStorage(BaseStorage):
|
|||
path = self._init_path(path)
|
||||
key = self._key_class(self._cloud_bucket, path)
|
||||
k = self._cloud_bucket.lookup(key)
|
||||
if k is None:
|
||||
raise IOError('No such key: \'{0}\''.format(path))
|
||||
|
||||
return k.etag[1:-1][:7]
|
||||
|
||||
|
||||
|
|
Reference in a new issue