Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/curl #628

Merged
merged 4 commits into from Sep 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 38 additions & 24 deletions run-tests.py
Expand Up @@ -28,13 +28,28 @@

verbose = False

if os.name == "posix":
have_wget = True
elif os.name == "nt":
have_wget = False
# https://stackoverflow.com/questions/377017/test-if-executable-exists-in-python/377028#377028
def which(program):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file

return None

if which('curl') is not None:
have_curl = True
else:
print "Unknown platform: %s" % os.name
sys.exit(1)
have_curl = False

config_file = None
if os.getenv("HOME"):
Expand Down Expand Up @@ -222,8 +237,8 @@ def test_copy(label, src_file, dst_file):
cmd.append(dst_file)
return test(label, cmd)

def test_wget_HEAD(label, src_file, **kwargs):
cmd = ['wget', '-q', '-S', '--method=HEAD']
def test_curl_HEAD(label, src_file, **kwargs):
cmd = ['curl', '--silent', '--head', '-include', '--location']
cmd.append(src_file)
return test(label, cmd, **kwargs)

Expand Down Expand Up @@ -406,21 +421,19 @@ def pbucket(tail):


## ====== Retrieve from URL
if have_wget:
test("Retrieve from URL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.%s/xyz/etc/logo.png' % (bucket(1), cfg.host_base)],
must_find_re = [ 'logo.png.*saved \[22059/22059\]' ])

if have_curl:
test_curl_HEAD("Retrieve from URL", 'http://%s.%s/xyz/etc/logo.png' % (bucket(1), cfg.host_base),
must_find_re = ['Content-Length: 22059'])

## ====== Change ACL to Private
test_s3cmd("Change ACL to Private", ['setacl', '--acl-private', '%s/xyz/etc/l*.png' % pbucket(1)],
must_find = [ "logo.png: ACL set to Private" ])


## ====== Verify Private ACL
if have_wget:
test("Verify Private ACL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.%s/xyz/etc/logo.png' % (bucket(1), cfg.host_base)],
retcode = [1, 8],
must_find_re = [ 'ERROR 403: Forbidden' ])
if have_curl:
test_curl_HEAD("Verify Private ACL", 'http://%s.%s/xyz/etc/logo.png' % (bucket(1), cfg.host_base),
must_find_re = [ '403 Forbidden' ])


## ====== Change ACL to Public
Expand All @@ -429,9 +442,10 @@ def pbucket(tail):


## ====== Verify Public ACL
if have_wget:
test("Verify Public ACL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.%s/xyz/etc/logo.png' % (bucket(1), cfg.host_base)],
must_find_re = [ 'logo.png.*saved \[22059/22059\]' ])
if have_curl:
test_curl_HEAD("Verify Public ACL", 'http://%s.%s/xyz/etc/logo.png' % (bucket(1), cfg.host_base),
must_find_re = [ '200 OK',
'Content-Length: 22059'])


## ====== Sync more to S3
Expand Down Expand Up @@ -547,15 +561,15 @@ def pbucket(tail):
test_s3cmd("Add cache-control header", ['modify', '--add-header=cache-control: max-age=3600, public', '%s/copy/etc2/Logo.PNG' % pbucket(2) ],
must_find_re = [ "modify: .*" ])

if have_wget:
test_wget_HEAD("HEAD check Cache-Control present", 'http://%s.%s/copy/etc2/Logo.PNG' % (bucket(2), cfg.host_base),
if have_curl:
test_curl_HEAD("HEAD check Cache-Control present", 'http://%s.%s/copy/etc2/Logo.PNG' % (bucket(2), cfg.host_base),
must_find_re = [ "Cache-Control: max-age=3600" ])

test_s3cmd("Remove cache-control header", ['modify', '--remove-header=cache-control', '%s/copy/etc2/Logo.PNG' % pbucket(2) ],
must_find_re = [ "modify: .*" ])
must_find_re = [ "modify: .*" ])

if have_wget:
test_wget_HEAD("HEAD check Cache-Control not present", 'http://%s.%s/copy/etc2/Logo.PNG' % (bucket(2), cfg.host_base),
if have_curl:
test_curl_HEAD("HEAD check Cache-Control not present", 'http://%s.%s/copy/etc2/Logo.PNG' % (bucket(2), cfg.host_base),
must_not_find_re = [ "Cache-Control: max-age=3600" ])

## ====== sign
Expand Down