Merge "Return verbose message if account quota exceeded"
This commit is contained in:
commit
16e1e1e3c6
@ -53,8 +53,7 @@ account size has been updated.
|
||||
"""
|
||||
|
||||
from swift.common.constraints import check_copy_from_header
|
||||
from swift.common.swob import HTTPForbidden, HTTPRequestEntityTooLarge, \
|
||||
HTTPBadRequest, wsgify
|
||||
from swift.common.swob import HTTPForbidden, Response, HTTPBadRequest, wsgify
|
||||
from swift.common.utils import register_swift_info
|
||||
from swift.proxy.controllers.base import get_account_info, get_object_info
|
||||
|
||||
@ -137,7 +136,7 @@ class AccountQuotaMiddleware(object):
|
||||
|
||||
new_size = int(account_info['bytes']) + content_length
|
||||
if quota < new_size:
|
||||
return HTTPRequestEntityTooLarge()
|
||||
return Response(status=413, body='Upload exceeds quota.')
|
||||
|
||||
return self.app
|
||||
|
||||
|
@ -140,6 +140,7 @@ class TestAccountQuota(unittest.TestCase):
|
||||
'swift.cache': cache})
|
||||
res = req.get_response(app)
|
||||
self.assertEquals(res.status_int, 413)
|
||||
self.assertEquals(res.body, 'Upload exceeds quota.')
|
||||
|
||||
def test_over_quota_container_create_still_works(self):
|
||||
headers = [('x-account-bytes-used', '1001'),
|
||||
@ -189,6 +190,7 @@ class TestAccountQuota(unittest.TestCase):
|
||||
headers={'x-copy-from': '/c2/o2'})
|
||||
res = req.get_response(app)
|
||||
self.assertEquals(res.status_int, 413)
|
||||
self.assertEquals(res.body, 'Upload exceeds quota.')
|
||||
|
||||
def test_exceed_bytes_quota_copy_verb(self):
|
||||
headers = [('x-account-bytes-used', '500'),
|
||||
@ -202,6 +204,7 @@ class TestAccountQuota(unittest.TestCase):
|
||||
headers={'Destination': '/c/o'})
|
||||
res = req.get_response(app)
|
||||
self.assertEquals(res.status_int, 413)
|
||||
self.assertEquals(res.body, 'Upload exceeds quota.')
|
||||
|
||||
def test_not_exceed_bytes_quota_copy_from(self):
|
||||
headers = [('x-account-bytes-used', '0'),
|
||||
|
@ -93,6 +93,7 @@ class TestContainerQuotas(unittest.TestCase):
|
||||
'CONTENT_LENGTH': '100'})
|
||||
res = req.get_response(app)
|
||||
self.assertEquals(res.status_int, 413)
|
||||
self.assertEquals(res.body, 'Upload exceeds quota.')
|
||||
|
||||
def test_exceed_bytes_quota_copy_from(self):
|
||||
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
|
||||
@ -105,6 +106,7 @@ class TestContainerQuotas(unittest.TestCase):
|
||||
headers={'x-copy-from': '/c2/o2'})
|
||||
res = req.get_response(app)
|
||||
self.assertEquals(res.status_int, 413)
|
||||
self.assertEquals(res.body, 'Upload exceeds quota.')
|
||||
|
||||
def test_exceed_bytes_quota_copy_verb(self):
|
||||
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
|
||||
@ -117,6 +119,7 @@ class TestContainerQuotas(unittest.TestCase):
|
||||
headers={'Destination': '/c/o'})
|
||||
res = req.get_response(app)
|
||||
self.assertEquals(res.status_int, 413)
|
||||
self.assertEquals(res.body, 'Upload exceeds quota.')
|
||||
|
||||
def test_not_exceed_bytes_quota(self):
|
||||
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
|
||||
@ -191,6 +194,7 @@ class TestContainerQuotas(unittest.TestCase):
|
||||
'CONTENT_LENGTH': '100'})
|
||||
res = req.get_response(app)
|
||||
self.assertEquals(res.status_int, 413)
|
||||
self.assertEquals(res.body, 'Upload exceeds quota.')
|
||||
|
||||
def test_exceed_counts_quota_copy_from(self):
|
||||
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
|
||||
@ -202,6 +206,7 @@ class TestContainerQuotas(unittest.TestCase):
|
||||
headers={'x-copy-from': '/c2/o2'})
|
||||
res = req.get_response(app)
|
||||
self.assertEquals(res.status_int, 413)
|
||||
self.assertEquals(res.body, 'Upload exceeds quota.')
|
||||
|
||||
def test_exceed_counts_quota_copy_verb(self):
|
||||
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
|
||||
@ -212,6 +217,7 @@ class TestContainerQuotas(unittest.TestCase):
|
||||
headers={'Destination': '/c/o'})
|
||||
res = req.get_response(app)
|
||||
self.assertEquals(res.status_int, 413)
|
||||
self.assertEquals(res.body, 'Upload exceeds quota.')
|
||||
|
||||
def test_not_exceed_counts_quota(self):
|
||||
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
|
||||
|
Loading…
Reference in New Issue
Block a user