From 7958729198045a2fc95480e9713a4dde2f86ad01 Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: Fri, 9 Jan 2015 14:38:23 +0000 Subject: [PATCH] Test that SLO disallows too small first segment if other segments SLO allows the first segment to be less than min_segment_size if it is the only segment. Current tests verify that a single small segment is allowed, and that multiple small segments are disallowed. This patch adds a test to verify that SLO will disallow a manifest with a small first segment followed by another correctly sized segment. Change-Id: I920c0aee38e4e16c49bd84a3b772308a00794fa7 --- test/unit/common/middleware/test_slo.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/unit/common/middleware/test_slo.py b/test/unit/common/middleware/test_slo.py index 4ee0c155f5..f4bac155ce 100644 --- a/test/unit/common/middleware/test_slo.py +++ b/test/unit/common/middleware/test_slo.py @@ -268,6 +268,21 @@ class TestSloPutManifest(SloTestCase): self.slo(req.environ, fake_start_response) self.assertTrue('X-Static-Large-Object' in req.headers) + def test_handle_multipart_put_disallow_small_first_segment(self): + with patch.object(self.slo, 'min_segment_size', 50): + test_json_data = json.dumps([{'path': '/cont/object', + 'etag': 'etagoftheobjectsegment', + 'size_bytes': 10}, + {'path': '/cont/small_object', + 'etag': 'etagoftheobjectsegment', + 'size_bytes': 100}]) + req = Request.blank('/v1/a/c/o', body=test_json_data) + try: + self.slo.handle_multipart_put(req, fake_start_response) + except HTTPException as e: + pass + self.assertEquals(e.status_int, 400) + def test_handle_multipart_put_success_unicode(self): test_json_data = json.dumps([{'path': u'/cont/object\u2661', 'etag': 'etagoftheobjectsegment',