This tests the --add-header and --remove-header functionality.
This also adds a dependency on curl to run these tests.
... | ... |
@@ -219,6 +219,11 @@ def test_copy(label, src_file, dst_file): |
219 | 219 |
cmd.append(dst_file) |
220 | 220 |
return test(label, cmd) |
221 | 221 |
|
222 |
+def test_curl_HEAD(label, src_file, **kwargs): |
|
223 |
+ cmd = ['curl', '-s', '-I'] |
|
224 |
+ cmd.append(src_file) |
|
225 |
+ return test(label, cmd, **kwargs) |
|
226 |
+ |
|
222 | 227 |
bucket_prefix = u"%s-" % getpass.getuser() |
223 | 228 |
print "Using bucket prefix: '%s'" % bucket_prefix |
224 | 229 |
|
... | ... |
@@ -503,6 +508,18 @@ test_s3cmd("Verify ACL and MIME type", ['info', '%s/copy/etc2/Logo.PNG' % pbucke |
503 | 503 |
"ACL:.*\*anon\*: READ", |
504 | 504 |
"URL:.*http://%s.%s/copy/etc2/Logo.PNG" % (bucket(2), cfg.host_base) ]) |
505 | 505 |
|
506 |
+test_s3cmd("Add cache-control header", ['modify', '--add-header=cache-control: max-age=3600', '%s/copy/etc2/Logo.PNG' % pbucket(2) ], |
|
507 |
+ must_find_re = [ "File .* modified" ]) |
|
508 |
+ |
|
509 |
+test_curl_HEAD("HEAD check Cache-Control present", 'http://%s.%s/copy/etc2/Logo.PNG' % (bucket(2), cfg.host_base), |
|
510 |
+ must_find_re = [ "Cache-Control: max-age=3600" ]) |
|
511 |
+ |
|
512 |
+test_s3cmd("Remove cache-control header", ['modify', '--remove-header=cache-control', '%s/copy/etc2/Logo.PNG' % pbucket(2) ], |
|
513 |
+ must_find_re = [ "File .* modified" ]) |
|
514 |
+ |
|
515 |
+test_curl_HEAD("HEAD check Cache-Control not present", 'http://%s.%s/copy/etc2/Logo.PNG' % (bucket(2), cfg.host_base), |
|
516 |
+ must_not_find_re = [ "Cache-Control: max-age=3600" ]) |
|
517 |
+ |
|
506 | 518 |
|
507 | 519 |
## ====== Rename within S3 |
508 | 520 |
test_s3cmd("Rename within S3", ['mv', '%s/copy/etc2/Logo.PNG' % pbucket(2), '%s/copy/etc/logo.png' % pbucket(2)], |