Add an explicit unit test for handling content-length: 0
Change-Id: I3568d4dc1900e6ddb4860589ca6a7b7039cc8c2d Signed-off-by: Peter Portante <peter.portante@redhat.com>
This commit is contained in:
parent
dec517e349
commit
960f01b4ba
@ -661,6 +661,24 @@ class TestObjectController(unittest.TestCase):
|
||||
resp = self.object_controller.PUT(req)
|
||||
self.assertEquals(resp.status_int, 411)
|
||||
|
||||
def test_PUT_zero_content_length(self):
|
||||
req = Request.blank('/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
|
||||
headers={'X-Timestamp': normalize_timestamp(time()),
|
||||
'Content-Type': 'application/octet-stream'})
|
||||
req.body = ''
|
||||
self.assertEquals(req.headers['Content-Length'], '0')
|
||||
resp = self.object_controller.PUT(req)
|
||||
self.assertEquals(resp.status_int, 201)
|
||||
|
||||
def test_PUT_zero_content_length_mismatched(self):
|
||||
req = Request.blank('/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
|
||||
headers={'X-Timestamp': normalize_timestamp(time()),
|
||||
'Content-Type': 'application/octet-stream'})
|
||||
req.body = 'VERIFY'
|
||||
req.headers['Content-Length'] = '0'
|
||||
resp = self.object_controller.PUT(req)
|
||||
self.assertEquals(resp.status_int, 499)
|
||||
|
||||
def test_PUT_common(self):
|
||||
timestamp = normalize_timestamp(time())
|
||||
req = Request.blank('/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
|
||||
|
Loading…
Reference in New Issue
Block a user