From 09cdd45026070c5231523e18d1f260f496cf0510 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 6 Jul 2012 15:17:18 -0700 Subject: [PATCH] test_s3: add a test for response header modification Testing response header fields modification by specified params. Signed-off-by: Yehuda Sadeh --- s3tests/functional/test_s3.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index 7721854..ae3abad 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -1038,14 +1038,14 @@ def _setup_bucket_request(bucket_acl=None): return bucket -def _make_request(method, bucket, key, body=None, authenticated=False): +def _make_request(method, bucket, key, body=None, authenticated=False, response_headers=None): """ issue a request for a specified method, on a specified , with a specified (optional) body (encrypted per the connection), and return the response (status, reason) """ if authenticated: - url = key.generate_url(100000, method=method) + url = key.generate_url(100000, method=method, response_headers=response_headers) o = urlparse(url) path = o.path + '?' + o.query else: @@ -1209,6 +1209,36 @@ def test_object_raw_authenticated(): eq(res.reason, 'OK') +@attr(resource='object') +@attr(method='get') +@attr(operation='authenticated on private bucket/private object with modified response headers') +@attr(assertion='succeeds') +@attr('fails_on_dho') +@attr('fails_on_rgw') +def test_object_raw_response_headers(): + (bucket, key) = _setup_request('private', 'private') + + response_headers = { + 'response-content-type': 'foo/bar', + 'response-content-disposition': 'bla', + 'response-content-language': 'esperanto', + 'response-content-encoding': 'aaa', + 'response-expires': '123', + 'response-cache-control': 'no-cache', + } + + res = _make_request('GET', bucket, key, authenticated=True, + response_headers=response_headers) + eq(res.status, 200) + eq(res.reason, 'OK') + eq(res.getheader('content-type'), 'foo/bar') + eq(res.getheader('content-disposition'), 'bla') + eq(res.getheader('content-language'), 'esperanto') + eq(res.getheader('content-encoding'), 'aaa') + eq(res.getheader('expires'), '123') + eq(res.getheader('cache-control'), 'no-cache') + + @attr(resource='object') @attr(method='ACLs') @attr(operation='authenticated on private bucket/public object')