Browse code

use ~/.s3cfg in run-tests too

Matt Domsch authored on 2014/02/22 06:13:01
Showing 1 changed files
... ...
@@ -12,6 +12,8 @@ import re
12 12
 from subprocess import Popen, PIPE, STDOUT
13 13
 import locale
14 14
 import getpass
15
+import S3.Exceptions
16
+import S3.Config
15 17
 
16 18
 count_pass = 0
17 19
 count_fail = 0
... ...
@@ -31,6 +33,14 @@ else:
31 31
     print "Unknown platform: %s" % os.name
32 32
     sys.exit(1)
33 33
 
34
+config_file = None
35
+if os.getenv("HOME"):
36
+    config_file = os.path.join(os.getenv("HOME"), ".s3cfg")
37
+elif os.name == "nt" and os.getenv("USERPROFILE"):
38
+    config_file = os.path.join(os.getenv("USERPROFILE").decode('mbcs'), "Application Data", "s3cmd.ini")
39
+
40
+cfg = S3.Config.Config(config_file)
41
+
34 42
 ## Unpack testsuite/ directory
35 43
 if not os.path.isdir('testsuite') and os.path.isfile('testsuite.tar.gz'):
36 44
     os.system("tar -xz -f testsuite.tar.gz")
... ...
@@ -355,7 +365,7 @@ test_s3cmd("Put public, guess MIME", ['put', '--guess-mime-type', '--acl-public'
355 355
 
356 356
 ## ====== Retrieve from URL
357 357
 if have_wget:
358
-    test("Retrieve from URL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.s3.amazonaws.com/xyz/etc/logo.png' % bucket(1)],
358
+    test("Retrieve from URL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.%s/xyz/etc/logo.png' % (bucket(1), cfg.host_base)],
359 359
         must_find_re = [ 'logo.png.*saved \[22059/22059\]' ])
360 360
 
361 361
 
... ...
@@ -366,7 +376,7 @@ test_s3cmd("Change ACL to Private", ['setacl', '--acl-private', '%s/xyz/etc/l*.p
366 366
 
367 367
 ## ====== Verify Private ACL
368 368
 if have_wget:
369
-    test("Verify Private ACL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.s3.amazonaws.com/xyz/etc/logo.png' % bucket(1)],
369
+    test("Verify Private ACL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.%s/xyz/etc/logo.png' % (bucket(1), cfg.host_base)],
370 370
         retcode = 8,
371 371
         must_find_re = [ 'ERROR 403: Forbidden' ])
372 372
 
... ...
@@ -378,7 +388,7 @@ test_s3cmd("Change ACL to Public", ['setacl', '--acl-public', '--recursive', '%s
378 378
 
379 379
 ## ====== Verify Public ACL
380 380
 if have_wget:
381
-    test("Verify Public ACL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.s3.amazonaws.com/xyz/etc/logo.png' % bucket(1)],
381
+    test("Verify Public ACL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.%s/xyz/etc/logo.png' % (bucket(1), cfg.host_base)],
382 382
         must_find_re = [ 'logo.png.*saved \[22059/22059\]' ])
383 383
 
384 384
 
... ...
@@ -461,7 +471,7 @@ test_s3cmd("Recursive copy, set ACL", ['cp', '-r', '--acl-public', '%s/xyz/' % p
461 461
 test_s3cmd("Verify ACL and MIME type", ['info', '%s/copy/etc2/Logo.PNG' % pbucket(2) ],
462 462
     must_find_re = [ "MIME type:.*image/png",
463 463
                      "ACL:.*\*anon\*: READ",
464
-                     "URL:.*http://%s.s3.amazonaws.com/copy/etc2/Logo.PNG" % bucket(2) ])
464
+                     "URL:.*http://%s.%s/copy/etc2/Logo.PNG" % (bucket(2), cfg.host_base) ])
465 465
 
466 466
 ## ====== Rename within S3
467 467
 test_s3cmd("Rename within S3", ['mv', '%s/copy/etc2/Logo.PNG' % pbucket(2), '%s/copy/etc/logo.png' % pbucket(2)],