Merge lp:~oubiwann/txaws/919433-missing-put-object-acl into lp:txaws

Proposed by Duncan McGreggor
Status: Merged
Approved by: Thomas Herve
Approved revision: 113
Merged at revision: 119
Proposed branch: lp:~oubiwann/txaws/919433-missing-put-object-acl
Merge into: lp:txaws
Diff against target: 73 lines (+44/-1)
3 files modified
txaws/s3/client.py (+10/-0)
txaws/s3/tests/test_client.py (+33/-0)
txaws/version.py (+1/-1)
To merge this branch: bzr merge lp:~oubiwann/txaws/919433-missing-put-object-acl
Reviewer Review Type Date Requested Status
Thomas Herve Approve
Review via email: mp+89520@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Thomas Herve (therve) wrote :

Looks good, +1!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'txaws/s3/client.py'
2--- txaws/s3/client.py 2012-01-06 00:00:22 +0000
3+++ txaws/s3/client.py 2012-01-21 08:07:26 +0000
4@@ -283,6 +283,16 @@
5 bucket=bucket, object_name=object_name)
6 return query.submit()
7
8+ def put_object_acl(self, bucket, object_name, access_control_policy):
9+ """
10+ Set access control policy on an object.
11+ """
12+ data = access_control_policy.to_xml()
13+ query = self.query_factory(
14+ action='PUT', creds=self.creds, endpoint=self.endpoint,
15+ bucket=bucket, object_name='%s?acl' % object_name, data=data)
16+ return query.submit().addCallback(self._parse_acl)
17+
18 def get_object_acl(self, bucket, object_name):
19 """
20 Get the access control policy for an object.
21
22=== modified file 'txaws/s3/tests/test_client.py'
23--- txaws/s3/tests/test_client.py 2012-01-06 09:51:07 +0000
24+++ txaws/s3/tests/test_client.py 2012-01-21 08:07:26 +0000
25@@ -523,6 +523,39 @@
26 s3 = client.S3Client(creds, query_factory=StubQuery)
27 return s3.delete_object("mybucket", "objectname")
28
29+ def test_put_object_acl(self):
30+
31+ class StubQuery(client.Query):
32+
33+ def __init__(query, action, creds, endpoint, bucket=None,
34+ object_name=None, data=""):
35+ super(StubQuery, query).__init__(action=action, creds=creds,
36+ bucket=bucket,
37+ object_name=object_name,
38+ data=data)
39+ self.assertEquals(action, "PUT")
40+ self.assertEqual(creds.access_key, "foo")
41+ self.assertEqual(creds.secret_key, "bar")
42+ self.assertEqual(query.bucket, "mybucket")
43+ self.assertEqual(query.object_name, "myobject?acl")
44+ self.assertEqual(query.data,
45+ payload.sample_access_control_policy_result)
46+ self.assertEqual(query.metadata, {})
47+ self.assertEqual(query.metadata, {})
48+
49+ def submit(query, url_context=None):
50+ return succeed(payload.sample_access_control_policy_result)
51+
52+ def check_result(result):
53+ self.assert_(isinstance(result, AccessControlPolicy))
54+
55+ creds = AWSCredentials("foo", "bar")
56+ s3 = client.S3Client(creds, query_factory=StubQuery)
57+ policy = AccessControlPolicy.from_xml(
58+ payload.sample_access_control_policy_result)
59+ deferred = s3.put_object_acl("mybucket", "myobject", policy)
60+ return deferred.addCallback(check_result)
61+
62 def test_get_object_acl(self):
63
64 class StubQuery(client.Query):
65
66=== modified file 'txaws/version.py'
67--- txaws/version.py 2011-11-29 08:17:54 +0000
68+++ txaws/version.py 2012-01-21 08:07:26 +0000
69@@ -1,3 +1,3 @@
70-txaws = "0.2.2"
71+txaws = "0.2.3"
72 ec2_api = "2008-12-01"
73 s3_api = "2006-03-01"

Subscribers

People subscribed via source and target branches

to all changes: