diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-10-09 05:33:26 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-10-09 05:33:26 +0000 |
commit | 022ad52213d6186d6ab2a82e5a93564c9630d073 (patch) | |
tree | 63f57a0798cc3e0d8c7adbd17dd1dab2daa5ca23 | |
parent | 62982779af9c6eb633a0f29248b9830aef4f172c (diff) | |
parent | 221aa9edd33fab41c696431261cb3414f3c02355 (diff) | |
download | swift-022ad52213d6186d6ab2a82e5a93564c9630d073.tar.gz |
Merge "allow container create even if over account quota"
-rw-r--r-- | swift/common/middleware/account_quotas.py | 2 | ||||
-rw-r--r-- | test/unit/common/middleware/test_account_quotas.py | 24 |
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')] |