Ensure status code is always passed as int

There is some inconsistency in calls to the wsgi render_response
function. Sometimes the status tuple uses an int for the http
status code and other times a string. The Python 3.5 gate job
discovered the problem.

This patch normalizes all calls to use an int.

Change-Id: I136b01f755ff99dfba244e79068fdaae614b2091
Closes-Bug: #1599983
This commit is contained in:
Eric Brown 2016-07-07 13:00:43 -07:00
parent 5f7377f5ab
commit 88de82e130
3 changed files with 9 additions and 9 deletions

View File

@ -766,7 +766,7 @@ def render_response(body=None, status=None, headers=None, method=None):
headers = _convert_to_str(headers)
resp = webob.Response(body=body,
status='%s %s' % status,
status='%d %s' % status,
headerlist=headers)
if method and method.upper() == 'HEAD':

View File

@ -96,7 +96,7 @@ class IdentityProvider(_ControllerBase):
identity_provider.setdefault('enabled', False)
idp_ref = self.federation_api.create_idp(idp_id, identity_provider)
response = IdentityProvider.wrap_member(request.context_dict, idp_ref)
return wsgi.render_response(body=response, status=('201', 'Created'))
return wsgi.render_response(body=response, status=(201, 'Created'))
@controller.filterprotected('id', 'enabled')
def list_identity_providers(self, request, filters):
@ -184,7 +184,7 @@ class FederationProtocol(_ControllerBase):
ref = self._normalize_dict(protocol)
ref = self.federation_api.create_protocol(idp_id, protocol_id, ref)
response = FederationProtocol.wrap_member(request.context_dict, ref)
return wsgi.render_response(body=response, status=('201', 'Created'))
return wsgi.render_response(body=response, status=(201, 'Created'))
@controller.protected()
@validation.validated(schema.protocol_update, 'protocol')
@ -223,7 +223,7 @@ class MappingController(_ControllerBase):
mapping_ref = self.federation_api.create_mapping(mapping_id, ref)
response = MappingController.wrap_member(request.context_dict,
mapping_ref)
return wsgi.render_response(body=response, status=('201', 'Created'))
return wsgi.render_response(body=response, status=(201, 'Created'))
@controller.protected()
def list_mappings(self, request):
@ -396,7 +396,7 @@ class Auth(auth_controllers.Auth):
headers = self._build_response_headers(service_provider)
return wsgi.render_response(body=response.to_string(),
status=('200', 'OK'),
status=(200, 'OK'),
headers=headers)
@validation.validated(schema.saml_create, 'auth')
@ -416,7 +416,7 @@ class Auth(auth_controllers.Auth):
headers = self._build_response_headers(service_provider)
return wsgi.render_response(body=ecp_assertion.to_string(),
status=('200', 'OK'),
status=(200, 'OK'),
headers=headers)
@ -494,7 +494,7 @@ class ServiceProvider(_ControllerBase):
CONF.saml.relay_state_prefix)
sp_ref = self.federation_api.create_sp(sp_id, service_provider)
response = ServiceProvider.wrap_member(request.context_dict, sp_ref)
return wsgi.render_response(body=response, status=('201', 'Created'))
return wsgi.render_response(body=response, status=(201, 'Created'))
@controller.filterprotected('id', 'enabled')
def list_service_providers(self, request, filters):
@ -532,5 +532,5 @@ class SAMLMetadataV3(_ControllerBase):
except IOError as e:
# Raise HTTP 500 in case Metadata file cannot be read.
raise exception.MetadataFileError(reason=e)
return wsgi.render_response(body=metadata, status=('200', 'OK'),
return wsgi.render_response(body=metadata, status=(200, 'OK'),
headers=[('Content-Type', 'text/xml')])

View File

@ -189,7 +189,7 @@ class DomainConfigV3(controller.V3Controller):
return wsgi.render_response(body={self.member_name: ref})
else:
return wsgi.render_response(body={self.member_name: ref},
status=('201', 'Created'))
status=(201, 'Created'))
@controller.protected()
def get_domain_config(self, request, domain_id, group=None, option=None):