Merge "Fix obscure double url bug in container quota middleware"
This commit is contained in:
@@ -64,12 +64,12 @@ class ContainerQuotaMiddleware(object):
|
|||||||
@wsgify
|
@wsgify
|
||||||
def __call__(self, req):
|
def __call__(self, req):
|
||||||
try:
|
try:
|
||||||
(version, account, container, obj) = req.split_path(2, 4, True)
|
(version, account, container, obj) = req.split_path(3, 4, True)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return self.app
|
return self.app
|
||||||
|
|
||||||
# verify new quota headers are properly formatted
|
# verify new quota headers are properly formatted
|
||||||
if container and not obj and req.method in ('PUT', 'POST'):
|
if not obj and req.method in ('PUT', 'POST'):
|
||||||
val = req.headers.get('X-Container-Meta-Quota-Bytes')
|
val = req.headers.get('X-Container-Meta-Quota-Bytes')
|
||||||
if val and not val.isdigit():
|
if val and not val.isdigit():
|
||||||
return HTTPBadRequest(body='Invalid bytes quota.')
|
return HTTPBadRequest(body='Invalid bytes quota.')
|
||||||
|
|||||||
@@ -48,6 +48,14 @@ def start_response(*args):
|
|||||||
|
|
||||||
class TestContainerQuotas(unittest.TestCase):
|
class TestContainerQuotas(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_split_path_empty_container_path_segment(self):
|
||||||
|
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
|
||||||
|
req = Request.blank('/v1/a//something/something_else',
|
||||||
|
environ={'REQUEST_METHOD': 'PUT',
|
||||||
|
'swift.cache': {'key':'value'}})
|
||||||
|
res = req.get_response(app)
|
||||||
|
self.assertEquals(res.status_int, 200)
|
||||||
|
|
||||||
def test_not_handled(self):
|
def test_not_handled(self):
|
||||||
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
|
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
|
||||||
req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': 'PUT'})
|
req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': 'PUT'})
|
||||||
|
|||||||
Reference in New Issue
Block a user