From 19f6dede897e8e3230d3f09fcc678dc9f0fd10f1 Mon Sep 17 00:00:00 2001 From: Rudyard Richter Date: Wed, 2 May 2018 18:05:08 -0500 Subject: [PATCH 1/4] fix(storage-api): fix to use fence restful api wrapper --- fence/blueprints/storage_creds/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fence/blueprints/storage_creds/__init__.py b/fence/blueprints/storage_creds/__init__.py index 65d2dccd9..94dd0d7de 100644 --- a/fence/blueprints/storage_creds/__init__.py +++ b/fence/blueprints/storage_creds/__init__.py @@ -1,6 +1,5 @@ import flask from flask_sqlalchemy_session import current_session -from flask_restful import Api from fence.auth import require_auth_header from fence.blueprints.storage_creds.api import AccessKey, ApiKey, ApiKeyList @@ -9,6 +8,7 @@ from fence.blueprints.storage_creds.other import OtherCredentialsList from fence.blueprints.storage_creds.other import OtherCredentials from fence.resources.storage import get_endpoints_descriptions +from fence.restful import RestfulApi ALL_RESOURCES = { '/api': 'access to CDIS APIs', @@ -21,7 +21,7 @@ def make_creds_blueprint(): blueprint = flask.Blueprint('credentials', __name__) - blueprint_api = Api(blueprint) + blueprint_api = RestfulApi(blueprint) blueprint_api.add_resource( GoogleCredentialsList, '/google', strict_slashes=False From a617812d18bdf4cc68502125d63d066b83c571cc Mon Sep 17 00:00:00 2001 From: Rudyard Richter Date: Wed, 2 May 2018 18:07:17 -0500 Subject: [PATCH 2/4] fix(authutils): update authutils version to include fix --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8b0027d24..84a4759d4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -35,4 +35,4 @@ pyyaml -e git+https://github.com/uc-cdis/datamodelutils.git@0.3.0#egg=datamodelutils -e git+https://github.com/uc-cdis/cdis-python-utils.git@0.2.8#egg=cdispyutils -e git+https://github.com/uc-cdis/cirrus.git@0.0.4#egg=cirrus-0.0.4 --e git+https://github.com/uc-cdis/authutils.git@079981a809382a14e17f5af4749f50e56410a8ad#egg=authutils-2.0.0 +-e git+https://github.com/uc-cdis/authutils.git@2.0.1#egg=authutils-2.0.1 From 8495afef2da673f5611bbe9a8390f5a511143384 Mon Sep 17 00:00:00 2001 From: Rudyard Richter Date: Wed, 2 May 2018 18:21:54 -0500 Subject: [PATCH 3/4] fix(storage-api): fix error handling to get status code --- fence/restful.py | 7 ++++++- tests/conftest.py | 1 + tests/test_settings.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fence/restful.py b/fence/restful.py index fda4f2906..a4ac9c2d4 100644 --- a/fence/restful.py +++ b/fence/restful.py @@ -24,4 +24,9 @@ def handle_error(error): return flask.jsonify(error.get_body()), error.status_code else: flask.current_app.logger.exception("Catch exception") - return flask.jsonify(error=error.message), 500 + error_code = 500 + if hasattr(error, 'code'): + error_code = error.code + elif hasattr(error, 'status_code'): + error_code = error.status_code + return flask.jsonify(error=error.message), error_code diff --git a/tests/conftest.py b/tests/conftest.py index 66bd93fb0..95ec5c07f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -244,6 +244,7 @@ def app(kid, rsa_private_key, rsa_public_key): fence.app.jwt_public_keys = { fence.app.config['BASE_URL']: OrderedDict([(kid, rsa_public_key)]) } + fence.app.debug = True return fence.app diff --git a/tests/test_settings.py b/tests/test_settings.py index 876ac8541..75386791a 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -12,7 +12,7 @@ # WARNING: the test database is cleared every run -DB = 'postgresql://postgres:postgres@localhost:5432/fence_test_tmp' +DB = 'postgresql://postgres@localhost:5432/fence_test_tmp' MOCK_AUTH = True From ed49c8de3385c99ea6d533e95c3b4c458f23d2e9 Mon Sep 17 00:00:00 2001 From: Rudyard Richter Date: Wed, 2 May 2018 18:23:35 -0500 Subject: [PATCH 4/4] fix(storage-api): remove debug enable --- tests/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 95ec5c07f..66bd93fb0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -244,7 +244,6 @@ def app(kid, rsa_private_key, rsa_public_key): fence.app.jwt_public_keys = { fence.app.config['BASE_URL']: OrderedDict([(kid, rsa_public_key)]) } - fence.app.debug = True return fence.app