summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--swift/common/middleware/account_quotas.py2
-rw-r--r--test/unit/common/middleware/test_account_quotas.py24
2 files changed, 25 insertions, 1 deletions
diff --git a/swift/common/middleware/account_quotas.py b/swift/common/middleware/account_quotas.py
index a3a6ab8d7..c687f983d 100644
--- a/swift/common/middleware/account_quotas.py
+++ b/swift/common/middleware/account_quotas.py
@@ -95,7 +95,7 @@ class AccountQuotaMiddleware(object):
if new_quota is not None:
return HTTPForbidden()
- if obj and request.method == "POST":
+ if obj and request.method == "POST" or not obj:
return self.app
copy_from = request.headers.get('X-Copy-From')
diff --git a/test/unit/common/middleware/test_account_quotas.py b/test/unit/common/middleware/test_account_quotas.py
index 623c75810..a058439b6 100644
--- a/test/unit/common/middleware/test_account_quotas.py
+++ b/test/unit/common/middleware/test_account_quotas.py
@@ -124,6 +124,30 @@ class TestAccountQuota(unittest.TestCase):
res = req.get_response(app)
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):
headers = [('x-account-bytes-used', '1001'),
('x-account-meta-quota-bytes', '1000')]