Skip to content

Commit

Permalink
Add tests for metadata on 304 and 412 responses
Browse files Browse the repository at this point in the history
Commit 1f67eb7 added support for If-[None-]Match on DLOs and SLOs. It
also made the 304 and 412 responses have the Content-Type and
X-Object-Meta-* headers from the object instead of just having the
Etag.

Someone showed up in IRC today looking for this behavior, and was
happy to learn it's in newer Swift versions than the one they were
running. If we've got clients depending on this, we should have some
unit tests to make sure we don't accidentally take it out again.

Change-Id: If06149d13140148463004d426cb7ba4c5601404a
  • Loading branch information
smerritt committed Dec 12, 2014
1 parent cc2f0f4 commit f483508
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/unit/obj/test_server.py
Expand Up @@ -1335,7 +1335,8 @@ def test_GET_if_none_match(self):
req = Request.blank('/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
headers={
'X-Timestamp': normalize_timestamp(time()),
'Content-Type': 'application/octet-stream',
'X-Object-Meta-Soup': 'gazpacho',
'Content-Type': 'application/fizzbuzz',
'Content-Length': '4'})
req.body = 'test'
resp = req.get_response(self.object_controller)
Expand All @@ -1352,6 +1353,8 @@ def test_GET_if_none_match(self):
resp = req.get_response(self.object_controller)
self.assertEquals(resp.status_int, 304)
self.assertEquals(resp.etag, etag)
self.assertEquals(resp.headers['Content-Type'], 'application/fizzbuzz')
self.assertEquals(resp.headers['X-Object-Meta-Soup'], 'gazpacho')

req = Request.blank('/sda1/p/a/c/o2',
environ={'REQUEST_METHOD': 'GET'},
Expand Down Expand Up @@ -1579,7 +1582,8 @@ def test_GET_if_unmodified_since(self):
req = Request.blank('/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
headers={
'X-Timestamp': timestamp,
'Content-Type': 'application/octet-stream',
'X-Object-Meta-Burr': 'ito',
'Content-Type': 'application/cat-picture',
'Content-Length': '4'})
req.body = 'test'
resp = req.get_response(self.object_controller)
Expand All @@ -1602,6 +1606,9 @@ def test_GET_if_unmodified_since(self):
headers={'If-Unmodified-Since': since})
resp = req.get_response(self.object_controller)
self.assertEquals(resp.status_int, 412)
self.assertEquals(resp.headers['Content-Type'],
'application/cat-picture')
self.assertEquals(resp.headers['X-Object-Meta-Burr'], 'ito')

since = \
strftime('%a, %d %b %Y %H:%M:%S GMT', gmtime(float(timestamp) + 9))
Expand Down

0 comments on commit f483508

Please sign in to comment.