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)
|
logger.warning('Invalid token format: %s' % auth)
|
||||||
abort(401, message='Invalid token format: %(auth)s', issue='invalid-auth-token', auth=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)}
|
(detail.split('=') for detail in token_details)}
|
||||||
|
|
||||||
if 'signature' not in token_vals:
|
if 'signature' not in token_vals:
|
||||||
logger.warning('Token does not contain signature: %s' % auth)
|
logger.warning('Token does not contain signature: %s' % auth)
|
||||||
abort(401, message='Token does not contain a valid signature: %(auth)s',
|
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):
|
def validate_redirect_uri(self, client_id, redirect_uri):
|
||||||
try:
|
try:
|
||||||
app = OAuthApplication.get(client_id=client_id)
|
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 True
|
||||||
return False
|
return False
|
||||||
except OAuthApplication.DoesNotExist:
|
except OAuthApplication.DoesNotExist:
|
||||||
|
|
|
@ -66,6 +66,9 @@ def generate_headers(role='read'):
|
||||||
@index.route('/users/', methods=['POST'])
|
@index.route('/users/', methods=['POST'])
|
||||||
def create_user():
|
def create_user():
|
||||||
user_data = request.get_json()
|
user_data = request.get_json()
|
||||||
|
if not 'username' in user_data:
|
||||||
|
abort(400, 'Missing username')
|
||||||
|
|
||||||
username = user_data['username']
|
username = user_data['username']
|
||||||
password = user_data.get('password', '')
|
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 an error occurred, report it and done.
|
||||||
if (ping < 0) {
|
if (ping < 0) {
|
||||||
cached['pings'] = [-1];
|
cached['pings'] = [-1];
|
||||||
invokeCallback($scope, pings, callback);
|
invokeCallback($scope, [-1], callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1518,7 +1518,12 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
||||||
};
|
};
|
||||||
|
|
||||||
notificationService.getPage = function(notification) {
|
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') {
|
if (typeof page != 'string') {
|
||||||
page = page(notification['metadata']);
|
page = page(notification['metadata']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,6 +205,9 @@ class _CloudStorage(BaseStorage):
|
||||||
path = self._init_path(path)
|
path = self._init_path(path)
|
||||||
key = self._key_class(self._cloud_bucket, path)
|
key = self._key_class(self._cloud_bucket, path)
|
||||||
k = self._cloud_bucket.lookup(key)
|
k = self._cloud_bucket.lookup(key)
|
||||||
|
if k is None:
|
||||||
|
raise IOError('No such key: \'{0}\''.format(path))
|
||||||
|
|
||||||
return k.etag[1:-1][:7]
|
return k.etag[1:-1][:7]
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue