diff options
-rw-r--r-- | keystone/common/wsgi.py | 3 | ||||
-rw-r--r-- | tests/test_content_types.py | 21 |
2 files changed, 24 insertions, 0 deletions
diff --git a/keystone/common/wsgi.py b/keystone/common/wsgi.py index 42a4bc31..92f6e1c1 100644 --- a/keystone/common/wsgi.py +++ b/keystone/common/wsgi.py @@ -233,6 +233,9 @@ class Application(BaseApplication): except exception.Error as e: LOG.warning(e) return render_exception(e) + except TypeError as e: + logging.exception(e) + return render_exception(exception.ValidationError(e)) except Exception as e: logging.exception(e) return render_exception(exception.UnexpectedError(exception=e)) diff --git a/tests/test_content_types.py b/tests/test_content_types.py index 6b0a03e0..20bf3386 100644 --- a/tests/test_content_types.py +++ b/tests/test_content_types.py @@ -506,6 +506,27 @@ class CoreApiTests(object): """This triggers assertValidErrorResponse by convention.""" self.public_request(path='/v2.0/tenants', expected_status=401) + def test_invalid_parameter_error_response(self): + token = self.get_scoped_token() + bad_body = { + 'OS-KSADM:serviceBAD': { + 'name': uuid.uuid4().hex, + 'type': uuid.uuid4().hex, + }, + } + res = self.admin_request(method='POST', + path='/v2.0/OS-KSADM/services', + body=bad_body, + token=token, + expected_status=400) + self.assertValidErrorResponse(res) + res = self.admin_request(method='POST', + path='/v2.0/users', + body=bad_body, + token=token, + expected_status=400) + self.assertValidErrorResponse(res) + class JsonTestCase(RestfulTestCase, CoreApiTests): content_type = 'json' |