allow container create even if over account quota

Change-Id: I07278bc3314c26426ff0557fe2f5c69c02d6550c
This commit is contained in:
Clay Gerrard 2013-10-08 13:34:50 -07:00
parent d5fcc9aaf3
commit 221aa9edd3
2 changed files with 25 additions and 1 deletions

View File

@ -95,7 +95,7 @@ class AccountQuotaMiddleware(object):
if new_quota is not None: if new_quota is not None:
return HTTPForbidden() return HTTPForbidden()
if obj and request.method == "POST": if obj and request.method == "POST" or not obj:
return self.app return self.app
copy_from = request.headers.get('X-Copy-From') copy_from = request.headers.get('X-Copy-From')

View File

@ -124,6 +124,30 @@ class TestAccountQuota(unittest.TestCase):
res = req.get_response(app) res = req.get_response(app)
self.assertEquals(res.status_int, 413) self.assertEquals(res.status_int, 413)
def test_over_quota_container_create_still_works(self):
headers = [('x-account-bytes-used', '1001'),
('x-account-meta-quota-bytes', '1000')]
app = account_quotas.AccountQuotaMiddleware(FakeApp(headers))
cache = FakeCache(None)
req = Request.blank('/v1/a/new_container',
environ={'REQUEST_METHOD': 'PUT',
'HTTP_X_CONTAINER_META_BERT': 'ernie',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
def test_over_quota_container_post_still_works(self):
headers = [('x-account-bytes-used', '1001'),
('x-account-meta-quota-bytes', '1000')]
app = account_quotas.AccountQuotaMiddleware(FakeApp(headers))
cache = FakeCache(None)
req = Request.blank('/v1/a/new_container',
environ={'REQUEST_METHOD': 'POST',
'HTTP_X_CONTAINER_META_BERT': 'ernie',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
def test_over_quota_obj_post_still_works(self): def test_over_quota_obj_post_still_works(self):
headers = [('x-account-bytes-used', '1001'), headers = [('x-account-bytes-used', '1001'),
('x-account-meta-quota-bytes', '1000')] ('x-account-meta-quota-bytes', '1000')]