Merge "Check object metadata constraints after authorizing"

This commit is contained in:
Jenkins 2016-08-01 14:38:13 +00:00 committed by Gerrit Code Review
commit 3cbb62a898
2 changed files with 22 additions and 3 deletions

View File

@ -212,9 +212,6 @@ class BaseObjectController(Controller):
@delay_denial
def POST(self, req):
"""HTTP POST request handler."""
error_response = check_metadata(req, 'object')
if error_response:
return error_response
container_info = self.container_info(
self.account_name, self.container_name, req)
container_partition = container_info['partition']
@ -226,6 +223,9 @@ class BaseObjectController(Controller):
return aresp
if not container_nodes:
return HTTPNotFound(request=req)
error_response = check_metadata(req, 'object')
if error_response:
return error_response
req, delete_at_container, delete_at_part, \
delete_at_nodes = self._config_obj_expiration(req)

View File

@ -3418,6 +3418,25 @@ class TestObjectController(unittest.TestCase):
res = req.get_response(self.app)
self.assertEqual(res.status_int, 400)
def test_POST_meta_authorize(self):
def authorize(req):
req.headers['X-Object-Meta-Foo'] = 'x' * (limit + 1)
return
with save_globals():
limit = constraints.MAX_META_VALUE_LENGTH
self.app.object_post_as_copy = False
controller = ReplicatedObjectController(
self.app, 'account', 'container', 'object')
set_http_connect(200, 200, 202, 202, 202)
# acct cont obj obj obj
req = Request.blank('/v1/a/c/o', {'REQUEST_METHOD': 'POST'},
headers={'Content-Type': 'foo/bar',
'X-Object-Meta-Foo': 'x'})
req.environ['swift.authorize'] = authorize
self.app.update_request(req)
res = controller.POST(req)
self.assertEqual(res.status_int, 400)
def test_POST_meta_key_len(self):
with save_globals():
limit = constraints.MAX_META_NAME_LENGTH