Permalink
Browse files

* S3/ACL.py: Move attributes from class to instance.

* run-tests.py: Tests for ACL.
* s3cmd: Minor messages changes.



git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@334 830e0280-6d2a-0410-9c65-932aecc39d9d
  • Loading branch information...
1 parent d56ec48 commit e3244a8cbcdc847d3bcb648ad7dbdc68807f1925 @mludvig mludvig committed Jan 7, 2009
Showing with 53 additions and 22 deletions.
  1. +3 −0 ChangeLog
  2. +17 −13 S3/ACL.py
  3. +31 −8 run-tests.py
  4. +2 −1 s3cmd
View
@@ -2,6 +2,9 @@
* S3/S3.py: Some errors during file upload were incorrectly
interpreted as MD5 mismatch. (bug #2384990)
+ * S3/ACL.py: Move attributes from class to instance.
+ * run-tests.py: Tests for ACL.
+ * s3cmd: Minor messages changes.
2009-01-07 Michal Ludvig <michal@logix.cz>
View
@@ -13,11 +13,12 @@
class Grantee(object):
ALL_USERS_URI = "http://acs.amazonaws.com/groups/global/AllUsers"
- xsi_type = None
- tag = None
- name = None
- display_name = None
- permission = None
+ def __init__(self):
+ self.xsi_type = None
+ self.tag = None
+ self.name = None
+ self.display_name = None
+ self.permission = None
def __repr__(self):
return 'Grantee("%(tag)s", "%(name)s", "%(permission)s")' % {
@@ -45,21 +46,24 @@ def getElement(self):
return el
class GranteeAnonRead(Grantee):
- xsi_type = "Group"
- tag = "URI"
- name = Grantee.ALL_USERS_URI
- permission = "READ"
+ def __init__(self):
+ Grantee.__init__(self)
+ self.xsi_type = "Group"
+ self.tag = "URI"
+ self.name = Grantee.ALL_USERS_URI
+ self.permission = "READ"
class ACL(object):
EMPTY_ACL = "<AccessControlPolicy><Owner><ID></ID></Owner><AccessControlList></AccessControlList></AccessControlPolicy>"
- grantees = []
- owner_id = ""
- owner_nick = ""
-
def __init__(self, xml = None):
if not xml:
xml = ACL.EMPTY_ACL
+
+ self.grantees = []
+ self.owner_id = ""
+ self.owner_nick = ""
+
tree = getTreeFromXml(xml)
self.parseOwner(tree)
self.parseGrants(tree)
View
@@ -238,26 +238,49 @@ def test_rmdir(label, dir_name):
# test_s3cmd("Recursive put", ['put', '--recursive', 'testsuite/etc', 's3://s3cmd-autotest-1/xyz/'])
-## ====== Put public, guess MIME
-test_s3cmd("Put public, guess MIME", ['put', '--guess-mime-type', '--acl-public', 'testsuite/etc/logo.png', 's3://s3cmd-autotest-1/xyz/etc/logo.png'],
- must_find = [ "stored as s3://s3cmd-autotest-1/xyz/etc/logo.png" ])
-
-
## ====== rmdir local
test_rmdir("Removing local target", 'testsuite-out')
## ====== Sync from S3
-must_find = [ "stored as testsuite-out/etc/logo.png " ]
+must_find = [ "stored as testsuite-out/binary/random-crap.md5 " ]
if have_encoding:
must_find.append("stored as testsuite-out/" + encoding + "/" + enc_pattern)
test_s3cmd("Sync from S3", ['sync', 's3://s3cmd-autotest-1/xyz', 'testsuite-out'],
must_find = must_find)
+## ====== Put public, guess MIME
+test_s3cmd("Put public, guess MIME", ['put', '--guess-mime-type', '--acl-public', 'testsuite/etc/logo.png', 's3://s3cmd-autotest-1/xyz/etc/logo.png'],
+ must_find = [ "stored as s3://s3cmd-autotest-1/xyz/etc/logo.png" ])
+
+
## ====== Retrieve from URL
if have_wget:
- test("Retrieve from URL", ['wget', 'http://s3cmd-autotest-1.s3.amazonaws.com/xyz/etc/logo.png'],
+ test("Retrieve from URL", ['wget', '-O', 'testsuite-out/logo.png', 'http://s3cmd-autotest-1.s3.amazonaws.com/xyz/etc/logo.png'],
+ must_find_re = [ 'logo.png.*saved \[22059/22059\]' ])
+
+
+## ====== Change ACL to Private
+test_s3cmd("Change ACL to Private", ['setacl', '--acl-private', 's3://s3cmd-autotest-1/xyz/etc/l*.png'],
+ 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://s3cmd-autotest-1.s3.amazonaws.com/xyz/etc/logo.png'],
+ retcode = 1,
+ must_find_re = [ 'ERROR 403: Forbidden' ])
+
+
+## ====== Change ACL to Public
+test_s3cmd("Change ACL to Public", ['setacl', '--acl-public', '--recursive', 's3://s3cmd-autotest-1/xyz/etc/', '-v'],
+ must_find = [ "logo.png: ACL set to Public" ])
+
+
+## ====== Verify Public ACL
+if have_wget:
+ test("Verify Public ACL", ['wget', '-O', 'testsuite-out/logo.png', 'http://s3cmd-autotest-1.s3.amazonaws.com/xyz/etc/logo.png'],
must_find_re = [ 'logo.png.*saved \[22059/22059\]' ])
@@ -279,7 +302,7 @@ def test_rmdir(label, dir_name):
## ====== Sync more from S3
test_s3cmd("Sync more from S3", ['sync', '--delete-removed', 's3://s3cmd-autotest-1/xyz', 'testsuite-out'],
- must_find = [ "deleted 'testsuite-out/etc/logo.png'", "stored as testsuite-out/etc2/Logo.PNG (22059 bytes",
+ must_find = [ "deleted 'testsuite-out/logo.png'", "stored as testsuite-out/etc2/Logo.PNG (22059 bytes",
"stored as testsuite-out/.svn/format " ],
must_not_find_re = [ "not-deleted.*etc/logo.png" ])
View
3 s3cmd
@@ -898,9 +898,10 @@ def cmd_setacl(args):
seq_label = "[%d of %d]" % (seq, total_keys)
uri = key['remote_uri']
acl = s3.get_acl(uri)
+ debug(u"acl: %s - %r" % (uri, acl.grantees))
if cfg.acl_public:
if acl.isAnonRead():
- info(u"%s: already Public, skippingi %s" % (uri, seq_label))
+ info(u"%s: already Public, skipping %s" % (uri, seq_label))
continue
acl.grantAnonRead()
else:

0 comments on commit e3244a8

Please sign in to comment.